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, see
16 <http://www.gnu.org/licenses/>. */
23 write_data (FILE *stream
)
27 fprintf (stream
, "%d\n", i
);
30 fprintf (stderr
, "Output to stream failed.\n");
36 read_data (FILE *stream
)
42 if (fscanf (stream
, "%d\n", &j
) != 1 || j
!= i
)
46 puts ("Test FAILED!");
58 /* We must remove this entry to assure the `cat' binary does not use
59 the perhaps incompatible new shared libraries. */
60 unsetenv ("LD_LIBRARY_PATH");
62 output
= popen ("/bin/cat >/tmp/tstpopen.tmp", "w");
66 puts ("Test FAILED!");
70 wstatus
= pclose (output
);
71 printf ("writing pclose returned %d\n", wstatus
);
72 input
= popen ("/bin/cat /tmp/tstpopen.tmp", "r");
75 perror ("/tmp/tstpopen.tmp");
76 puts ("Test FAILED!");
80 rstatus
= pclose (input
);
81 printf ("reading pclose returned %d\n", rstatus
);
83 remove ("/tmp/tstpopen.tmp");
86 output
= popen ("/bin/cat", "m");
89 puts ("popen called with illegal mode does not return NULL");
90 puts ("Test FAILED!");
95 puts ("popen called with illegal mode does not set errno to EINVAL");
96 puts ("Test FAILED!");
100 puts (wstatus
| rstatus
? "Test FAILED!" : "Test succeeded.");
101 return (wstatus
| rstatus
);