From ab43f753618726c5da91cecf63b55835279f3e5d Mon Sep 17 00:00:00 2001 From: Joe Ranweiler Date: Tue, 13 Feb 2018 14:49:36 -0800 Subject: [PATCH] Add hook to save crashing tests --- src/include/deepstate/DeepState.h | 9 ++++++++- src/lib/DeepState.c | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/include/deepstate/DeepState.h b/src/include/deepstate/DeepState.h index 7194376..c228107 100644 --- a/src/include/deepstate/DeepState.h +++ b/src/include/deepstate/DeepState.h @@ -346,6 +346,9 @@ extern void DeepState_SavePassingTest(void); /* Save a failing test to the output test directory. */ extern void DeepState_SaveFailingTest(void); +/* Save a crashing test to the output test directory. */ +extern void DeepState_SaveCrashingTest(void); + /* Jump buffer for returning to `DeepState_Run`. */ extern jmp_buf DeepState_ReturnToRun; @@ -469,7 +472,11 @@ static int DeepState_ForkAndRunTest(struct DeepState_TestInfo *test) { return status ? 1 : 0; } - /* If here, we exited abnormally, and so the test failed. */ + /* If here, we exited abnormally, and so the test failed due to a crash. */ + if (HAS_FLAG_output_test_dir) { + DeepState_SaveCrashingTest(); + } + return 1; } diff --git a/src/lib/DeepState.c b/src/lib/DeepState.c index ac61b90..6009160 100644 --- a/src/lib/DeepState.c +++ b/src/lib/DeepState.c @@ -374,6 +374,9 @@ void DeepState_SaveFailingTest(void) { printf("Saving to %s\n", FLAGS_output_test_dir); } +/* Save a crashing test to the output test directory. */ +void DeepState_SaveCrashingTest(void) {} + /* Return the first test case to run. */ struct DeepState_TestInfo *DeepState_FirstTest(void) { return DeepState_LastTestInfo;