authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-05-02 21:34:34-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-05-02 21:34:34-04:00
log02c1b9df3bcf2e0324adf02fd6c0ed56fe58c6d3
treeea5605110789b468d204b6c44c9d393c1855d61d
parentc186cd187e9b75ee1514a5f3371abeffb36d871a

fix compiler-rt tests accidentally running std tests

also reduce the aggressiveness of std.atomic.stack and std.atomic.queue fuzz testing. appveyor has 1 core and 10,000 iterations is too much for 6 threads to thrash over

15 files changed, 56 insertions(+), 36 deletions(-)

std/atomic/queue.zig+8-2
...@@ -49,14 +49,20 @@ const Context = struct {...@@ -49,14 +49,20 @@ const Context = struct {
49 get_count: usize,49 get_count: usize,
50 puts_done: u8, // TODO make this a bool50 puts_done: u8, // TODO make this a bool
51};51};
52const puts_per_thread = 10000;52
53// TODO add lazy evaluated build options and then put puts_per_thread behind
54// some option such as: "AggressiveMultithreadedFuzzTest". In the AppVeyor
55// CI we would use a less aggressive setting since at 1 core, while we still
56// want this test to pass, we need a smaller value since there is so much thrashing
57// we would also use a less aggressive setting when running in valgrind
58const puts_per_thread = 500;
53const put_thread_count = 3;59const put_thread_count = 3;
5460
55test "std.atomic.queue" {61test "std.atomic.queue" {
56 var direct_allocator = std.heap.DirectAllocator.init();62 var direct_allocator = std.heap.DirectAllocator.init();
57 defer direct_allocator.deinit();63 defer direct_allocator.deinit();
5864
59 var plenty_of_memory = try direct_allocator.allocator.alloc(u8, 600 * 1024);65 var plenty_of_memory = try direct_allocator.allocator.alloc(u8, 300 * 1024);
60 defer direct_allocator.allocator.free(plenty_of_memory);66 defer direct_allocator.allocator.free(plenty_of_memory);
6167
62 var fixed_buffer_allocator = std.heap.ThreadSafeFixedBufferAllocator.init(plenty_of_memory);68 var fixed_buffer_allocator = std.heap.ThreadSafeFixedBufferAllocator.init(plenty_of_memory);
std/atomic/stack.zig+7-2
...@@ -56,14 +56,19 @@ const Context = struct {...@@ -56,14 +56,19 @@ const Context = struct {
56 get_count: usize,56 get_count: usize,
57 puts_done: u8, // TODO make this a bool57 puts_done: u8, // TODO make this a bool
58};58};
59const puts_per_thread = 1000;59// TODO add lazy evaluated build options and then put puts_per_thread behind
60// some option such as: "AggressiveMultithreadedFuzzTest". In the AppVeyor
61// CI we would use a less aggressive setting since at 1 core, while we still
62// want this test to pass, we need a smaller value since there is so much thrashing
63// we would also use a less aggressive setting when running in valgrind
64const puts_per_thread = 500;
60const put_thread_count = 3;65const put_thread_count = 3;
6166
62test "std.atomic.stack" {67test "std.atomic.stack" {
63 var direct_allocator = std.heap.DirectAllocator.init();68 var direct_allocator = std.heap.DirectAllocator.init();
64 defer direct_allocator.deinit();69 defer direct_allocator.deinit();
6570
66 var plenty_of_memory = try direct_allocator.allocator.alloc(u8, 600 * 1024);71 var plenty_of_memory = try direct_allocator.allocator.alloc(u8, 300 * 1024);
67 defer direct_allocator.allocator.free(plenty_of_memory);72 defer direct_allocator.allocator.free(plenty_of_memory);
6873
69 var fixed_buffer_allocator = std.heap.ThreadSafeFixedBufferAllocator.init(plenty_of_memory);74 var fixed_buffer_allocator = std.heap.ThreadSafeFixedBufferAllocator.init(plenty_of_memory);
std/special/compiler_rt/fixuint.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const is_test = @import("builtin").is_test;1const is_test = @import("builtin").is_test;
2const Log2Int = @import("../../math/index.zig").Log2Int;2const Log2Int = @import("std").math.Log2Int;
33
4pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t {4pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t {
5 @setRuntimeSafety(is_test);5 @setRuntimeSafety(is_test);
std/special/compiler_rt/fixunsdfdi_test.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const __fixunsdfdi = @import("fixunsdfdi.zig").__fixunsdfdi;1const __fixunsdfdi = @import("fixunsdfdi.zig").__fixunsdfdi;
2const assert = @import("../../index.zig").debug.assert;2const assert = @import("std").debug.assert;
33
4fn test__fixunsdfdi(a: f64, expected: u64) void {4fn test__fixunsdfdi(a: f64, expected: u64) void {
5 const x = __fixunsdfdi(a);5 const x = __fixunsdfdi(a);
std/special/compiler_rt/fixunsdfsi_test.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const __fixunsdfsi = @import("fixunsdfsi.zig").__fixunsdfsi;1const __fixunsdfsi = @import("fixunsdfsi.zig").__fixunsdfsi;
2const assert = @import("../../index.zig").debug.assert;2const assert = @import("std").debug.assert;
33
4fn test__fixunsdfsi(a: f64, expected: u32) void {4fn test__fixunsdfsi(a: f64, expected: u32) void {
5 const x = __fixunsdfsi(a);5 const x = __fixunsdfsi(a);
std/special/compiler_rt/fixunsdfti_test.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const __fixunsdfti = @import("fixunsdfti.zig").__fixunsdfti;1const __fixunsdfti = @import("fixunsdfti.zig").__fixunsdfti;
2const assert = @import("../../index.zig").debug.assert;2const assert = @import("std").debug.assert;
33
4fn test__fixunsdfti(a: f64, expected: u128) void {4fn test__fixunsdfti(a: f64, expected: u128) void {
5 const x = __fixunsdfti(a);5 const x = __fixunsdfti(a);
std/special/compiler_rt/fixunssfdi_test.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const __fixunssfdi = @import("fixunssfdi.zig").__fixunssfdi;1const __fixunssfdi = @import("fixunssfdi.zig").__fixunssfdi;
2const assert = @import("../../index.zig").debug.assert;2const assert = @import("std").debug.assert;
33
4fn test__fixunssfdi(a: f32, expected: u64) void {4fn test__fixunssfdi(a: f32, expected: u64) void {
5 const x = __fixunssfdi(a);5 const x = __fixunssfdi(a);
std/special/compiler_rt/fixunssfsi_test.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const __fixunssfsi = @import("fixunssfsi.zig").__fixunssfsi;1const __fixunssfsi = @import("fixunssfsi.zig").__fixunssfsi;
2const assert = @import("../../index.zig").debug.assert;2const assert = @import("std").debug.assert;
33
4fn test__fixunssfsi(a: f32, expected: u32) void {4fn test__fixunssfsi(a: f32, expected: u32) void {
5 const x = __fixunssfsi(a);5 const x = __fixunssfsi(a);
std/special/compiler_rt/fixunssfti_test.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const __fixunssfti = @import("fixunssfti.zig").__fixunssfti;1const __fixunssfti = @import("fixunssfti.zig").__fixunssfti;
2const assert = @import("../../index.zig").debug.assert;2const assert = @import("std").debug.assert;
33
4fn test__fixunssfti(a: f32, expected: u128) void {4fn test__fixunssfti(a: f32, expected: u128) void {
5 const x = __fixunssfti(a);5 const x = __fixunssfti(a);
std/special/compiler_rt/fixunstfdi_test.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const __fixunstfdi = @import("fixunstfdi.zig").__fixunstfdi;1const __fixunstfdi = @import("fixunstfdi.zig").__fixunstfdi;
2const assert = @import("../../index.zig").debug.assert;2const assert = @import("std").debug.assert;
33
4fn test__fixunstfdi(a: f128, expected: u64) void {4fn test__fixunstfdi(a: f128, expected: u64) void {
5 const x = __fixunstfdi(a);5 const x = __fixunstfdi(a);
std/special/compiler_rt/fixunstfsi_test.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const __fixunstfsi = @import("fixunstfsi.zig").__fixunstfsi;1const __fixunstfsi = @import("fixunstfsi.zig").__fixunstfsi;
2const assert = @import("../../index.zig").debug.assert;2const assert = @import("std").debug.assert;
33
4fn test__fixunstfsi(a: f128, expected: u32) void {4fn test__fixunstfsi(a: f128, expected: u32) void {
5 const x = __fixunstfsi(a);5 const x = __fixunstfsi(a);
std/special/compiler_rt/fixunstfti_test.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const __fixunstfti = @import("fixunstfti.zig").__fixunstfti;1const __fixunstfti = @import("fixunstfti.zig").__fixunstfti;
2const assert = @import("../../index.zig").debug.assert;2const assert = @import("std").debug.assert;
33
4fn test__fixunstfti(a: f128, expected: u128) void {4fn test__fixunstfti(a: f128, expected: u128) void {
5 const x = __fixunstfti(a);5 const x = __fixunstfti(a);
std/special/compiler_rt/index.zig+3-2
...@@ -71,7 +71,8 @@ comptime {...@@ -71,7 +71,8 @@ comptime {
71 }71 }
72}72}
7373
74const assert = @import("../../index.zig").debug.assert;74const std = @import("std");
75const assert = std.debug.assert;
7576
76const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4;77const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4;
7778
...@@ -80,7 +81,7 @@ const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4;...@@ -80,7 +81,7 @@ const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4;
80pub fn panic(msg: []const u8, error_return_trace: ?&builtin.StackTrace) noreturn {81pub fn panic(msg: []const u8, error_return_trace: ?&builtin.StackTrace) noreturn {
81 @setCold(true);82 @setCold(true);
82 if (is_test) {83 if (is_test) {
83 @import("std").debug.panic("{}", msg);84 std.debug.panic("{}", msg);
84 } else {85 } else {
85 unreachable;86 unreachable;
86 }87 }
std/special/compiler_rt/udivmod.zig+1-1
...@@ -9,7 +9,7 @@ pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem:...@@ -9,7 +9,7 @@ pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem:
99
10 const SingleInt = @IntType(false, @divExact(DoubleInt.bit_count, 2));10 const SingleInt = @IntType(false, @divExact(DoubleInt.bit_count, 2));
11 const SignedDoubleInt = @IntType(true, DoubleInt.bit_count);11 const SignedDoubleInt = @IntType(true, DoubleInt.bit_count);
12 const Log2SingleInt = @import("../../math/index.zig").Log2Int(SingleInt);12 const Log2SingleInt = @import("std").math.Log2Int(SingleInt);
1313
14 const n = *@ptrCast(&const [2]SingleInt, &a); // TODO issue #42114 const n = *@ptrCast(&const [2]SingleInt, &a); // TODO issue #421
15 const d = *@ptrCast(&const [2]SingleInt, &b); // TODO issue #42115 const d = *@ptrCast(&const [2]SingleInt, &b); // TODO issue #421
std/zig/parser_test.zig+27-19
...@@ -1,3 +1,30 @@...@@ -1,3 +1,30 @@
1// TODO
2//if (sr > n_uword_bits - 1) // d > r
3// return 0;
4
5// TODO switch with no body
6// format(&size, error{}, countSize, fmt, args) catch |err| switch (err) {};
7
8
9//TODO
10//test "zig fmt: same-line comptime" {
11// try testCanonical(
12// \\test "" {
13// \\ comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer to absInt
14// \\}
15// \\
16// );
17//}
18
19
20//TODO
21//test "zig fmt: number literals" {
22// try testCanonical(
23// \\pub const f64_true_min = 4.94065645841246544177e-324;
24// \\
25// );
26//}
27
1test "zig fmt: line comments in struct initializer" {28test "zig fmt: line comments in struct initializer" {
2 try testCanonical(29 try testCanonical(
3 \\fn foo() void {30 \\fn foo() void {
...@@ -20,25 +47,6 @@ test "zig fmt: line comments in struct initializer" {...@@ -20,25 +47,6 @@ test "zig fmt: line comments in struct initializer" {
20 );47 );
21}48}
2249
23//TODO
24//test "zig fmt: same-line comptime" {
25// try testCanonical(
26// \\test "" {
27// \\ comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer to absInt
28// \\}
29// \\
30// );
31//}
32
33
34//TODO
35//test "zig fmt: number literals" {
36// try testCanonical(
37// \\pub const f64_true_min = 4.94065645841246544177e-324;
38// \\
39// );
40//}
41
42test "zig fmt: doc comments before struct field" {50test "zig fmt: doc comments before struct field" {
43 try testCanonical(51 try testCanonical(
44 \\pub const Allocator = struct {52 \\pub const Allocator = struct {