From: brarcher Date: Sun, 22 Sep 2013 21:27:50 +0000 (+0000) Subject: Set default fork mode to CK_NOFORK if fork is unavailable X-Git-Tag: 0.10.0~440 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a3112af81a0ebd7d79477671fb2a23b81bf3bfe7;p=check Set default fork mode to CK_NOFORK if fork is unavailable The default fork mode is CK_FORK_GETENV, which checks the environment, and failing that falls back on using fork. If fork is unavailable, the default is now to set CK_NOFORK. git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@774 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- diff --git a/src/check.c b/src/check.c index 8fc4bf1..9e8d7e2 100644 --- a/src/check.c +++ b/src/check.c @@ -279,7 +279,17 @@ SRunner *srunner_create (Suite *s) sr->log_fname = NULL; sr->xml_fname = NULL; sr->loglst = NULL; + +#if defined(HAVE_FORK) sr->fstat = CK_FORK_GETENV; +#else + /* + * Overriding the default of running tests in fork mode, + * as this system does not have fork() + */ + sr->fstat = CK_NOFORK; +#endif /* HAVE_FORK */ + return sr; } diff --git a/tests/check_check_fork.c b/tests/check_check_fork.c index 22e2c93..75907fd 100644 --- a/tests/check_check_fork.c +++ b/tests/check_check_fork.c @@ -71,8 +71,13 @@ void fork_teardown (void) START_TEST(test_default_fork) { +#if defined(HAVE_FORK) ck_assert_msg(srunner_fork_status(fork_dummy_sr) == CK_FORK, "Default fork status not set correctly"); +#else + ck_assert_msg(srunner_fork_status(fork_dummy_sr) == CK_NOFORK, + "Default fork status not set correctly"); +#endif /* HAVE_FORK */ } END_TEST