]> granicus.if.org Git - strace/commitdiff
tests/filter-unavailable.c: use libtests
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 4 Jan 2016 23:56:03 +0000 (23:56 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 6 Jan 2016 00:14:36 +0000 (00:14 +0000)
* tests/filter-unavailable.c (main): Use perror_msg_and_fail.

tests/filter-unavailable.c

index 2151c9a8e8658de716a0a7df8fc2aad5c83cd6bf..6368b2cb8e98c6a1a5784166a2312ce1baea1806 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,6 +25,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "tests.h"
 #include <assert.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -52,7 +53,8 @@ process(void)
 
        (void) close(0);
        (void) close(1);
-       assert(pipe(fds) == 0 && fds[0] == 0 && fds[1] == 1);
+       if (pipe(fds))
+               perror_msg_and_fail("pipe");
 
        for (i = 0; i < T; ++i)
                assert(pthread_create(&t, NULL, thread, NULL) == 0);
@@ -70,10 +72,13 @@ main(void)
        pid_t p;
 
        for (i = 0; i < P; ++i) {
-               assert((p = fork()) >= 0);
+               p = fork();
+               if (p < 0)
+                       perror_msg_and_fail("fork");
                if (p == 0)
                        return process();
-               assert(waitpid(p, &s, 0) == p && WIFEXITED(s));
+               assert(waitpid(p, &s, 0) == p);
+               assert(WIFEXITED(s));
                if (WEXITSTATUS(s))
                        return WEXITSTATUS(s);
        }