-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fuzzing: add convenience mixin ldc.libfuzzer.DefineTestOneInput. (#2510)
Resolves issue #2501
- Loading branch information
1 parent
df860d0
commit 94f6c0e
Showing
2 changed files
with
25 additions
and
1 deletion.
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
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; |