-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Test that all files in test/testsuite-generated do not crash - This is regardless of if they're supported in zware or not - Also includes fuzzed files
- Loading branch information
1 parent
224d620
commit 73358bc
Showing
5 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const Builder = @import("std").build.Builder; | ||
|
||
pub fn build(b: *Builder) void { | ||
// Standard target options allows the person running `zig build` to choose | ||
// what target to build for. Here we do not override the defaults, which | ||
// means any target is allowed, and the default is native. Other options | ||
// for restricting supported target set are available. | ||
const target = b.standardTargetOptions(.{}); | ||
|
||
// Standard release options allow the person running `zig build` to select | ||
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. | ||
const mode = b.standardReleaseOptions(); | ||
|
||
const exe = b.addExecutable("parsecheck", "src/parsecheck.zig"); | ||
exe.setTarget(target); | ||
exe.setBuildMode(mode); | ||
exe.addPackagePath("zware", "../../src/main.zig"); | ||
exe.install(); | ||
|
||
const run_cmd = exe.run(); | ||
run_cmd.step.dependOn(b.getInstallStep()); | ||
if (b.args) |args| { | ||
run_cmd.addArgs(args); | ||
} | ||
|
||
const run_step = b.step("run", "Run the app"); | ||
run_step.dependOn(&run_cmd.step); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const std = @import("std"); | ||
const mem = std.mem; | ||
const fs = std.fs; | ||
const fmt = std.fmt; | ||
const process = std.process; | ||
const zware = @import("zware"); | ||
const ArrayList = std.ArrayList; | ||
const Module = zware.Module; | ||
const Store = zware.Store; | ||
const Instance = zware.Instance; | ||
const GeneralPurposeAllocator = std.heap.GeneralPurposeAllocator; | ||
const ArenaAllocator = std.heap.ArenaAllocator; | ||
var gpa = GeneralPurposeAllocator(.{}){}; | ||
|
||
pub fn main() !void { | ||
var args = process.args(); | ||
_ = args.skip(); | ||
const directory = args.next() orelse return error.NoFilename; | ||
|
||
defer _ = gpa.deinit(); | ||
|
||
var wasm_files = ArrayList([]const u8).init(gpa.allocator()); | ||
defer wasm_files.deinit(); | ||
|
||
var dir = try std.fs.cwd().openIterableDir(directory, .{}); | ||
defer dir.close(); | ||
|
||
var it = dir.iterate(); | ||
|
||
var file_count: usize = 0; | ||
while (try it.next()) |entry| { | ||
if (entry.kind == .File) file_count += 1; | ||
if (mem.endsWith(u8, entry.name, ".wasm")) { | ||
std.log.info("{s}", .{entry.name}); | ||
var arena = ArenaAllocator.init(gpa.allocator()); | ||
defer _ = arena.deinit(); | ||
const alloc = arena.allocator(); | ||
|
||
const program = try dir.dir.readFileAlloc(alloc, entry.name, 0xFFFFFFF); | ||
if (program.len == 0) continue; | ||
|
||
var store: Store = Store.init(alloc); | ||
|
||
var module = Module.init(alloc, program); | ||
module.decode() catch continue; | ||
|
||
var new_inst = Instance.init(alloc, &store, module); | ||
const index = store.addInstance(new_inst) catch continue; | ||
var inst = store.instance(index) catch continue; | ||
inst.instantiate(index) catch continue; | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.