dns fuzz targets: smith corpus, llvm-backed fuzz artifact
This commit is contained in:
@@ -18,6 +18,7 @@ pub fn build(b: *std.Build) void {
|
||||
|
||||
const integration = b.option(bool, "integration", "Run hermetic integration tests (loopback sockets only)") orelse false;
|
||||
const live = b.option(bool, "live", "Run tests that reach external network hosts") orelse false;
|
||||
const fuzz = b.option(bool, "fuzz", "Build the fuzz targets with the LLVM backend (required for --fuzz)") orelse false;
|
||||
const version_string = b.option([]const u8, "version-string", "Version reported by `nxdns version`") orelse "0.1.0-dev";
|
||||
const git_commit = b.option([]const u8, "git-commit", "Git commit reported by `nxdns version`") orelse "unknown";
|
||||
|
||||
@@ -52,7 +53,31 @@ pub fn build(b: *std.Build) void {
|
||||
tests.root_module.addAnonymousImport("test_fixtures", .{
|
||||
.root_source_file = b.path("tests/fixtures/fixtures.zig"),
|
||||
});
|
||||
b.step("test", "Run the test suite").dependOn(&b.addRunArtifact(tests).step);
|
||||
const test_step = b.step("test", "Run the test suite");
|
||||
test_step.dependOn(&b.addRunArtifact(tests).step);
|
||||
|
||||
// Fuzz targets compile as a second test artifact with `dns` as a named module
|
||||
// (a file belongs to one module per compilation; the aggregator keeps owning
|
||||
// the in-file tests). `-Dfuzz` opts into the LLVM backend, which `--fuzz`
|
||||
// needs for sanitizer coverage; stock 0.16.0 also requires a patched
|
||||
// test_runner.zig for fuzz mode — see specs/milestone-2.md.
|
||||
const dns_mod = b.createModule(.{
|
||||
.root_source_file = b.path("src/dns/dns.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const fuzz_mod = b.createModule(.{
|
||||
.root_source_file = b.path("tests/fuzz/dns_fuzz.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
fuzz_mod.addImport("dns", dns_mod);
|
||||
const fuzz_tests = b.addTest(.{
|
||||
.name = "fuzz",
|
||||
.use_llvm = if (fuzz) true else null,
|
||||
.root_module = fuzz_mod,
|
||||
});
|
||||
test_step.dependOn(&b.addRunArtifact(fuzz_tests).step);
|
||||
|
||||
const cross = b.step("cross", "Build static musl executables for every deploy target");
|
||||
for (cross_targets) |triple| {
|
||||
|
||||
Reference in New Issue
Block a user