Commit 7a5d2a196f
Changed files (5)
lib
compiler_rt
std
test
behavior
lib/compiler_rt/memcpy.zig
@@ -194,37 +194,36 @@ inline fn copyRange4(
copyFixedLength(dest + last, src + last, copy_len);
}
-test "memcpy" {
- if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
-
- const S = struct {
- fn testFunc(comptime copy_func: anytype) !void {
- const max_len = 1024;
- var buffer: [max_len + @alignOf(Element) - 1]u8 align(@alignOf(Element)) = undefined;
- for (&buffer, 0..) |*b, i| {
- b.* = @intCast(i % 97);
- }
- var dest: [max_len + @alignOf(Element) - 1]u8 align(@alignOf(Element)) = undefined;
-
- for (0..max_len) |copy_len| {
- for (0..@alignOf(Element)) |s_offset| {
- for (0..@alignOf(Element)) |d_offset| {
- @memset(&dest, 0xff);
- const s = buffer[s_offset..][0..copy_len];
- const d = dest[d_offset..][0..copy_len];
- _ = copy_func(@ptrCast(d.ptr), @ptrCast(s.ptr), s.len);
- std.testing.expectEqualSlices(u8, s, d) catch |e| {
- std.debug.print("error encountered for length={d}, s_offset={d}, d_offset={d}\n", .{
- copy_len, s_offset, d_offset,
- });
- return e;
- };
- }
- }
+fn testMemcpyImpl(comptime memcpyImpl: anytype) !void {
+ const max_len = 1024;
+ var buffer: [max_len + @alignOf(Element) - 1]u8 align(@alignOf(Element)) = undefined;
+ for (&buffer, 0..) |*b, i| {
+ b.* = @intCast(i % 97);
+ }
+ var dest: [max_len + @alignOf(Element) - 1]u8 align(@alignOf(Element)) = undefined;
+
+ for (0..max_len) |copy_len| {
+ for (0..@alignOf(Element)) |s_offset| {
+ for (0..@alignOf(Element)) |d_offset| {
+ @memset(&dest, 0xff);
+ const s = buffer[s_offset..][0..copy_len];
+ const d = dest[d_offset..][0..copy_len];
+ _ = memcpyImpl(@ptrCast(d.ptr), @ptrCast(s.ptr), s.len);
+ std.testing.expectEqualSlices(u8, s, d) catch |e| {
+ std.debug.print("error encountered for length={d}, s_offset={d}, d_offset={d}\n", .{
+ copy_len, s_offset, d_offset,
+ });
+ return e;
+ };
}
}
- };
-
- try S.testFunc(memcpySmall);
- try S.testFunc(memcpyFast);
+ }
+}
+test memcpySmall {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
+ try testMemcpyImpl(memcpySmall);
+}
+test memcpyFast {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
+ try testMemcpyImpl(memcpyFast);
}
lib/std/crypto/25519/ed25519.zig
@@ -587,8 +587,7 @@ test "signature" {
}
test "batch verification" {
- var i: usize = 0;
- while (i < 100) : (i += 1) {
+ for (0..16) |_| {
const key_pair = Ed25519.KeyPair.generate();
var msg1: [32]u8 = undefined;
var msg2: [32]u8 = undefined;
lib/std/posix/test.zig
@@ -562,15 +562,11 @@ test "sync" {
if (native_os != .linux)
return error.SkipZigTest;
- var tmp = tmpDir(.{});
- defer tmp.cleanup();
-
- const test_out_file = "os_tmp_test";
- const file = try tmp.dir.createFile(test_out_file, .{});
- defer file.close();
+ // Unfortunately, we cannot safely call `sync` or `syncfs`, because if file IO is happening
+ // than the system can commit the results to disk, such calls could block indefinitely.
- posix.sync();
- try posix.syncfs(file.handle);
+ _ = &posix.sync;
+ _ = &posix.syncfs;
}
test "fsync" {
lib/std/Thread/RwLock.zig
@@ -301,8 +301,8 @@ test "concurrent access" {
const num_writers: usize = 2;
const num_readers: usize = 4;
- const num_writes: usize = 10000;
- const num_reads: usize = num_writes * 2;
+ const num_writes: usize = 4096;
+ const num_reads: usize = 8192;
const Runner = struct {
const Self = @This();
test/behavior/call.zig
@@ -320,7 +320,7 @@ test "inline call preserves tail call" {
if (builtin.zig_backend == .stage2_c and builtin.os.tag == .windows) return error.SkipZigTest; // MSVC doesn't support always tail calls
- const max = std.math.maxInt(u16);
+ const max_depth = 1000;
const S = struct {
var a: u16 = 0;
fn foo() void {
@@ -328,16 +328,16 @@ test "inline call preserves tail call" {
}
inline fn bar() void {
- if (a == max) return;
+ if (a == max_depth) return;
// Stack overflow if not tail called
- var buf: [max]u16 = undefined;
+ var buf: [100_000]u16 = undefined;
buf[a] = a;
a += 1;
return @call(.always_tail, foo, .{});
}
};
S.foo();
- try expect(S.a == std.math.maxInt(u16));
+ try expect(S.a == max_depth);
}
test "inline call doesn't re-evaluate non generic struct" {