hard crash
This commit is contained in:
parent
68419e12e9
commit
81777f1e2d
@ -247,6 +247,12 @@ DEEPSTATE_INLINE static void DeepState_Assert(int expr) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Used to make DeepState really crash for fuzzers, on any platform. */
|
||||
DEEPSTATE_INLINE static void DeepState_HardCrash() {
|
||||
char *p = 0;
|
||||
(*p) = 0;
|
||||
}
|
||||
|
||||
/* Asserts that `expr` must hold. If it does not, then the test fails, but
|
||||
* nonetheless continues on. */
|
||||
DEEPSTATE_INLINE static void DeepState_Check(int expr) {
|
||||
@ -578,6 +584,9 @@ static int DeepState_RunTestNoFork(struct DeepState_TestInfo *test) {
|
||||
if (HAS_FLAG_output_test_dir) {
|
||||
DeepState_SaveFailingTest();
|
||||
}
|
||||
if (HAS_FLAG_abort_on_fail) {
|
||||
DeepState_HardCrash();
|
||||
}
|
||||
return(DeepState_TestRunFail);
|
||||
|
||||
/* The test was abandoned. We may have gotten soft failures before
|
||||
@ -753,7 +762,7 @@ static int DeepState_RunSingleSavedTestCase(void) {
|
||||
|
||||
if ((result == DeepState_TestRunFail) || (result == DeepState_TestRunCrash)) {
|
||||
if (FLAGS_abort_on_fail) {
|
||||
assert(0); // Terminate in a way AFL/etc. can see as a crash
|
||||
DeepState_HardCrash();
|
||||
}
|
||||
if (FLAGS_exit_on_fail) {
|
||||
exit(255); // Terminate the testing
|
||||
@ -829,7 +838,7 @@ static int DeepState_RunSingleSavedTestDir(void) {
|
||||
|
||||
if ((result == DeepState_TestRunFail) || (result == DeepState_TestRunCrash)) {
|
||||
if (FLAGS_abort_on_fail) {
|
||||
assert(0); // Terminate in a way AFL/etc. can see as a crash
|
||||
DeepState_HardCrash();
|
||||
}
|
||||
if (FLAGS_exit_on_fail) {
|
||||
exit(255); // Terminate the testing
|
||||
|
||||
@ -833,7 +833,7 @@ 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
|
||||
DeepState_HardCrash();
|
||||
}
|
||||
|
||||
if (FLAGS_exit_on_fail && ((result == DeepState_TestRunCrash) ||
|
||||
@ -921,7 +921,7 @@ void __assert_fail(const char * assertion, const char * file,
|
||||
"%s(%u): Assertion %s failed in function %s",
|
||||
file, line, assertion, function);
|
||||
if (FLAGS_abort_on_fail) {
|
||||
assert(0); // Terminate the testing in a way AFL/etc. can see as a crash
|
||||
DeepState_HardCrash();
|
||||
}
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user