From 23af5b562d8f20f3e6328e560797f7d950fd97da Mon Sep 17 00:00:00 2001 From: Joe Ranweiler Date: Wed, 14 Feb 2018 12:03:45 -0800 Subject: [PATCH] Add `DeepState_Crash()` hook --- src/include/deepstate/DeepState.h | 4 ++++ src/lib/DeepState.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/include/deepstate/DeepState.h b/src/include/deepstate/DeepState.h index 2a0f85f..06ef3e3 100644 --- a/src/include/deepstate/DeepState.h +++ b/src/include/deepstate/DeepState.h @@ -184,6 +184,9 @@ extern void _DeepState_Assume(int expr, const char *expr_str, const char *file, DEEPSTATE_NORETURN extern void DeepState_Abandon(const char *reason); +/* Mark this test as having crashed. */ +extern void DeepState_Crash(void); + DEEPSTATE_NORETURN extern void DeepState_Fail(void); @@ -473,6 +476,7 @@ static int DeepState_ForkAndRunTest(struct DeepState_TestInfo *test) { } /* If here, we exited abnormally, and so the test failed due to a crash. */ + DeepState_Crash(); DeepState_LogFormat(DeepState_LogError, "Crashed: %s", test->test_name); if (HAS_FLAG_output_test_dir) { diff --git a/src/lib/DeepState.c b/src/lib/DeepState.c index ec566b6..14a428a 100644 --- a/src/lib/DeepState.c +++ b/src/lib/DeepState.c @@ -55,6 +55,11 @@ void DeepState_Abandon(const char *reason) { longjmp(DeepState_ReturnToRun, 1); } +/* Mark this test as having crashed. */ +void DeepState_Crash(void) { + DeepState_TestFailed = 1; +} + /* Mark this test as failing. */ DEEPSTATE_NORETURN void DeepState_Fail(void) { @@ -261,6 +266,7 @@ const struct DeepState_IndexEntry DeepState_API[] = { /* Control-flow during the test. */ {"Pass", (void *) DeepState_Pass}, + {"Crash", (void *) DeepState_Crash}, {"Fail", (void *) DeepState_Fail}, {"SoftFail", (void *) DeepState_SoftFail}, {"Abandon", (void *) DeepState_Abandon},