In Development:
# Mentioning Check 0.9.14 for now, to fix distcheck target until next release
+* If Check is compiled without support for fork(), the behavior of
+ functions which require fork() to be useful have been changed.
+ Functions that attempt to set CK_FORK mode are no-ops,
+ check_fork() returns in failure, and check_waitpid_and_exit()
+ exits in failure.
+
* Add space around operators in assert messages for readability.
Bug #102.
#else
(void)tc;
(void)timeout;
- eprintf
- ("This version does not support timeouts, as fork is not supported",
- __FILE__, __LINE__);
+ /* Ignoring, as Check is not compiled with fork support. */
#endif /* HAVE_FORK */
}
* the environment variable CK_DEFAULT_TIMEOUT is defined and no timeout
* is set, the value in the environment variable is used.
*
+ * If Check is compile without fork() support this call is ignored,
+ * as timeouts are not possible.
+ *
* @param tc test case to assign timeout to
* @param timeout to use, in seconds. If the value contains a decimal
* portion, but no high resolution timer is available,
* If set to CK_FORK or CK_NOFORK, the environment variable
* if defined is ignored.
*
+ * If Check is compiled without support for fork(), attempting
+ * to set the status to CK_FORK is ignored.
+ *
* @param sr suite runner to assign the fork status to
* @param fstat fork status to assign
*
* the process group will be killed; using this wrapper will prevent
* orphan processes.
*
+ * If Check is compiled without fork() support this call simply
+ * return -1 and does nothing.
+ *
* @return On success, the PID of the child process is returned in
* the parent, and 0 is returned in the child. On failure,
- * an error will be printed and exit() invoked.
+ * a value of -1 is returned to the parent process and no
+ * child process is created.
*
* @since 0.9.3
*/
* exited without error, exit(EXIT_SUCCESS) is invoked; otherwise
* exit(EXIT_FAILURE) is invoked.
*
+ * If Check is compiled without support for fork(), this invokes
+ * exit(EXIT_FAILURE).
+ *
* @param pid process to wait for, created by check_fork()
*
* @since 0.9.3
#if defined(HAVE_FORK) && HAVE_FORK==1
return CK_FORK;
#else /* HAVE_FORK */
- eprintf("This version does not support fork", __FILE__, __LINE__);
+ /* Ignoring, as Check is not compiled with fork support. */
return CK_NOFORK;
#endif /* 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__);
+ /* Overriding, as Check is not compiled with fork support. */
+ fstat = CK_NOFORK;
}
#endif /* ! HAVE_FORK */
sr->fstat = fstat;
}
return pid;
#else /* HAVE_FORK */
- eprintf("This version does not support fork", __FILE__, __LINE__);
- return 0;
+ /* Ignoring, as Check is not compiled with fork support. */
+ return -1;
#endif /* HAVE_FORK */
}
}
exit(EXIT_SUCCESS);
#else /* HAVE_FORK */
- eprintf("This version does not support fork", __FILE__, __LINE__);
+ /* Ignoring, as Check is not compiled with fork support. */
+ exit(EXIT_FAILURE);
#endif /* HAVE_FORK */
}
}
END_TEST
+#if !defined(HAVE_FORK) || HAVE_FORK == 0
+START_TEST(test_check_fork)
+{
+ ck_assert_int_eq(-1, check_fork());
+}
+END_TEST
+#endif
+
int main(void)
{
s = suite_create("NoFork");
srunner_run_all(sr, CK_MINIMAL);
srunner_free(sr);
+#if !defined(HAVE_FORK) || HAVE_FORK == 0
+ s = suite_create("NoForkSupport");
+ tc = tcase_create("NoFork");
+ sr = srunner_create(s);
+
+ /* The following should not fail, but should be ignored */
+ srunner_set_fork_status(sr, CK_FORK);
+ if(srunner_fork_status(sr) != CK_NOFORK)
+ {
+ fprintf(stderr, "Call to srunner_set_fork_status() was not ignored\n");
+ exit(1);
+ }
+
+ suite_add_tcase(s, tc);
+ tcase_add_test(tc, test_check_fork);
+ srunner_run_all(sr, CK_MINIMAL);
+ srunner_free(sr);
+#endif
+
return 0;
}
0%: Checks: 1, Failures: 1, Errors: 0"
else
expected="Running suite(s): NoFork
-0%: Checks: 1, Failures: 1, Errors: 0"
+0%: Checks: 1, Failures: 1, Errors: 0
+Running suite(s): NoForkSupport
+100%: Checks: 1, Failures: 0, Errors: 0"
fi
actual=`./check_nofork${EXEEXT} | tr -d "\r"`