]> granicus.if.org Git - strace/commitdiff
tests/fork-f.c: use libtests
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 6 Jan 2016 11:22:25 +0000 (11:22 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 6 Jan 2016 11:24:29 +0000 (11:24 +0000)
* tests/fork-f.c (main): Use assert and perror_msg_and_fail.

tests/fork-f.c

index 68c88460a46c22c2cfd3642b2a1f6a3a60d23554..aee0c5e513fff6e46b055161bdb54af159569380 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
@@ -26,6 +26,7 @@
  */
 
 #include "tests.h"
+#include <assert.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
@@ -48,17 +49,13 @@ int main(int ac, char **av, char **ep)
 
        int fds[2];
        (void) close(0);
-       if (pipe(fds)) {
-               perror("pipe");
-               return 77;
-       }
+       if (pipe(fds))
+               perror_msg_and_fail("pipe");
 
        pid_t pid = fork();
 
-       if (pid < 0) {
-               perror("fork");
-               return 77;
-       }
+       if (pid < 0)
+               perror_msg_and_fail("fork");
 
        if (!pid) {
                close(fds[1]);
@@ -77,14 +74,8 @@ int main(int ac, char **av, char **ep)
        close(fds[1]);
 
        int status;
-       if (wait(&status) != pid) {
-               perror("wait");
-               return 77;
-       }
-       if (status) {
-               fprintf(stderr, "status = %d\n", status);
-               return 77;
-       }
+       assert(wait(&status) == pid);
+       assert(status == 0);
 
        logit("finish");