public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
To: ltp-list@lists.sourceforge.net
Subject: [LTP] [PATCH] ltp setrlimit testcase patch for RLIMIT_FSIZE resource
Date: Mon, 16 Aug 2010 17:05:01 +0530	[thread overview]
Message-ID: <1281958501-17087-1-git-send-email-harsh@linux.vnet.ibm.com> (raw)

Current testcase for setrlimit resource RLIMIT_FSIZE
is using a global integer variable to communicate the number of
bytes from child to parent which is incorrect. This
has been corrected by introducing a pipe to transfer
this information from child to parent process.

Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
---
 testcases/kernel/syscalls/setrlimit/setrlimit01.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit01.c b/testcases/kernel/syscalls/setrlimit/setrlimit01.c
index 6952eb3..2bb1e9d 100644
--- a/testcases/kernel/syscalls/setrlimit/setrlimit01.c
+++ b/testcases/kernel/syscalls/setrlimit/setrlimit01.c
@@ -156,7 +156,11 @@ void test2()
 	 * an wired value!  So, it is essential to fflush the parent's
 	 * write buffer HERE
 	 */
+	int pipefd[2];
 	fflush(stdout);
+	if (pipe(pipefd) == -1) {
+		tst_brkm(TBROK | TERRNO, NULL, "pipe creation failed");
+	}
 
 	/*
 	 * Spawn a child process, and reduce the filesize to
@@ -170,6 +174,7 @@ void test2()
 	}
 
 	if (pid == 0) {
+		close(pipefd[0]); /* close unused read end */
 		rlim.rlim_cur = 10;
 		rlim.rlim_max = 10;
 		if ((setrlimit(RLIMIT_FSIZE, &rlim)) == -1) {
@@ -181,6 +186,11 @@ void test2()
 		}
 
 		if ((bytes = write(fd, buf, 26)) != 10) {
+			if (write(pipefd[1], &bytes, sizeof(bytes))
+				< sizeof(bytes)) {
+				perror("child: write to pipe failed");
+			}
+			close(pipefd[1]); /* EOF */
 			exit(3);
 		}
 		exit(0);	/* success */
@@ -202,6 +212,11 @@ void test2()
 		tst_resm(TFAIL, "creating testfile failed");
 		break;
 	case 3:
+		close(pipefd[1]); /* close unused write end */
+		if (read(pipefd[0], &bytes, sizeof(bytes)) < sizeof(bytes)) {
+			tst_resm(TFAIL, "parent: reading pipe failed");
+		}
+		close(pipefd[0]);
 		tst_resm(TFAIL, "setrlimit failed, expected "
 			 "10 got %d", bytes);
 		break;
-- 
1.7.1.1


------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

             reply	other threads:[~2010-08-16 11:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-16 11:35 Harsh Prateek Bora [this message]
2010-08-16 14:21 ` [LTP] [PATCH] ltp setrlimit testcase patch for RLIMIT_FSIZE resource Subrata Modak
2010-08-16 15:52   ` Garrett Cooper
2010-08-24 11:02     ` Subrata Modak

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=1281958501-17087-1-git-send-email-harsh@linux.vnet.ibm.com \
    --to=harsh@linux.vnet.ibm.com \
    --cc=ltp-list@lists.sourceforge.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox