diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-02-10 00:26:33 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-02-10 00:26:33 -0500 |
| commit | cdc5070f216a924d24588b8d0fe06400e036e6bf (patch) | |
| tree | c1943e1831725e41810ea4db4eb1785a130e18e1 /lib/std/special | |
| parent | 9e5b2489913f72764ded2089bccd7e612a3cc347 (diff) | |
| parent | 014f66e6de4aaf81f32c796b12f981326a479397 (diff) | |
| download | zig-cdc5070f216a924d24588b8d0fe06400e036e6bf.tar.gz zig-cdc5070f216a924d24588b8d0fe06400e036e6bf.zip | |
Merge remote-tracking branch 'origin/master' into llvm10
Diffstat (limited to 'lib/std/special')
| -rw-r--r-- | lib/std/special/compiler_rt/clzsi2.zig | 3 | ||||
| -rw-r--r-- | lib/std/special/test_runner.zig | 26 |
2 files changed, 27 insertions, 2 deletions
diff --git a/lib/std/special/compiler_rt/clzsi2.zig b/lib/std/special/compiler_rt/clzsi2.zig index 6a69ae75f1..0c9c5d4318 100644 --- a/lib/std/special/compiler_rt/clzsi2.zig +++ b/lib/std/special/compiler_rt/clzsi2.zig @@ -45,8 +45,9 @@ fn __clzsi2_thumb1() callconv(.Naked) void { \\ subs r0, r1, r0 \\ bx lr \\ .p2align 2 + \\ // Number of bits set in the 0-15 range \\ LUT: - \\ .byte 4,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0 + \\ .byte 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 ); unreachable; diff --git a/lib/std/special/test_runner.zig b/lib/std/special/test_runner.zig index 07c46ee43c..6dd208e3b4 100644 --- a/lib/std/special/test_runner.zig +++ b/lib/std/special/test_runner.zig @@ -2,6 +2,8 @@ const std = @import("std"); const io = std.io; const builtin = @import("builtin"); +pub const io_mode: io.Mode = builtin.test_io_mode; + pub fn main() anyerror!void { const test_fn_list = builtin.test_functions; var ok_count: usize = 0; @@ -12,6 +14,11 @@ pub fn main() anyerror!void { error.TimerUnsupported => @panic("timer unsupported"), }; + var async_frame_buffer: []align(std.Target.stack_align) u8 = undefined; + // TODO this is on the next line (using `undefined` above) because otherwise zig incorrectly + // ignores the alignment of the slice. + async_frame_buffer = &[_]u8{}; + for (test_fn_list) |test_fn, i| { std.testing.base_allocator_instance.reset(); @@ -21,7 +28,24 @@ pub fn main() anyerror!void { if (progress.terminal == null) { std.debug.warn("{}/{} {}...", .{ i + 1, test_fn_list.len, test_fn.name }); } - if (test_fn.func()) |_| { + const result = if (test_fn.async_frame_size) |size| switch (io_mode) { + .evented => blk: { + if (async_frame_buffer.len < size) { + std.heap.page_allocator.free(async_frame_buffer); + async_frame_buffer = try std.heap.page_allocator.alignedAlloc(u8, std.Target.stack_align, size); + } + const casted_fn = @ptrCast(async fn () anyerror!void, test_fn.func); + break :blk await @asyncCall(async_frame_buffer, {}, casted_fn); + }, + .blocking => { + skip_count += 1; + test_node.end(); + progress.log("{}...SKIP (async test)\n", .{test_fn.name}); + if (progress.terminal == null) std.debug.warn("SKIP (async test)\n", .{}); + continue; + }, + } else test_fn.func(); + if (result) |_| { ok_count += 1; test_node.end(); std.testing.allocator_instance.validate() catch |err| switch (err) { |
