X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-popen.h;h=f3df9f94b0d1039785d4caf45b6d60b5094c144e;hb=b187ff0528e2a081392a834e684d1d0c161708a7;hp=9364c5afa56990477ddd62517030eb2fa7c79b81;hpb=9076085f888c8abc5c80ea344be0ad504a26cc0f;p=gnulib.git diff --git a/tests/test-popen.h b/tests/test-popen.h index 9364c5afa..f3df9f94b 100644 --- a/tests/test-popen.h +++ b/tests/test-popen.h @@ -1,5 +1,5 @@ /* Test of opening a subcommand stream. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,17 +24,7 @@ #include #include -#define ASSERT(expr) \ - do \ - { \ - if (!(expr)) \ - { \ - fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ - fflush (stderr); \ - abort (); \ - } \ - } \ - while (0) +#include "macros.h" int main (int argc, char **argv) @@ -47,9 +37,9 @@ main (int argc, char **argv) if (argc > 1) { if (*argv[1] == 'r') /* Parent is reading, so we write. */ - ASSERT (putchar ('c') == 'c'); + ASSERT (putchar ('c') == 'c'); else /* Parent is writing, so we read. */ - ASSERT (getchar () == 'p'); + ASSERT (getchar () == 'p'); /* Test that parent can read non-zero status. */ return 42; } @@ -69,10 +59,10 @@ main (int argc, char **argv) int status; if (i) - { - ASSERT (fclose (stdin) == 0); - ASSERT (fclose (stdout) == 0); - } + { + ASSERT (fclose (stdin) == 0); + ASSERT (fclose (stdout) == 0); + } cmd[len + 1] = 'r'; ASSERT (child = popen (cmd, "r")); @@ -81,10 +71,10 @@ main (int argc, char **argv) ASSERT (WIFEXITED (status)); ASSERT (WEXITSTATUS (status) == 42); if (i) - { - ASSERT (dup2 (STDIN_FILENO, STDIN_FILENO) == -1); - ASSERT (dup2 (STDOUT_FILENO, STDOUT_FILENO) == -1); - } + { + ASSERT (dup2 (STDIN_FILENO, STDIN_FILENO) == -1); + ASSERT (dup2 (STDOUT_FILENO, STDOUT_FILENO) == -1); + } cmd[len + 1] = 'w'; ASSERT (child = popen (cmd, "w")); @@ -93,10 +83,10 @@ main (int argc, char **argv) ASSERT (WIFEXITED (status)); ASSERT (WEXITSTATUS (status) == 42); if (i) - { - ASSERT (dup2 (STDIN_FILENO, STDIN_FILENO) == -1); - ASSERT (dup2 (STDOUT_FILENO, STDOUT_FILENO) == -1); - } + { + ASSERT (dup2 (STDIN_FILENO, STDIN_FILENO) == -1); + ASSERT (dup2 (STDOUT_FILENO, STDOUT_FILENO) == -1); + } } free (cmd); return 0;