]> granicus.if.org Git - check/commitdiff
* msys/gcc portability:
authorcpickett <cpickett@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Sun, 28 Dec 2008 07:16:08 +0000 (07:16 +0000)
committercpickett <cpickett@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Sun, 28 Dec 2008 07:16:08 +0000 (07:16 +0000)
  - protect calls to fork/sleep/kill with _POSIX_VERSION
  - protect inclusion of sys/wait.h with #if HAVE_SYS_WAIT_H

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

tests/check_check_sub.c

index bb367bb6ac149582f24b881377b73374b13f788d..303932dd3b18babf966c2d1e0b5c5f985494095e 100644 (file)
@@ -1,8 +1,11 @@
-#include <stdlib.h>
-#include <signal.h>
-#include <unistd.h>
+#include "config.h"
 #include <sys/types.h>
+#if HAVE_SYS_WAIT_H
 #include <sys/wait.h>
+#endif /* HAVE_SYS_WAIT_H */
+#include <unistd.h>
+#include <stdlib.h>
+#include <signal.h>
 #include <check.h>
 #include "check_check.h"
 
@@ -10,9 +13,6 @@
 
 
 
-
-
-
 START_TEST(test_lno)
 {
   fail("Failure expected"); /* line 18*/
@@ -315,16 +315,20 @@ START_TEST(test_fork1p_pass)
 {
   pid_t pid;
   
+#ifdef _POSIX_VERSION
   if((pid = fork()) < 0) {
     fail("Failed to fork new process");
   } else if (pid > 0) {
+#endif /* _POSIX_VERSION */
     fail_unless(1, NULL);
+#ifdef _POSIX_VERSION
     kill(pid, SIGKILL);
   } else {
     for (;;) {
       sleep(1);
     }
   }
+#endif /* _POSIX_VERSION */
 }
 END_TEST
 
@@ -332,16 +336,20 @@ START_TEST(test_fork1p_fail)
 {
   pid_t pid;
   
+#ifdef _POSIX_VERSION
   if((pid = fork()) < 0) {
     fail("Failed to fork new process");
   } else if (pid > 0) {
+#endif /* _POSIX_VERSION */
     fail("Expected fail");
+#ifdef _POSIX_VERSION
     kill(pid, SIGKILL);
   } else {
     for (;;) {
       sleep(1);
     }
   }
+#endif /* _POSIX_VERSION */
 }
 END_TEST