From baef5b6c09d3f4ef9ca86ce1e432ff78e2d41116 Mon Sep 17 00:00:00 2001 From: Evan Haas Date: Thu, 2 May 2024 23:37:55 -0700 Subject: [PATCH] Fuzz lib: Ignore out of memory errors, and allow up to 20 megs for tests --- test/fuzz/fuzz_lib.zig | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/fuzz/fuzz_lib.zig b/test/fuzz/fuzz_lib.zig index fdd0985a..730a1881 100644 --- a/test/fuzz/fuzz_lib.zig +++ b/test/fuzz/fuzz_lib.zig @@ -9,10 +9,15 @@ const Source = aro.Source; const Preprocessor = aro.Preprocessor; const Parser = aro.Parser; -var fixed_buffer_mem: [10 * 1024 * 1024]u8 = undefined; +var fixed_buffer_mem: [20 * 1024 * 1024]u8 = undefined; export fn compile_c_buf(buf: [*]const u8, len: c_int) void { - compileSlice(buf[0..@intCast(len)]) catch unreachable; + compileSlice(buf[0..@intCast(len)]) catch |e| switch (e) { + error.FatalError, + error.OutOfMemory, + => {}, + else => unreachable, + }; } fn compileSlice(buf: []const u8) !void { @@ -31,10 +36,7 @@ fn compileSlice(buf: []const u8) !void { const builtin = try comp.generateBuiltinMacros(.include_system_defines); const user_source = try comp.addSourceFromBuffer("", buf); - processSource(&comp, builtin, user_source) catch |e| switch (e) { - error.FatalError => {}, - else => |err| return err, - }; + try processSource(&comp, builtin, user_source); _ = comp.sources.swapRemove(user_source.path); }