All of lore.kernel.org
 help / color / mirror / Atom feed
From: sukadev-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org
To: serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org
Cc: Containers <containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>
Subject: [PATCH 4/4][cryo]: Test 5: Read/write using dup() of pipe fds
Date: Mon, 23 Jun 2008 20:34:54 -0700	[thread overview]
Message-ID: <20080624033454.GD27709@us.ibm.com> (raw)
In-Reply-To: <20080624033133.GA27649-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

From 121c33ebe1ae201d5bb051f9c76e3eaae29329bb Mon Sep 17 00:00:00 2001
From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Date: Sun, 22 Jun 2008 23:33:24 -0700
Subject: [PATCH] Test 5: Read/write using dup() of pipe fds

---
 tests/pipe.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/tests/pipe.c b/tests/pipe.c
index 5b04f46..47f5da6 100644
--- a/tests/pipe.c
+++ b/tests/pipe.c
@@ -16,12 +16,13 @@ char *test_descriptions[] = {
 	"Test continous reads/writes from pipe",
 	"Test non-consecutive pipe-fds",
 	"Test with read-fd > write-fd",
+	"Test with dup of pipe fds around"
 	"Test with read-fd/write-fd swapped",
 	"Test with all-fds in use",
 	"Test with all-fds in use for pipes",
 };
 
-static int last_num = 4;
+static int last_num = 5;
 usage(char *argv[])
 {
 	int i;
@@ -145,13 +146,13 @@ int read_write_pipe(int *testfdsp, int close_unused)
 		exit(1);
 	}
 
+	read_fd = tmpfds[0];
+	write_fd = tmpfds[1];
 	if (testfdsp) {
 		reset_pipe_fds(tmpfds, testfdsp, close_unused);
+		/* read from dup'd fds even if main ones are open */
 		read_fd = testfdsp[0];
 		write_fd = testfdsp[1];
-	} else {
-		read_fd = tmpfds[0];
-		write_fd = tmpfds[1];
 	}
 
 	printf("read_fd %d, write_fd %d\n", read_fd, write_fd);
@@ -193,7 +194,7 @@ int read_write_pipe(int *testfdsp, int close_unused)
 		}
 	}
 
-	if (strncmp(wbuf, rbuf, strlen(wbufp))) {
+	if (strncmp(wbuf, rbuf, strlen(wbuf))) {
 		printf("Wrote: %s\n", wbuf);
 		printf("Read : %s\n", rbuf);
 		printf("Test FAILED\n");
@@ -214,6 +215,13 @@ static void test4()
 	read_write_pipe(tmpfds, 1);
 }
 
+static void test5()
+{
+	int tmpfds[2] = { 172, 101 };
+
+	read_write_pipe(tmpfds, 0);
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -238,6 +246,7 @@ main(int argc, char *argv[])
 	case 2: test2(); break;
 	case 3: test3(); break;
 	case 4: test4(); break;
+	case 5: test5(); break;
 	default:
 		printf("Unsupported test case %d\n", tc_num);
 		usage(argv);
-- 
1.5.2.5

      parent reply	other threads:[~2008-06-24  3:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-24  3:31 [PATCH 0/4][cryo] Test pipes sukadev-r/Jw6+rmf7HQT0dZR+AlfA
     [not found] ` <20080624033133.GA27649-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-06-24  3:32   ` [PATCH 1/4]: Support multiple pipe test cases sukadev-r/Jw6+rmf7HQT0dZR+AlfA
2008-06-24  3:33   ` [PATCH 2/4]: Test3: continous read/write to pipe sukadev-r/Jw6+rmf7HQT0dZR+AlfA
2008-06-24  3:34   ` [PATCH 3/4][cryo]: Test 4: Non-consecutive pipe fds sukadev-r/Jw6+rmf7HQT0dZR+AlfA
2008-06-24  3:34   ` sukadev-r/Jw6+rmf7HQT0dZR+AlfA [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080624033454.GD27709@us.ibm.com \
    --to=sukadev-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.