| author | |
| committer | |
| log | 7a5d2a196f2d78eb55f8ef294b4c899e0378f71e |
| tree | 1b969a67d606cf818b95ee5e09f4bf5fc9504b44 |
| parent | d0b92a80224e1ed44434ed8546fa2ff497cc5312 |
| signature |
5 files changed, 41 insertions(+), 47 deletions(-)
lib/compiler_rt/memcpy.zig+30-31| ... | @@ -194,37 +194,36 @@ inline fn copyRange4( | ... | @@ -194,37 +194,36 @@ inline fn copyRange4( |
| 194 | copyFixedLength(dest + last, src + last, copy_len); | 194 | copyFixedLength(dest + last, src + last, copy_len); |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | test "memcpy" { | 197 | fn testMemcpyImpl(comptime memcpyImpl: anytype) !void { |
| 198 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | 198 | const max_len = 1024; |
| 199 | 199 | var buffer: [max_len + @alignOf(Element) - 1]u8 align(@alignOf(Element)) = undefined; | |
| 200 | const S = struct { | 200 | for (&buffer, 0..) |*b, i| { |
| 201 | fn testFunc(comptime copy_func: anytype) !void { | 201 | b.* = @intCast(i % 97); |
| 202 | const max_len = 1024; | 202 | } |
| 203 | var buffer: [max_len + @alignOf(Element) - 1]u8 align(@alignOf(Element)) = undefined; | 203 | var dest: [max_len + @alignOf(Element) - 1]u8 align(@alignOf(Element)) = undefined; |
| 204 | for (&buffer, 0..) |*b, i| { | 204 | |
| 205 | b.* = @intCast(i % 97); | 205 | for (0..max_len) |copy_len| { |
| 206 | } | 206 | for (0..@alignOf(Element)) |s_offset| { |
| 207 | var dest: [max_len + @alignOf(Element) - 1]u8 align(@alignOf(Element)) = undefined; | 207 | for (0..@alignOf(Element)) |d_offset| { |
| 208 | 208 | @memset(&dest, 0xff); | |
| 209 | for (0..max_len) |copy_len| { | 209 | const s = buffer[s_offset..][0..copy_len]; |
| 210 | for (0..@alignOf(Element)) |s_offset| { | 210 | const d = dest[d_offset..][0..copy_len]; |
| 211 | for (0..@alignOf(Element)) |d_offset| { | 211 | _ = memcpyImpl(@ptrCast(d.ptr), @ptrCast(s.ptr), s.len); |
| 212 | @memset(&dest, 0xff); | 212 | std.testing.expectEqualSlices(u8, s, d) catch |e| { |
| 213 | const s = buffer[s_offset..][0..copy_len]; | 213 | std.debug.print("error encountered for length={d}, s_offset={d}, d_offset={d}\n", .{ |
| 214 | const d = dest[d_offset..][0..copy_len]; | 214 | copy_len, s_offset, d_offset, |
| 215 | _ = copy_func(@ptrCast(d.ptr), @ptrCast(s.ptr), s.len); | 215 | }); |
| 216 | std.testing.expectEqualSlices(u8, s, d) catch |e| { | 216 | return e; |
| 217 | std.debug.print("error encountered for length={d}, s_offset={d}, d_offset={d}\n", .{ | 217 | }; |
| 218 | copy_len, s_offset, d_offset, | ||
| 219 | }); | ||
| 220 | return e; | ||
| 221 | }; | ||
| 222 | } | ||
| 223 | } | ||
| 224 | } | 218 | } |
| 225 | } | 219 | } |
| 226 | }; | 220 | } |
| 227 | 221 | } | |
| 228 | try S.testFunc(memcpySmall); | 222 | test memcpySmall { |
| 229 | try S.testFunc(memcpyFast); | 223 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 224 | try testMemcpyImpl(memcpySmall); | ||
| 225 | } | ||
| 226 | test memcpyFast { | ||
| 227 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | ||
| 228 | try testMemcpyImpl(memcpyFast); | ||
| 230 | } | 229 | } |
lib/std/Thread/RwLock.zig+2-2| ... | @@ -301,8 +301,8 @@ test "concurrent access" { | ... | @@ -301,8 +301,8 @@ test "concurrent access" { |
| 301 | 301 | ||
| 302 | const num_writers: usize = 2; | 302 | const num_writers: usize = 2; |
| 303 | const num_readers: usize = 4; | 303 | const num_readers: usize = 4; |
| 304 | const num_writes: usize = 10000; | 304 | const num_writes: usize = 4096; |
| 305 | const num_reads: usize = num_writes * 2; | 305 | const num_reads: usize = 8192; |
| 306 | 306 | ||
| 307 | const Runner = struct { | 307 | const Runner = struct { |
| 308 | const Self = @This(); | 308 | const Self = @This(); |
lib/std/crypto/25519/ed25519.zig+1-2| ... | @@ -587,8 +587,7 @@ test "signature" { | ... | @@ -587,8 +587,7 @@ test "signature" { |
| 587 | } | 587 | } |
| 588 | 588 | ||
| 589 | test "batch verification" { | 589 | test "batch verification" { |
| 590 | var i: usize = 0; | 590 | for (0..16) |_| { |
| 591 | while (i < 100) : (i += 1) { | ||
| 592 | const key_pair = Ed25519.KeyPair.generate(); | 591 | const key_pair = Ed25519.KeyPair.generate(); |
| 593 | var msg1: [32]u8 = undefined; | 592 | var msg1: [32]u8 = undefined; |
| 594 | var msg2: [32]u8 = undefined; | 593 | var msg2: [32]u8 = undefined; |
lib/std/posix/test.zig+4-8| ... | @@ -562,15 +562,11 @@ test "sync" { | ... | @@ -562,15 +562,11 @@ test "sync" { |
| 562 | if (native_os != .linux) | 562 | if (native_os != .linux) |
| 563 | return error.SkipZigTest; | 563 | return error.SkipZigTest; |
| 564 | 564 | ||
| 565 | var tmp = tmpDir(.{}); | 565 | // Unfortunately, we cannot safely call `sync` or `syncfs`, because if file IO is happening |
| 566 | defer tmp.cleanup(); | 566 | // than the system can commit the results to disk, such calls could block indefinitely. |
| 567 | |||
| 568 | const test_out_file = "os_tmp_test"; | ||
| 569 | const file = try tmp.dir.createFile(test_out_file, .{}); | ||
| 570 | defer file.close(); | ||
| 571 | 567 | ||
| 572 | posix.sync(); | 568 | _ = &posix.sync; |
| 573 | try posix.syncfs(file.handle); | 569 | _ = &posix.syncfs; |
| 574 | } | 570 | } |
| 575 | 571 | ||
| 576 | test "fsync" { | 572 | test "fsync" { |
test/behavior/call.zig+4-4| ... | @@ -320,7 +320,7 @@ test "inline call preserves tail call" { | ... | @@ -320,7 +320,7 @@ test "inline call preserves tail call" { |
| 320 | 320 | ||
| 321 | if (builtin.zig_backend == .stage2_c and builtin.os.tag == .windows) return error.SkipZigTest; // MSVC doesn't support always tail calls | 321 | if (builtin.zig_backend == .stage2_c and builtin.os.tag == .windows) return error.SkipZigTest; // MSVC doesn't support always tail calls |
| 322 | 322 | ||
| 323 | const max = std.math.maxInt(u16); | 323 | const max_depth = 1000; |
| 324 | const S = struct { | 324 | const S = struct { |
| 325 | var a: u16 = 0; | 325 | var a: u16 = 0; |
| 326 | fn foo() void { | 326 | fn foo() void { |
| ... | @@ -328,16 +328,16 @@ test "inline call preserves tail call" { | ... | @@ -328,16 +328,16 @@ test "inline call preserves tail call" { |
| 328 | } | 328 | } |
| 329 | 329 | ||
| 330 | inline fn bar() void { | 330 | inline fn bar() void { |
| 331 | if (a == max) return; | 331 | if (a == max_depth) return; |
| 332 | // Stack overflow if not tail called | 332 | // Stack overflow if not tail called |
| 333 | var buf: [max]u16 = undefined; | 333 | var buf: [100_000]u16 = undefined; |
| 334 | buf[a] = a; | 334 | buf[a] = a; |
| 335 | a += 1; | 335 | a += 1; |
| 336 | return @call(.always_tail, foo, .{}); | 336 | return @call(.always_tail, foo, .{}); |
| 337 | } | 337 | } |
| 338 | }; | 338 | }; |
| 339 | S.foo(); | 339 | S.foo(); |
| 340 | try expect(S.a == std.math.maxInt(u16)); | 340 | try expect(S.a == max_depth); |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | test "inline call doesn't re-evaluate non generic struct" { | 343 | test "inline call doesn't re-evaluate non generic struct" { |