void srunner_set_fork_status (SRunner *sr, enum fork_status fstat)
{
+#if !defined(HAVE_FORK)
+ /* If fork() is unavailable, do not allow a fork mode to be set */
+ if (fstat != CK_NOFORK)
+ {
+ eprintf("This version does not support fork", __FILE__, __LINE__);
+ }
+#endif /* ! HAVE_FORK */
sr->fstat = fstat;
}
}
END_TEST
-START_TEST(test_set_fork)
+START_TEST(test_set_nofork)
{
srunner_set_fork_status(fork_dummy_sr, CK_NOFORK);
ck_assert_msg(srunner_fork_status(fork_dummy_sr) == CK_NOFORK,
}
END_TEST
+/*
+ * The following tests will fail if fork is unavailable, as
+ * attempting to set the fork mode as anything but
+ * CK_NOFORK is considered an error.
+ */
+#if defined(HAVE_FORK)
START_TEST(test_env)
{
putenv((char *) "CK_FORK=no");
"Explicit setting of fork status should override env");
}
END_TEST
-
+#endif /* HAVE_FORK */
START_TEST(test_nofork)
{
suite_add_tcase(s, tc);
tcase_add_test(tc,test_default_fork);
- tcase_add_test(tc,test_set_fork);
+ tcase_add_test(tc,test_set_nofork);
+#if defined(HAVE_FORK)
tcase_add_test(tc,test_env);
tcase_add_test(tc,test_env_and_set);
+#endif /* HAVE_FORK */
tcase_add_test(tc,test_nofork);
return s;