How to trigger the fuzzer loop?

Hello,

I’m trying to wrap my head around how to use the fuzzer.
My sadness is that I can’t get the fuzz loop to run over my build - either on linux or macos, with 0.14.

The tests just run once and exits with a success - no fuzz loop.
Full repro at src/fuzz_stateful.zig.

Here’s a simplified version:

fn runStatefulTest(_: void, input: []const u8) !void {
    // allocate a copy of the data that we can use
    // Initialize PRNG with the fuzzer data
    var prng = FinitePrng.init(fuzz_data);
    var random = prng.random();
    const commands = [_]state.Command(Model, System){ }; // list of  commands here

    // Initialize model and system
    var model = Model{};
    var sut = System{};

    var cmd_seq = state.CommandSequence(Model, System).init(...); // Create command sequence

    // Run the stateful test
    const result = state.assertStateful(Model, System, &cmd_seq, &model, &sut, .{ .verbose = false });

    try std.testing.expect(result == null);
}

// Add a fuzz test that will be picked up by the build system
test "fuzz stateful testing" {
    try std.testing.fuzz({}, runStatefulTest, .{});
}

Based on the online demos I’ve seen, my expectation was: zig build test --fuzz triggers the fuzzer to keep calling the test function, until it returns an error. Yet, I don’t see any loop running - the test just succeeds and exits immediately.

Could it be that the issue is in my build.zig, or am I grossly mishandling the API here?

The fuzzer released with 0.14.0 does not work with MacOS and I don’t believe any version does at the moment.

As for the reason your example doesn’t work I’m going to keep looking into that. I haven’t used the fuzzer yet but this question inspired me to take a look lol.

I found the issue:

The fuzz tests don’t run if they come after a failure in the test suite :man_facepalming:

2 Likes