From 62ef93d0443fc898182cb4089b7ece48f6e64ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 29 Jun 2003 18:12:48 +0000 Subject: [PATCH] Updated the pipe_test to also test buffering of writes to the pipe. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3735 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/apps/pipe_test.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/kernel/apps/pipe_test.c b/src/kernel/apps/pipe_test.c index 2e5cfbba9d..5947e59662 100644 --- a/src/kernel/apps/pipe_test.c +++ b/src/kernel/apps/pipe_test.c @@ -25,7 +25,11 @@ reader_func(void *data) // null-terminate, just in case printf("reader: (%d) %s\n", bytes, buffer); - if (!strcmp(buffer, "QUIT")) + if (buffer[0] == '2') { + puts("reader: wait a second and let the writer lead (the pipe has to be buffered)"); + snooze(1000000); + } + if (strstr(buffer, "QUIT")) break; } puts("reader quits"); @@ -41,11 +45,11 @@ writer_func(void *data) int i; const char *strings[] = { - "1. If you read this", - "2. the pipe implementation", - "3. seems to work", - "4. at least a bit", - "QUIT", + "1. If you read this ", + "2. the pipe implementation ", + "3. seems to work ", + "4. at least a bit ", + "5. QUIT", NULL}; for (i = 0; strings[i] != NULL; i++) { @@ -53,7 +57,7 @@ writer_func(void *data) // make sure the reader is waiting for us... // (needed by the current pipefs implementation :) - printf("writer: (%ld)\n", write(output, strings[i], strlen(strings[i]) + 1)); + printf("writer: (%ld)\n", write(output, strings[i], strlen(strings[i]))); } puts("writer quits");