AC_CHECK_FUNCS([setitimer])
+# Checks for functions not available in Windows
+AC_CHECK_FUNCS([fork])
+AC_CHECK_FUNCS([sigaction])
+
# Check if the system's snprintf (and its variations) are C99 compliant.
# If they are not, use the version in libcompat.
HW_FUNC_VSNPRINTF
va_end(ap);
send_failure_info (buf);
if (cur_fork_status() == CK_FORK) {
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FORK
exit(1);
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
} else {
longjmp(error_jmp_buffer, 1);
}
static void set_nofork_info (TestResult *tr);
static char *pass_msg (void);
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FORK
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,
break;
}
}
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
#define MSG_LEN 100
log_test_start (sr, tc, tfun);
switch (srunner_fork_status(sr)) {
case CK_FORK:
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FORK
tr = tcase_run_tfun_fork (sr, tc, tfun, i);
-#else /* _POSIX_VERSION */
+#else /* HAVE_FORK */
eprintf("This version does not support fork", __FILE__, __LINE__);
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
break;
case CK_NOFORK:
tr = tcase_run_tfun_nofork (sr, tc, tfun, i);
return strdup("Passed");
}
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FORK
static TestResult *tcase_run_tfun_fork (SRunner *sr, TCase *tc, TF *tfun, int i)
{
pid_t pid_w;
return ((was_sig && (signal_received != signal_expected)) ||
(was_exit && exit_status != 0));
}
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
enum fork_status srunner_fork_status (SRunner *sr)
{
if (strcmp (env,"no") == 0)
return CK_NOFORK;
else {
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FORK
return CK_FORK;
-#else /* _POSIX_VERSION */
+#else /* HAVE_FORK */
eprintf("This version does not support fork", __FILE__, __LINE__);
return CK_NOFORK;
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
}
} else
return sr->fstat;
void srunner_run (SRunner *sr, const char *sname, const char *tcname, enum print_output print_mode)
{
-#ifdef _POSIX_VERSION
+#ifdef HAVE_SIGACTION
struct sigaction old_action;
struct sigaction new_action;
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_SIGACTION */
/* Get the selected test suite and test case from the
environment. */
eprintf ("Bad print_mode argument to srunner_run_all: %d",
__FILE__, __LINE__, print_mode);
}
-#ifdef _POSIX_VERSION
+#ifdef HAVE_SIGACTION
memset(&new_action, 0, sizeof new_action);
new_action.sa_handler = sig_handler;
sigaction(SIGALRM, &new_action, &old_action);
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_SIGACTION */
srunner_run_init (sr, print_mode);
srunner_iterate_suites (sr, sname, tcname, print_mode);
srunner_run_end (sr, print_mode);
-#ifdef _POSIX_VERSION
+#ifdef HAVE_SIGACTION
sigaction(SIGALRM, &old_action, NULL);
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_SIGACTION */
}
pid_t check_fork (void)
{
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FORK
pid_t pid = fork();
/* Set the process to a process group to be able to kill it easily. */
if(pid >= 0)
setpgid(pid, group_pid);
}
return pid;
-#else /* _POSIX_VERSION */
+#else /* HAVE_FORK */
eprintf("This version does not support fork", __FILE__, __LINE__);
return 0;
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
}
void check_waitpid_and_exit (pid_t pid CK_ATTRIBUTE_UNUSED)
{
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FORK
pid_t pid_w;
int status;
}
}
exit(EXIT_SUCCESS);
-#else /* _POSIX_VERSION */
+#else /* HAVE_FORK */
eprintf("This version does not support fork", __FILE__, __LINE__);
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
}
int n;
SRunner *sr;
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FORK
fork_setup();
setup_fixture();
setup();
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
sr = srunner_create (make_master_suite());
srunner_add_suite(sr, make_list_suite());
END_TEST
/* the ppack probably means 'pipe' pack */
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FORK
START_TEST(test_ppack)
{
int filedes[2];
free (fmsg.msg);
}
END_TEST
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
Suite *make_pack_suite(void)
{
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 _POSIX_VERSION
+#ifdef HAVE_FORK
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_core, test_ppack_multictx);
tcase_add_test (tc_core, test_ppack_nofail);
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
suite_add_tcase (s, tc_limit);
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 _POSIX_VERSION
+#ifdef HAVE_FORK
tcase_add_test (tc_limit, test_ppack_big);
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
return s;
}
{
mark_point();
#define LINENO_mark_lno _STR(__LINE__)
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FORK
exit(EXIT_FAILURE); /* should fail with mark_point above as line */
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
}
END_TEST
}
END_TEST
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FORK
START_TEST(test_fork1p_pass)
{
pid_t pid;
check_waitpid_and_exit(pid);
}
END_TEST
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
START_TEST(test_srunner)
{
tcase_add_test (tc_limit, test_null);
tcase_add_test (tc_limit, test_null_2);
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FORK
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);
tcase_add_test (tc_messaging_and_fork, test_fork1c_fail);
tcase_add_test (tc_messaging_and_fork, test_fork2_pass);
tcase_add_test (tc_messaging_and_fork, test_fork2_fail);
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
return s;
}
TCase *tc;
SRunner *sr;
-#if defined (HAVE_PTHREAD) || defined (_POSIX_VERSION)
+#if defined (HAVE_PTHREAD) || defined (HAVE_FORK)
static void *
sendinfo (void *userdata CK_ATTRIBUTE_UNUSED)
{
}
return NULL;
}
-#endif /* HAVE_PTHREAD || _POSIX_VERSION */
+#endif /* HAVE_PTHREAD || HAVE_FORK */
#ifdef HAVE_PTHREAD
START_TEST (test_stress_threads)
END_TEST
#endif /* HAVE_PTHREAD */
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FORK
START_TEST (test_stress_forks)
{
pid_t cpid = fork ();
}
}
END_TEST
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
int
main (void)
tcase_add_loop_test (tc, test_stress_threads, 0, 100);
#endif /* HAVE_PTHREAD */
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FORK
tcase_add_loop_test (tc, test_stress_forks, 0, 100);
-#endif /* _POSIX_VERSION */
+#endif /* HAVE_FORK */
srunner_run_all (sr, CK_VERBOSE);
nf = srunner_ntests_failed (sr);
srunner_free (sr);
/* hack to give us XFAIL on non-posix platforms */
-#ifndef _POSIX_VERSION
+#ifndef HAVE_FORK
nf++;
-#endif /* !_POSIX_VERSION */
+#endif /* !HAVE_FORK */
return nf ? EXIT_FAILURE : EXIT_SUCCESS;
}