1 /* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24 write_data (FILE *stream)
28 fprintf (stream, "%d\n", i);
31 fprintf (stderr, "Output to stream failed.\n");
37 read_data (FILE *stream)
43 if (fscanf (stream, "%d\n", &j) != 1 || j != i)
47 puts ("Test FAILED!");
59 /* We must remove this entry to assure the `cat' binary does not use
60 the perhaps incompatible new shared libraries. */
61 unsetenv ("LD_LIBRARY_PATH");
63 output = popen ("/bin/cat >/tmp/tstpopen.tmp", "w");
67 puts ("Test FAILED!");
71 wstatus = pclose (output);
72 printf ("writing pclose returned %d\n", wstatus);
73 input = popen ("/bin/cat /tmp/tstpopen.tmp", "r");
76 perror ("/tmp/tstpopen.tmp");
77 puts ("Test FAILED!");
81 rstatus = pclose (input);
82 printf ("reading pclose returned %d\n", rstatus);
84 remove ("/tmp/tstpopen.tmp");
87 output = popen ("/bin/cat", "m");
90 puts ("popen called with illegal mode does not return NULL");
91 puts ("Test FAILED!");
96 puts ("popen called with illegal mode does not set errno to EINVAL");
97 puts ("Test FAILED!");
101 puts (wstatus | rstatus ? "Test FAILED!" : "Test succeeded.");
102 return (wstatus | rstatus);