From 400d826b0a3e369a1ae1d5bfbe484fb2993472af Mon Sep 17 00:00:00 2001 From: Peter Goodman Date: Thu, 27 Sep 2018 17:14:19 -0700 Subject: [PATCH] Make sure DeepState_Setup is not inlined for default-provided main functions. --- src/lib/DeepState.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/DeepState.c b/src/lib/DeepState.c index fb5fede..e6395ed 100644 --- a/src/lib/DeepState.c +++ b/src/lib/DeepState.c @@ -367,8 +367,13 @@ const struct DeepState_IndexEntry DeepState_API[] = { }; /* Set up DeepState. */ +DEEPSTATE_NOINLINE void DeepState_Setup(void) { - DeepState_AllocCurrentTestRun(); + static int was_setup = 0; + if (!was_setup) { + DeepState_AllocCurrentTestRun(); + was_setup = 1; + } /* TODO(pag): Sort the test cases by file name and line number. */ } @@ -620,8 +625,12 @@ void __stack_chk_fail(void) { __attribute__((weak)) int main(int argc, char *argv[]) { + int ret = 0; + DeepState_Setup(); DeepState_InitOptions(argc, argv); - return DeepState_Run(); + ret = DeepState_Run(); + DeepState_Teardown(); + return ret; } DEEPSTATE_END_EXTERN_C