new way to specify which test
This commit is contained in:
parent
121a748f7e
commit
656ffa1b6d
@ -99,10 +99,6 @@ directory shows how this can be done. The libFuzzer executable works
|
||||
like any other libFuzzer executable, and the tests produced can be run
|
||||
using the normal DeepState executable.
|
||||
|
||||
Because libFuzzer controls `main`, you need a different executable for
|
||||
each test when using libFuzzer, which can be done as shown in the compilation for the
|
||||
`IntegerOverflow` example.
|
||||
|
||||
## Fuzzing with AFL
|
||||
|
||||
DeepState can also be used with a file-based fuzzer (e.g. AFL). There
|
||||
|
||||
@ -71,12 +71,6 @@ if (BUILD_LIBFUZZER)
|
||||
target_link_libraries(IntegerOverflow_LF deepstate_LF)
|
||||
target_link_libraries (IntegerOverflow_LF "-fsanitize=fuzzer")
|
||||
set_target_properties(IntegerOverflow_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
|
||||
|
||||
add_executable(IntegerOverflow_Addition_LF IntegerOverflow.cpp)
|
||||
target_link_libraries(IntegerOverflow_Addition_LF deepstate_LF)
|
||||
target_link_libraries (IntegerOverflow_Addition_LF "-fsanitize=fuzzer")
|
||||
set_target_properties(IntegerOverflow_Addition_LF PROPERTIES COMPILE_DEFINITIONS
|
||||
"LIBFUZZER;LIBFUZZER_WHICH_TEST=\"SignedInteger_AdditionOverflow\"")
|
||||
endif()
|
||||
|
||||
add_executable(IntegerArithmetic IntegerArithmetic.cpp)
|
||||
|
||||
@ -558,15 +558,17 @@ extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
void *mem = malloc(sizeof(struct DeepState_TestRunInfo));
|
||||
DeepState_CurrentTestRun = (struct DeepState_TestRunInfo *) mem;
|
||||
|
||||
#ifdef LIBFUZZER_WHICH_TEST
|
||||
for (test = DeepState_FirstTest(); test != NULL; test = test->prev) {
|
||||
if (strncmp(LIBFUZZER_WHICH_TEST, test->test_name, strlen(FLAGS_input_which_test)) == 0) {
|
||||
break;
|
||||
const char* which_test = getenv("LIBFUZZER_WHICH_TEST");
|
||||
if (!(strnlen(which_test, 1024) == 0)) {
|
||||
for (test = DeepState_FirstTest(); test != NULL; test = test->prev) {
|
||||
if (strncmp(which_test, test->test_name, strnlen(which_test, 1024)) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
test = DeepState_FirstTest();
|
||||
}
|
||||
#else
|
||||
test = DeepState_FirstTest();
|
||||
#endif
|
||||
|
||||
|
||||
memset((void *) DeepState_Input, 0, sizeof(DeepState_Input));
|
||||
DeepState_InputIndex = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user