From: cpickett Date: Thu, 1 Jan 2009 00:06:54 +0000 (+0000) Subject: * protect all calls to exit with _POSIX_VERSION, except in eprintf X-Git-Tag: 0.10.0~649 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ba55780370a37b9f514792b973513958fc79c102;p=check * protect all calls to exit with _POSIX_VERSION, except in eprintf git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@515 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- diff --git a/src/check.c b/src/check.c index a8798da..a00cd91 100644 --- a/src/check.c +++ b/src/check.c @@ -211,8 +211,11 @@ void _fail_unless (int result, const char *file, vsnprintf(buf, BUFSIZ, msg, ap); va_end(ap); send_failure_info (buf); - if (cur_fork_status() == CK_FORK) + if (cur_fork_status() == CK_FORK) { +#ifdef _POSIX_VERSION exit(1); +#endif /* _POSIX_VERSION */ + } } } diff --git a/src/check_run.c b/src/check_run.c index a5d4140..d39ae3e 100644 --- a/src/check_run.c +++ b/src/check_run.c @@ -449,7 +449,9 @@ static TestResult *tcase_run_tfun_fork (SRunner *sr, TCase *tc, TF *tfun, int i) tcase_run_checked_setup(sr, tc); tfun->fn(i); tcase_run_checked_teardown(tc); +#ifdef _POSIX_VERSION exit(EXIT_SUCCESS); +#endif /* _POSIX_VERSION */ } else { group_pid = pid; } @@ -558,10 +560,15 @@ void check_waitpid_and_exit (pid_t pid) pid_w = waitpid(pid, &status, 0); #endif /* _POSIX_VERSION */ } while (pid_w == -1); - if (waserror(status, 0)) + if (waserror(status, 0)) { +#ifdef _POSIX_VERSION exit(EXIT_FAILURE); +#endif /* _POSIX_VERSION */ + } } +#ifdef _POSIX_VERSION exit(EXIT_SUCCESS); +#endif /* _POSIX_VERSION */ } static int waserror (int CK_ATTRIBUTE_UNUSED status, int signal_expected) diff --git a/tests/check_check_master.c b/tests/check_check_master.c index fdcca70..aff5029 100644 --- a/tests/check_check_master.c +++ b/tests/check_check_master.c @@ -29,7 +29,7 @@ static char signal_8_str[SIG_STR_LEN]; /* FIXME: all these line numbers are kind of hard to maintain */ static master_test_t master_tests[] = { { "Simple Tests", 18, CK_FAILURE, "Failure expected" }, - { "Simple Tests", 24, CK_ERROR, "Early exit with return value 1" }, + { "Simple Tests", 23, CK_ERROR, "Early exit with return value 1" }, { "Simple Tests", -1, CK_PASS, "Passed" }, { "Simple Tests", -1, CK_FAILURE, "This test should fail" }, { "Simple Tests", -1, CK_PASS, "Passed" }, diff --git a/tests/check_check_sub.c b/tests/check_check_sub.c index 09f843e..474552b 100644 --- a/tests/check_check_sub.c +++ b/tests/check_check_sub.c @@ -18,14 +18,14 @@ START_TEST(test_lno) fail("Failure expected"); /* line 18*/ } END_TEST - START_TEST(test_mark_lno) { - mark_point(); /* line 24*/ - exit(EXIT_FAILURE); /* should fail at line 24*/ + mark_point(); /* line 23*/ +#ifdef _POSIX_VERSION + exit(EXIT_FAILURE); /* should fail at line 23*/ +#endif /* _POSIX_VERSION */ } END_TEST - START_TEST(test_pass) { fail_unless(1 == 1, "This test should pass");