Skip to content

Commit

Permalink
fix compiler-rt tests accidentally running std tests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
andrewrk committed May 3, 2018
1 parent c186cd1 commit 02c1b9d
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 36 deletions.
10 changes: 8 additions & 2 deletions std/atomic/queue.zig
Expand Up @@ -49,14 +49,20 @@ const Context = struct {
get_count: usize,
puts_done: u8, // TODO make this a bool
};
const puts_per_thread = 10000;

// TODO add lazy evaluated build options and then put puts_per_thread behind
// some option such as: "AggressiveMultithreadedFuzzTest". In the AppVeyor
// CI we would use a less aggressive setting since at 1 core, while we still
// want this test to pass, we need a smaller value since there is so much thrashing
// we would also use a less aggressive setting when running in valgrind
const puts_per_thread = 500;
const put_thread_count = 3;

test "std.atomic.queue" {
var direct_allocator = std.heap.DirectAllocator.init();
defer direct_allocator.deinit();

var plenty_of_memory = try direct_allocator.allocator.alloc(u8, 600 * 1024);
var plenty_of_memory = try direct_allocator.allocator.alloc(u8, 300 * 1024);
defer direct_allocator.allocator.free(plenty_of_memory);

var fixed_buffer_allocator = std.heap.ThreadSafeFixedBufferAllocator.init(plenty_of_memory);
Expand Down
9 changes: 7 additions & 2 deletions std/atomic/stack.zig
Expand Up @@ -56,14 +56,19 @@ const Context = struct {
get_count: usize,
puts_done: u8, // TODO make this a bool
};
const puts_per_thread = 1000;
// TODO add lazy evaluated build options and then put puts_per_thread behind
// some option such as: "AggressiveMultithreadedFuzzTest". In the AppVeyor
// CI we would use a less aggressive setting since at 1 core, while we still
// want this test to pass, we need a smaller value since there is so much thrashing
// we would also use a less aggressive setting when running in valgrind
const puts_per_thread = 500;
const put_thread_count = 3;

test "std.atomic.stack" {
var direct_allocator = std.heap.DirectAllocator.init();
defer direct_allocator.deinit();

var plenty_of_memory = try direct_allocator.allocator.alloc(u8, 600 * 1024);
var plenty_of_memory = try direct_allocator.allocator.alloc(u8, 300 * 1024);
defer direct_allocator.allocator.free(plenty_of_memory);

var fixed_buffer_allocator = std.heap.ThreadSafeFixedBufferAllocator.init(plenty_of_memory);
Expand Down
2 changes: 1 addition & 1 deletion std/special/compiler_rt/fixuint.zig
@@ -1,5 +1,5 @@
const is_test = @import("builtin").is_test;
const Log2Int = @import("../../math/index.zig").Log2Int;
const Log2Int = @import("std").math.Log2Int;

pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t {
@setRuntimeSafety(is_test);
Expand Down
2 changes: 1 addition & 1 deletion std/special/compiler_rt/fixunsdfdi_test.zig
@@ -1,5 +1,5 @@
const __fixunsdfdi = @import("fixunsdfdi.zig").__fixunsdfdi;
const assert = @import("../../index.zig").debug.assert;
const assert = @import("std").debug.assert;

fn test__fixunsdfdi(a: f64, expected: u64) void {
const x = __fixunsdfdi(a);
Expand Down
2 changes: 1 addition & 1 deletion std/special/compiler_rt/fixunsdfsi_test.zig
@@ -1,5 +1,5 @@
const __fixunsdfsi = @import("fixunsdfsi.zig").__fixunsdfsi;
const assert = @import("../../index.zig").debug.assert;
const assert = @import("std").debug.assert;

fn test__fixunsdfsi(a: f64, expected: u32) void {
const x = __fixunsdfsi(a);
Expand Down
2 changes: 1 addition & 1 deletion std/special/compiler_rt/fixunsdfti_test.zig
@@ -1,5 +1,5 @@
const __fixunsdfti = @import("fixunsdfti.zig").__fixunsdfti;
const assert = @import("../../index.zig").debug.assert;
const assert = @import("std").debug.assert;

fn test__fixunsdfti(a: f64, expected: u128) void {
const x = __fixunsdfti(a);
Expand Down
2 changes: 1 addition & 1 deletion std/special/compiler_rt/fixunssfdi_test.zig
@@ -1,5 +1,5 @@
const __fixunssfdi = @import("fixunssfdi.zig").__fixunssfdi;
const assert = @import("../../index.zig").debug.assert;
const assert = @import("std").debug.assert;

fn test__fixunssfdi(a: f32, expected: u64) void {
const x = __fixunssfdi(a);
Expand Down
2 changes: 1 addition & 1 deletion std/special/compiler_rt/fixunssfsi_test.zig
@@ -1,5 +1,5 @@
const __fixunssfsi = @import("fixunssfsi.zig").__fixunssfsi;
const assert = @import("../../index.zig").debug.assert;
const assert = @import("std").debug.assert;

fn test__fixunssfsi(a: f32, expected: u32) void {
const x = __fixunssfsi(a);
Expand Down
2 changes: 1 addition & 1 deletion std/special/compiler_rt/fixunssfti_test.zig
@@ -1,5 +1,5 @@
const __fixunssfti = @import("fixunssfti.zig").__fixunssfti;
const assert = @import("../../index.zig").debug.assert;
const assert = @import("std").debug.assert;

fn test__fixunssfti(a: f32, expected: u128) void {
const x = __fixunssfti(a);
Expand Down
2 changes: 1 addition & 1 deletion std/special/compiler_rt/fixunstfdi_test.zig
@@ -1,5 +1,5 @@
const __fixunstfdi = @import("fixunstfdi.zig").__fixunstfdi;
const assert = @import("../../index.zig").debug.assert;
const assert = @import("std").debug.assert;

fn test__fixunstfdi(a: f128, expected: u64) void {
const x = __fixunstfdi(a);
Expand Down
2 changes: 1 addition & 1 deletion std/special/compiler_rt/fixunstfsi_test.zig
@@ -1,5 +1,5 @@
const __fixunstfsi = @import("fixunstfsi.zig").__fixunstfsi;
const assert = @import("../../index.zig").debug.assert;
const assert = @import("std").debug.assert;

fn test__fixunstfsi(a: f128, expected: u32) void {
const x = __fixunstfsi(a);
Expand Down
2 changes: 1 addition & 1 deletion std/special/compiler_rt/fixunstfti_test.zig
@@ -1,5 +1,5 @@
const __fixunstfti = @import("fixunstfti.zig").__fixunstfti;
const assert = @import("../../index.zig").debug.assert;
const assert = @import("std").debug.assert;

fn test__fixunstfti(a: f128, expected: u128) void {
const x = __fixunstfti(a);
Expand Down
5 changes: 3 additions & 2 deletions std/special/compiler_rt/index.zig
Expand Up @@ -71,7 +71,8 @@ comptime {
}
}

const assert = @import("../../index.zig").debug.assert;
const std = @import("std");
const assert = std.debug.assert;

const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4;

Expand All @@ -80,7 +81,7 @@ const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4;
pub fn panic(msg: []const u8, error_return_trace: ?&builtin.StackTrace) noreturn {
@setCold(true);
if (is_test) {
@import("std").debug.panic("{}", msg);
std.debug.panic("{}", msg);
} else {
unreachable;
}
Expand Down
2 changes: 1 addition & 1 deletion std/special/compiler_rt/udivmod.zig
Expand Up @@ -9,7 +9,7 @@ pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem:

const SingleInt = @IntType(false, @divExact(DoubleInt.bit_count, 2));
const SignedDoubleInt = @IntType(true, DoubleInt.bit_count);
const Log2SingleInt = @import("../../math/index.zig").Log2Int(SingleInt);
const Log2SingleInt = @import("std").math.Log2Int(SingleInt);

const n = *@ptrCast(&const [2]SingleInt, &a); // TODO issue #421
const d = *@ptrCast(&const [2]SingleInt, &b); // TODO issue #421
Expand Down
46 changes: 27 additions & 19 deletions std/zig/parser_test.zig
@@ -1,3 +1,30 @@
// TODO
//if (sr > n_uword_bits - 1) // d > r
// return 0;

// TODO switch with no body
// format(&size, error{}, countSize, fmt, args) catch |err| switch (err) {};


//TODO
//test "zig fmt: same-line comptime" {
// try testCanonical(
// \\test "" {
// \\ comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer to absInt
// \\}
// \\
// );
//}


//TODO
//test "zig fmt: number literals" {
// try testCanonical(
// \\pub const f64_true_min = 4.94065645841246544177e-324;
// \\
// );
//}

test "zig fmt: line comments in struct initializer" {
try testCanonical(
\\fn foo() void {
Expand All @@ -20,25 +47,6 @@ test "zig fmt: line comments in struct initializer" {
);
}

//TODO
//test "zig fmt: same-line comptime" {
// try testCanonical(
// \\test "" {
// \\ comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer to absInt
// \\}
// \\
// );
//}


//TODO
//test "zig fmt: number literals" {
// try testCanonical(
// \\pub const f64_true_min = 4.94065645841246544177e-324;
// \\
// );
//}

test "zig fmt: doc comments before struct field" {
try testCanonical(
\\pub const Allocator = struct {
Expand Down

0 comments on commit 02c1b9d

Please sign in to comment.