exit on fail now supported
This commit is contained in:
parent
8ced662872
commit
84f317da06
@ -227,7 +227,7 @@ deepstate-angr ./Runlen
|
||||
or
|
||||
|
||||
```shell
|
||||
./Runlen --fuzz --abort_on_fail
|
||||
./Runlen --fuzz --exit_on_fail
|
||||
```
|
||||
|
||||
The fuzzer will output something like:
|
||||
|
||||
@ -68,6 +68,7 @@ DECLARE_string(output_test_dir);
|
||||
|
||||
DECLARE_bool(take_over);
|
||||
DECLARE_bool(abort_on_fail);
|
||||
DECLARE_bool(exit_on_fail);
|
||||
DECLARE_bool(verbose_reads);
|
||||
DECLARE_bool(fuzz);
|
||||
DECLARE_bool(fuzz_save_passing);
|
||||
@ -747,6 +748,9 @@ static int DeepState_RunSingleSavedTestCase(void) {
|
||||
if (FLAGS_abort_on_fail) {
|
||||
assert(0); // Terminate in a way AFL/etc. can see as a crash
|
||||
}
|
||||
if (FLAGS_exit_on_fail) {
|
||||
exit(255); // Terminate the testing
|
||||
}
|
||||
num_failed_tests++;
|
||||
}
|
||||
|
||||
@ -820,6 +824,9 @@ static int DeepState_RunSingleSavedTestDir(void) {
|
||||
if (FLAGS_abort_on_fail) {
|
||||
assert(0); // Terminate in a way AFL/etc. can see as a crash
|
||||
}
|
||||
if (FLAGS_exit_on_fail) {
|
||||
exit(255); // Terminate the testing
|
||||
}
|
||||
|
||||
num_failed_tests++;
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ DEFINE_string(output_test_dir, "", "Directory where tests will be saved.");
|
||||
|
||||
DEFINE_bool(take_over, false, "Replay test cases in take-over mode.");
|
||||
DEFINE_bool(abort_on_fail, false, "Abort on file replay failure (useful in file fuzzing).");
|
||||
DEFINE_bool(exit_on_fail, false, "Exit with status 255 on test failure.");
|
||||
DEFINE_bool(verbose_reads, false, "Report on bytes being read during execution of test.");
|
||||
DEFINE_bool(fuzz, false, "Perform brute force unguided fuzzing.");
|
||||
DEFINE_bool(fuzz_save_passing, false, "Save passing tests during fuzzing.");
|
||||
@ -833,7 +834,12 @@ enum DeepState_TestRunResult DeepState_FuzzOneTestCase(struct DeepState_TestInfo
|
||||
if (FLAGS_abort_on_fail && ((result == DeepState_TestRunCrash) ||
|
||||
(result == DeepState_TestRunFail))) {
|
||||
assert(0); // Terminate the testing in a way AFL/etc. can see as a crash
|
||||
}
|
||||
}
|
||||
|
||||
if (FLAGS_exit_on_fail && ((result == DeepState_TestRunCrash) ||
|
||||
(result == DeepState_TestRunFail))) {
|
||||
exit(255); // Terminate the testing
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -885,6 +891,13 @@ extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
}
|
||||
}
|
||||
|
||||
const char* exit_check = getenv("LIBFUZZER_EXIT_ON_FAIL");
|
||||
if (exit_check != NULL) {
|
||||
if ((result == DeepState_TestRunFail) || (result == DeepState_TestRunCrash)) {
|
||||
exit(255); // Terminate the testing
|
||||
}
|
||||
}
|
||||
|
||||
DeepState_Teardown();
|
||||
DeepState_CurrentTestRun = NULL;
|
||||
free(mem);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user