summaryrefslogtreecommitdiff
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
commitd0c354039867e69de5f94b4d99c0479d8e8e54c9 (patch)
tree6cba9edc096c95bfc0f18c84f7de3594de671524 /sim
parentf9072872f6735d90f56ac59fe8f413b9ac580397 (diff)
downloadgdb-d0c354039867e69de5f94b4d99c0479d8e8e54c9.tar.gz
* 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 061b45dd20f..34a29c6fe06 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 ccb97f82d4e..18ccf38b9b1 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");