aboutsummaryrefslogtreecommitdiff
path: root/stdio-common/tst-popen2.c
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
committerZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
commit5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch)
tree4470480d904b65cf14ca524f96f79eca818c3eaf /stdio-common/tst-popen2.c
parent199fc19d3aaaf57944ef036e15904febe877fc93 (diff)
downloadglibc-zack/build-layout-experiment.tar
glibc-zack/build-layout-experiment.tar.gz
glibc-zack/build-layout-experiment.tar.bz2
glibc-zack/build-layout-experiment.zip
Prepare for radical source tree reorganization.zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage directory, REORG.TODO, except for files that will certainly still exist in their current form at top level when we're done (COPYING, COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which are moved to the new directory OldChangeLogs, instead), and the generated file INSTALL (which is just deleted; in the new order, there will be no generated files checked into version control).
Diffstat (limited to 'stdio-common/tst-popen2.c')
-rw-r--r--stdio-common/tst-popen2.c92
1 files changed, 0 insertions, 92 deletions
diff --git a/stdio-common/tst-popen2.c b/stdio-common/tst-popen2.c
deleted file mode 100644
index 0ab151c598..0000000000
--- a/stdio-common/tst-popen2.c
+++ /dev/null
@@ -1,92 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-static int
-do_test (void)
-{
- int fd = dup (fileno (stdout));
- if (fd <= 1)
- {
- puts ("dup failed");
- return 1;
- }
-
- FILE *f1 = fdopen (fd, "w");
- if (f1 == NULL)
- {
- printf ("fdopen failed: %m\n");
- return 1;
- }
-
- fclose (stdout);
-
- FILE *f2 = popen ("echo test1", "r");
- if (f2 == NULL)
- {
- fprintf (f1, "1st popen failed: %m\n");
- return 1;
- }
- FILE *f3 = popen ("echo test2", "r");
- if (f2 == NULL || f3 == NULL)
- {
- fprintf (f1, "2nd popen failed: %m\n");
- return 1;
- }
-
- char *line = NULL;
- size_t len = 0;
- int result = 0;
- if (getline (&line, &len, f2) != 6)
- {
- fputs ("could not read line from 1st popen\n", f1);
- result = 1;
- }
- else if (strcmp (line, "test1\n") != 0)
- {
- fprintf (f1, "read \"%s\"\n", line);
- result = 1;
- }
-
- if (getline (&line, &len, f2) != -1)
- {
- fputs ("second getline did not return -1\n", f1);
- result = 1;
- }
-
- if (getline (&line, &len, f3) != 6)
- {
- fputs ("could not read line from 2nd popen\n", f1);
- result = 1;
- }
- else if (strcmp (line, "test2\n") != 0)
- {
- fprintf (f1, "read \"%s\"\n", line);
- result = 1;
- }
-
- if (getline (&line, &len, f3) != -1)
- {
- fputs ("second getline did not return -1\n", f1);
- result = 1;
- }
-
- int ret = pclose (f2);
- if (ret != 0)
- {
- fprintf (f1, "1st pclose returned %d\n", ret);
- result = 1;
- }
-
- ret = pclose (f3);
- if (ret != 0)
- {
- fprintf (f1, "2nd pclose returned %d\n", ret);
- result = 1;
- }
-
- return result;
-}
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"