va_end(ap);
send_failure_info (buf);
if (cur_fork_status() == CK_FORK) {
- #ifdef HAVE_FORK
+ #if defined(HAVE_FORK) && HAVE_FORK==1
exit(1);
#endif /* HAVE_FORK */
} else {
static void set_nofork_info (TestResult *tr);
static char *pass_msg (void);
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
static TestResult *tcase_run_tfun_fork (SRunner *sr, TCase *tc, TF *tf, int i);
static TestResult *receive_result_info_fork (const char *tcname,
const char *tname,
log_test_start (sr, tc, tfun);
switch (srunner_fork_status(sr)) {
case CK_FORK:
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
tr = tcase_run_tfun_fork (sr, tc, tfun, i);
#else /* HAVE_FORK */
eprintf("This version does not support fork", __FILE__, __LINE__);
return strdup("Passed");
}
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
static TestResult *tcase_run_tfun_fork (SRunner *sr, TCase *tc, TF *tfun, int i)
{
pid_t pid_w;
if (sr->fstat == CK_FORK_GETENV) {
char *env = getenv ("CK_FORK");
if (env == NULL)
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
return CK_FORK;
#else
return CK_NOFORK;
if (strcmp (env,"no") == 0)
return CK_NOFORK;
else {
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
return CK_FORK;
#else /* HAVE_FORK */
eprintf("This version does not support fork", __FILE__, __LINE__);
pid_t check_fork (void)
{
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
pid_t pid = fork();
/* Set the process to a process group to be able to kill it easily. */
if(pid >= 0)
void check_waitpid_and_exit (pid_t pid CK_ATTRIBUTE_UNUSED)
{
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
pid_t pid_w;
int status;
/* FIXME: all these line numbers are kind of hard to maintain */
static master_test_t master_tests[] = {
{ "Simple Tests", CK_FAILURE, "Failure expected" },
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
{ "Simple Tests", CK_ERROR, "Early exit with return value 1" },
#endif
{ "Simple Tests", CK_PASS, "Passed" },
{ "Simple Tests", CK_FAILURE, "Assertion 'x==y' failed: x==0x1, y==0x2" },
{ "Simple Tests", CK_FAILURE, "Assertion 'x!=z' failed: x==0x1, z==0x1" },
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
{ "Signal Tests", CK_ERROR, signal_11_str },
{ "Signal Tests", CK_PASS, "Passed" },
{ "Signal Tests", CK_ERROR, signal_11_8_str },
{ "Signal Tests", CK_ERROR, signal_8_str },
#endif
-#if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK)
+#if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) && HAVE_FORK==1
#if HAVE_WORKING_SETENV
{ "Environment Integer Timeout Tests", CK_ERROR, "Test timeout expired" },
{ "Environment Integer Timeout Tests", CK_PASS, "Passed" },
#endif /* HAVE_WORKING_SETENV */
#endif /* TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) */
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
{ "Limit Tests", CK_ERROR, "Early exit with return value 1" },
#endif /* HAVE_FORK */
#if MEMORY_LEAKING_TESTS_ENABLED
#endif /* MEMORY_LEAKING_TESTS_ENABLED */
{ "Limit Tests", CK_FAILURE, "Completed properly" },
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
{ "Msg and fork Tests", CK_PASS, "Passed" },
{ "Msg and fork Tests", CK_FAILURE, "Expected fail" },
{ "Msg and fork Tests", CK_PASS, "Passed" },
preservation of fixture values across tests, regardless
of the order in which tests are added to the test case */
tcase_add_test (tc_fixture, test_setup);
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
/* The remaining test runs only work if fork() is available. */
tcase_add_test (tc_fixture, test_setup);
tcase_add_test (tc_fixture, test_setup);
END_TEST
/* the ppack probably means 'pipe' pack */
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
START_TEST(test_ppack)
{
int filedes[2];
tcase_add_test (tc_core, test_pack_loc);
tcase_add_test (tc_core, test_pack_ctx);
tcase_add_test (tc_core, test_pack_len);
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
tcase_add_test (tc_core, test_ppack);
tcase_add_test (tc_core, test_ppack_noctx);
tcase_add_test (tc_core, test_ppack_onlyctx);
tcase_add_test (tc_limit, test_pack_ctx_limit);
tcase_add_test (tc_limit, test_pack_fail_limit);
tcase_add_test (tc_limit, test_pack_loc_limit);
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
tcase_add_test (tc_limit, test_ppack_big);
#endif /* HAVE_FORK */
}
END_TEST
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
START_TEST(test_mark_lno)
{
mark_point();
}
END_TEST
-#if defined(HAVE_FORK)
+#if defined(HAVE_FORK) && HAVE_FORK == 1
START_TEST(test_segv)
#define LINENO_segv _STR(__LINE__)
{
END_TEST
#endif
-#if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK)
+#if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) && HAVE_FORK == 1
START_TEST(test_eternal)
#define LINENO_eternal _STR(__LINE__)
{
END_TEST
#endif /* TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) */
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
START_TEST(test_early_exit)
{
exit(EXIT_FAILURE);
}
END_TEST
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
START_TEST(test_fork1p_pass)
{
pid_t pid;
const char * lineno[] = {
/* Simple Tests */
LINENO_lno,
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
LINENO_mark_lno,
#endif
"-1",
LINENO_ck_assert_ptr_eq,
LINENO_ck_assert_ptr_ne,
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
/* Signal Tests */
"-1",
"-1",
"-1",
#endif /* HAVE_FORK */
-#if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK)
+#if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) && HAVE_FORK == 1
#if HAVE_WORKING_SETENV
/* Environment Integer Timeout Tests */
LINENO_eternal,
#endif /* TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) */
/* Limit Tests */
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
"-1",
#endif /* HAVE_FORK */
"-1",
"-1",
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
/* Msg and fork Tests */
"-1",
"-1",
Suite *s;
TCase *tc_simple;
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
TCase *tc_signal;
#endif
-#if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK)
+#if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) && HAVE_FORK == 1
#if HAVE_WORKING_SETENV
TCase *tc_timeout_env_int;
TCase *tc_timeout_env_double;
s = suite_create("Check Servant");
tc_simple = tcase_create("Simple Tests");
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
tc_signal = tcase_create("Signal Tests");
#endif /* HAVE_FORK */
-#if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK)
+#if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) && HAVE_FORK == 1
#if HAVE_WORKING_SETENV
setenv("CK_DEFAULT_TIMEOUT", "6", 1);
tc_timeout_env_int = tcase_create("Environment Integer Timeout Tests");
tc_messaging_and_fork = tcase_create("Msg and fork Tests");
suite_add_tcase (s, tc_simple);
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
suite_add_tcase (s, tc_signal);
#endif /* HAVE_FORK */
-#if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK)
+#if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) && HAVE_FORK == 1
#if HAVE_WORKING_SETENV
suite_add_tcase (s, tc_timeout_env_int);
suite_add_tcase (s, tc_timeout_env_double);
suite_add_tcase (s, tc_messaging_and_fork);
tcase_add_test (tc_simple, test_lno);
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
tcase_add_test (tc_simple, test_mark_lno);
#endif
tcase_add_test (tc_simple, test_pass);
tcase_add_test (tc_simple, test_ck_assert_ptr_eq);
tcase_add_test (tc_simple, test_ck_assert_ptr_ne);
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
tcase_add_test (tc_signal, test_segv);
tcase_add_test_raise_signal (tc_signal, test_segv, 11); /* pass */
tcase_add_test_raise_signal (tc_signal, test_segv, 8); /* error */
tcase_add_test (tc_signal, test_mark_point);
#endif /* HAVE_FORK */
-#if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK)
+#if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) && HAVE_FORK == 1
#if HAVE_WORKING_SETENV
tcase_add_test (tc_timeout_env_int, test_eternal);
tcase_add_test (tc_timeout_env_int, test_sleep2);
#endif /* HAVE_WORKING_SETENV */
#endif /* TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) */
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
tcase_add_test (tc_limit, test_early_exit);
#endif /* HAVE_FORK */
#if MEMORY_LEAKING_TESTS_ENABLED
#endif /* MEMORY_LEAKING_TESTS_ENABLED */
tcase_add_test (tc_limit, test_null_2);
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
tcase_add_test (tc_messaging_and_fork, test_fork1p_pass);
tcase_add_test (tc_messaging_and_fork, test_fork1p_fail);
tcase_add_test (tc_messaging_and_fork, test_fork1c_pass);
END_TEST
#endif /* HAVE_PTHREAD */
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
START_TEST (test_stress_forks)
{
pid_t cpid = fork ();
tcase_add_loop_test (tc, test_stress_threads, 0, 100);
#endif /* HAVE_PTHREAD */
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
tcase_add_loop_test (tc, test_stress_forks, 0, 100);
#endif /* HAVE_FORK */
* This test will fail without fork, as it will result in the
* unit test runniner exiting early.
*/
-#if defined(HAVE_FORK)
+#if defined(HAVE_FORK) && HAVE_FORK==1
START_TEST(test_exit)
{
exit(1);
suite_add_tcase(s, tc);
tcase_add_test (tc, test_pass);
tcase_add_test (tc, test_fail);
-#if defined(HAVE_FORK)
+#if defined(HAVE_FORK) && HAVE_FORK==1
tcase_add_test (tc, test_exit);
#endif /* HAVE_FORK */
* This test will fail without fork, as it will result in the
* unit test runniner exiting early.
*/
-#if defined(HAVE_FORK)
+#if defined(HAVE_FORK) && HAVE_FORK==1
START_TEST(test_exit)
{
exit(1);
suite_add_tcase(s, tc);
tcase_add_test (tc, test_pass);
tcase_add_test (tc, test_fail);
-#if defined(HAVE_FORK)
+#if defined(HAVE_FORK) && HAVE_FORK==1
tcase_add_test (tc, test_exit);
#endif /* HAVE_FORK */
return s;
* This test will fail without fork, as it will result in the
* unit test runniner exiting early.
*/
-#if defined(HAVE_FORK)
+#if defined(HAVE_FORK) && HAVE_FORK==1
START_TEST(test_exit)
{
exit(1);
suite_add_tcase(s, tc);
tcase_add_test (tc, test_pass);
tcase_add_test (tc, test_fail);
-#if defined(HAVE_FORK)
+#if defined(HAVE_FORK) && HAVE_FORK==1
tcase_add_test (tc, test_exit);
#endif /* HAVE_FORK */
* This test will fail without fork, as it will result in the
* unit test runniner exiting early.
*/
-#if defined(HAVE_FORK)
+#if defined(HAVE_FORK) && HAVE_FORK==1
START_TEST(test_exit)
{
exit(1);
suite_add_tcase(s, tc);
tcase_add_test (tc, test_pass);
tcase_add_test (tc, test_fail);
-#if defined(HAVE_FORK)
+#if defined(HAVE_FORK) && HAVE_FORK==1
tcase_add_test (tc, test_exit);
#endif /* HAVE_FORK */