]> granicus.if.org Git - check/commitdiff
modify how HAVE_FORK is determined in code
authorbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Wed, 25 Dec 2013 03:04:44 +0000 (03:04 +0000)
committerbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Wed, 25 Dec 2013 03:04:44 +0000 (03:04 +0000)
autotools will define HAVE_FORK only if fork is available.
cmake can do the same thing on Linux, however on Windows
the only way to get HAVE_FORK to appear is to make it always
appear and contain a value. To support both autotools and
cmake, change the compile time check slightly to check that
HAVE_FORK is 1.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@956 64e312b2-a51f-0410-8e61-82d0ca0eb02a

src/check.c
src/check_run.c
tests/check_check_master.c
tests/check_check_pack.c
tests/check_check_sub.c
tests/check_thread_stress.c
tests/ex_log_output.c
tests/ex_output.c
tests/ex_tap_output.c
tests/ex_xml_output.c

index 2af3c7841d364ff36281adb8c5d11320d4de1da7..c2e9ada8eda91f456f1f6db088724e6ab8406523 100644 (file)
@@ -268,7 +268,7 @@ void _ck_assert_failed (const char *file,
   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 {
index 00197186fb99619e91b3b08563325066c0f90aee..65af1a05ebe821131f0d0457e7e54d4ac9478064 100644 (file)
@@ -75,7 +75,7 @@ static TestResult *receive_result_info_nofork (const char *tcname,
 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,
@@ -177,7 +177,7 @@ static void srunner_iterate_tcase_tfuns (SRunner *sr, TCase *tc)
       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__);
@@ -372,7 +372,7 @@ static char *pass_msg (void)
   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;
@@ -595,7 +595,7 @@ enum fork_status srunner_fork_status (SRunner *sr)
   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;
@@ -603,7 +603,7 @@ enum fork_status srunner_fork_status (SRunner *sr)
     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__);
@@ -668,7 +668,7 @@ void srunner_run (SRunner *sr, const char *sname, const char *tcname, enum print
 
 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)
@@ -684,7 +684,7 @@ pid_t check_fork (void)
 
 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;
 
index 7e8f9e9e69cb7bd140c04c2d5d35dd111b995316..efd39ccb9cc8f93660e6dcf5985e23ee40eb7855 100644 (file)
@@ -27,7 +27,7 @@ static char signal_8_str[SIG_STR_LEN];
 /* 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" },
@@ -71,7 +71,7 @@ static master_test_t master_tests[] = {
   { "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 },
@@ -81,7 +81,7 @@ static master_test_t master_tests[] = {
   { "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" },
@@ -192,7 +192,7 @@ static master_test_t master_tests[] = {
 #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
@@ -200,7 +200,7 @@ static master_test_t master_tests[] = {
 #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" },
@@ -421,7 +421,7 @@ Suite *make_master_suite (void)
      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);
index 32dd4982f99af7dbc2bab33db2512bf0357ad1cd..d6f931b5db4589df7cabef8699ae485193bd0df9 100644 (file)
@@ -188,7 +188,7 @@ START_TEST(test_pack_loc_limit)
 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];
@@ -400,7 +400,7 @@ 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 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);
@@ -411,7 +411,7 @@ Suite *make_pack_suite(void)
   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 */
 
index 8ff5bd8a5a6f07555c9d2531b979e2b0ea30e592..8a8ca720f4478eceff19442f5606861e5022474e 100644 (file)
@@ -16,7 +16,7 @@ START_TEST(test_lno)
 }
 END_TEST
 
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
 START_TEST(test_mark_lno)
 {
   mark_point();
@@ -399,7 +399,7 @@ START_TEST(test_ck_assert_ptr_ne)
 }
 END_TEST
 
-#if defined(HAVE_FORK)
+#if defined(HAVE_FORK) && HAVE_FORK == 1
 START_TEST(test_segv)
   #define LINENO_segv _STR(__LINE__)
 {
@@ -429,7 +429,7 @@ START_TEST(test_mark_point)
 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__)
 {
@@ -487,7 +487,7 @@ START_TEST(test_sleep14)
 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);
@@ -528,7 +528,7 @@ START_TEST(test_null_2)
 }
 END_TEST
 
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
 START_TEST(test_fork1p_pass)
 {
   pid_t pid;
@@ -680,7 +680,7 @@ void init_master_tests_lineno(int num_master_tests) {
   const char * lineno[] = {
 /* Simple Tests */
     LINENO_lno,
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
     LINENO_mark_lno,
 #endif
     "-1",
@@ -724,7 +724,7 @@ void init_master_tests_lineno(int num_master_tests) {
     LINENO_ck_assert_ptr_eq,
     LINENO_ck_assert_ptr_ne,
 
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
 /* Signal Tests */
     "-1",
     "-1",
@@ -735,7 +735,7 @@ void init_master_tests_lineno(int num_master_tests) {
     "-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,
@@ -848,13 +848,13 @@ void init_master_tests_lineno(int num_master_tests) {
 #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",
@@ -888,10 +888,10 @@ Suite *make_sub_suite(void)
   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;
@@ -914,10 +914,10 @@ Suite *make_sub_suite(void)
   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");
@@ -951,10 +951,10 @@ Suite *make_sub_suite(void)
   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);
@@ -978,7 +978,7 @@ Suite *make_sub_suite(void)
   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);
@@ -1029,7 +1029,7 @@ Suite *make_sub_suite(void)
   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 */
@@ -1039,7 +1039,7 @@ Suite *make_sub_suite(void)
   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);
@@ -1147,7 +1147,7 @@ Suite *make_sub_suite(void)
 #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
@@ -1155,7 +1155,7 @@ Suite *make_sub_suite(void)
 #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);
index b06ed16110a24276534145d2a38bc3fdf8faf6ea..e5f8af02e9a4669bb9038ffb0b0bd611cff54e49 100644 (file)
@@ -34,7 +34,7 @@ START_TEST (test_stress_threads)
 END_TEST
 #endif /* HAVE_PTHREAD */
 
-#ifdef HAVE_FORK
+#if defined(HAVE_FORK) && HAVE_FORK==1
 START_TEST (test_stress_forks)
 {
   pid_t cpid = fork ();
@@ -66,7 +66,7 @@ main (void)
   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 */
 
index fa621ea2f8c8d054ef59e7ecb5d186214c1707c8..4850056b2962011244b38a9ed5cf65e2c1c47350 100644 (file)
@@ -21,7 +21,7 @@ END_TEST
  * 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);
@@ -45,7 +45,7 @@ static Suite *make_s1_suite (void)
   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 */
 
index cf8c617dfdd18eb427f04def5496ca623cf8b434..1382b513633aca012eb994cc68239d0530927b0a 100644 (file)
@@ -22,7 +22,7 @@ END_TEST
  * 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);
@@ -40,7 +40,7 @@ static Suite *make_suite (void)
   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;
index c4f99eaca62f6a1e8b15abf811bfb0b78fc41a85..6928ef28fb1ba3a37fb3216f8bd232ea58103237 100644 (file)
@@ -21,7 +21,7 @@ END_TEST
  * 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);
@@ -56,7 +56,7 @@ static Suite *make_s1_suite (void)
   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 */
 
index 0a9893699cdc952dc9a70d90d61ed6017d617640..173cffb1c0fd802a5fea20341d013756f657ca57 100644 (file)
@@ -21,7 +21,7 @@ END_TEST
  * 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);
@@ -57,7 +57,7 @@ static Suite *make_s1_suite (void)
   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 */