Skip to content

Commit

Permalink
Fuzzing: add convenience mixin ldc.libfuzzer.DefineTestOneInput. (#2510)
Browse files Browse the repository at this point in the history
Resolves issue #2501
  • Loading branch information
JohanEngelen authored Mar 7, 2018
1 parent df860d0 commit 94f6c0e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion runtime/druntime
Submodule druntime updated 1 files
+78 −0 src/ldc/libfuzzer.di
24 changes: 24 additions & 0 deletions tests/sanitizers/fuzz_mixin.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Test the basic fuzz target mixin for a D-signature fuzz target.

// REQUIRES: atleast_llvm500
// REQUIRES: Fuzzer
// UNSUPPORTED: Windows

// RUN: %ldc -g -fsanitize=fuzzer %s -of=%t%exe
// RUN: not %t%exe 2>&1 | FileCheck %s

int FuzzMe(in ubyte[] data)
{
if ((data.length >= 3) && data[0] == 'F' && data[1] == 'U' && data[2] == 'Z')
{
// Testing this assertion also tests that druntime is initialized.
// CHECK: fuzz_mixin.d([[@LINE+1]]): Assertion failure
assert(false);
// CHECK: ERROR: libFuzzer: deadly signal
}

return 0;
}

import ldc.libfuzzer;
mixin DefineTestOneInput!FuzzMe;

0 comments on commit 94f6c0e

Please sign in to comment.