aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@axis.com>2006-09-30 02:34:43 +0000
committerHans-Peter Nilsson <hp@axis.com>2006-09-30 02:34:43 +0000
commit539a52558fc24b1a2c4dd3d6dc389ca111858401 (patch)
treed5a41bcdf986f4e93989cc2a9eb649bdb0e82ef1 /sim
parentc33e703572f3a3f168f1ef541a0779b926fd8dc4 (diff)
downloadgdb-539a52558fc24b1a2c4dd3d6dc389ca111858401.zip
gdb-539a52558fc24b1a2c4dd3d6dc389ca111858401.tar.gz
gdb-539a52558fc24b1a2c4dd3d6dc389ca111858401.tar.bz2
* sim/cris/c/pipe2.c: Adjust expected output.
(process): Don't write as much to the pipe as to trig the inordinate-amount test in the sim pipe machinery. Correct test of write return-value; check only that pipemax bytes were successfully written. For error-case, emit strerror as well. (main): Add a second read.
Diffstat (limited to 'sim')
-rw-r--r--sim/testsuite/ChangeLog9
-rw-r--r--sim/testsuite/sim/cris/c/pipe2.c35
2 files changed, 36 insertions, 8 deletions
diff --git a/sim/testsuite/ChangeLog b/sim/testsuite/ChangeLog
index 061b45d..34a29c6 100644
--- a/sim/testsuite/ChangeLog
+++ b/sim/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2006-09-30 Hans-Peter Nilsson <hp@axis.com>
+
+ * sim/cris/c/pipe2.c: Adjust expected output.
+ (process): Don't write as much to the pipe as to trig the
+ inordinate-amount test in the sim pipe machinery. Correct test of
+ write return-value; check only that pipemax bytes were
+ successfully written. For error-case, emit strerror as well.
+ (main): Add a second read.
+
2006-04-08 Hans-Peter Nilsson <hp@axis.com>
* sim/cris/hw/rv-n-cris/irq6.ms: New test.
diff --git a/sim/testsuite/sim/cris/c/pipe2.c b/sim/testsuite/sim/cris/c/pipe2.c
index ccb97f8..18ccf38 100644
--- a/sim/testsuite/sim/cris/c/pipe2.c
+++ b/sim/testsuite/sim/cris/c/pipe2.c
@@ -1,6 +1,6 @@
/* Check that closing a pipe with a nonempty buffer works.
#notarget: cris*-*-elf
-#output: got: a\nexit: 0\n
+#output: got: a\ngot: b\nexit: 0\n
*/
@@ -14,7 +14,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
-
+#include <string.h>
int pip[2];
int pipemax;
@@ -23,7 +23,8 @@ int
process (void *arg)
{
char *s = arg;
- char *buf = malloc (pipemax * 100);
+ int lots = pipemax + 256;
+ char *buf = malloc (lots);
int ret;
if (buf == NULL)
@@ -37,12 +38,17 @@ process (void *arg)
*buf = s[1];
- /* The second write should only successful for at most the PIPE_MAX
- part, but no error. */
- ret = write (pip[1], buf, pipemax * 10);
- if (ret != 0 && ret != pipemax - 1 && ret != pipemax)
+ /* The second write may or may not be successful for the whole
+ write, but should be successful for at least the pipemax part.
+ As linux/limits.h clamps PIPE_BUF to 4096, but the page size is
+ actually 8k, we can get away with that much. There should be no
+ error, though. Doing this on host shows that for
+ x86_64-unknown-linux-gnu (2.6.14-1.1656_FC4) pipemax * 10 can be
+ successfully written, perhaps for similar reasons. */
+ ret = write (pip[1], buf, lots);
+ if (ret < pipemax)
{
- fprintf (stderr, "ret: %d\n", ret);
+ fprintf (stderr, "ret: %d, %s, %d\n", ret, strerror (errno), pipemax);
fflush (0);
abort ();
}
@@ -104,6 +110,19 @@ main (void)
printf ("got: %c\n", buf[0]);
+ /* Need to read out something from the second write too before
+ closing, or the writer can get EPIPE. */
+ while ((retcode = read (pip[0], buf, 1)) == 0)
+ ;
+
+ if (retcode != 1)
+ {
+ fprintf (stderr, "Bad read 2: %d\n", retcode);
+ abort ();
+ }
+
+ printf ("got: %c\n", buf[0]);
+
if (close (pip[0]) != 0)
{
perror ("pip close");