public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] setrlimit testcase fix
@ 2010-08-03 10:04 Harsh Prateek Bora
  2010-08-03 16:26 ` Garrett Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Harsh Prateek Bora @ 2010-08-03 10:04 UTC (permalink / raw)
  To: ltp-list

Current testcase for setrlimit for parameter RLIMIT_FSIZE
does not convey the number of bytes actually written from
child process to parent, as the child process writes to its
own copy of global variable. This patch introduces a pipe
to send the information from child to the parent process.

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

diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit01.c b/testcases/kernel/syscalls/setrlimit/setrlimit01.c
index 6952eb3..d8949c6 100644
--- a/testcases/kernel/syscalls/setrlimit/setrlimit01.c
+++ b/testcases/kernel/syscalls/setrlimit/setrlimit01.c
@@ -156,7 +156,12 @@ 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) {
+		perror("pipe");
+		exit(EXIT_FAILURE);
+	}
 
 	/*
 	 * Spawn a child process, and reduce the filesize to
@@ -170,6 +175,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 +187,8 @@ void test2()
 		}
 
 		if ((bytes = write(fd, buf, 26)) != 10) {
+			write(pipefd[1], &bytes, sizeof(bytes));
+			close(pipefd[1]); /* EOF */
 			exit(3);
 		}
 		exit(0);	/* success */
@@ -202,6 +210,9 @@ void test2()
 		tst_resm(TFAIL, "creating testfile failed");
 		break;
 	case 3:
+		close(pipefd[1]); /* close unused write end */
+		read(pipefd[0], &bytes, sizeof(bytes));
+		close(pipefd[0]);
 		tst_resm(TFAIL, "setrlimit failed, expected "
 			 "10 got %d", bytes);
 		break;
-- 
1.7.1.1


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] setrlimit testcase fix
  2010-08-03 10:04 [LTP] [PATCH] setrlimit testcase fix Harsh Prateek Bora
@ 2010-08-03 16:26 ` Garrett Cooper
  2010-08-05  9:59   ` Harsh Bora
  0 siblings, 1 reply; 4+ messages in thread
From: Garrett Cooper @ 2010-08-03 16:26 UTC (permalink / raw)
  To: Harsh Prateek Bora; +Cc: ltp-list

On Tue, Aug 3, 2010 at 3:04 AM, Harsh Prateek Bora
<harsh@linux.vnet.ibm.com> wrote:
> Current testcase for setrlimit for parameter RLIMIT_FSIZE
> does not convey the number of bytes actually written from
> child process to parent, as the child process writes to its
> own copy of global variable. This patch introduces a pipe
> to send the information from child to the parent process.

1. The style's a bit wonky, but that might be the fault with how the
original test was written.
2. You aren't checking how many bytes are actually being read/written
in your patch but assuming that the stream `bytes' is correctly
written each time ;)...

Thanks,
-Garrett

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] setrlimit testcase fix
  2010-08-03 16:26 ` Garrett Cooper
@ 2010-08-05  9:59   ` Harsh Bora
  2010-08-05 13:04     ` Garrett Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Harsh Bora @ 2010-08-05  9:59 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list

On 08/03/2010 09:56 PM, Garrett Cooper wrote:
> On Tue, Aug 3, 2010 at 3:04 AM, Harsh Prateek Bora
> <harsh@linux.vnet.ibm.com>  wrote:
>    
>> Current testcase for setrlimit for parameter RLIMIT_FSIZE
>> does not convey the number of bytes actually written from
>> child process to parent, as the child process writes to its
>> own copy of global variable. This patch introduces a pipe
>> to send the information from child to the parent process.
>>      
> 1. The style's a bit wonky, but that might be the fault with how the
> original test was written.
>    
So, what change do you suggest in the style? Can you be precise?
> 2. You aren't checking how many bytes are actually being read/written
> in your patch but assuming that the stream `bytes' is correctly
> written each time ;)...
>    
I hope you are talking about verifying expected number of bytes after 
reading/writing from pipe, shall do that.
> Thanks,
> -Garrett
>    


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] setrlimit testcase fix
  2010-08-05  9:59   ` Harsh Bora
@ 2010-08-05 13:04     ` Garrett Cooper
  0 siblings, 0 replies; 4+ messages in thread
From: Garrett Cooper @ 2010-08-05 13:04 UTC (permalink / raw)
  To: Harsh Bora; +Cc: ltp-list

On Aug 5, 2010, at 2:59 AM, Harsh Bora wrote:

> On 08/03/2010 09:56 PM, Garrett Cooper wrote:
>> On Tue, Aug 3, 2010 at 3:04 AM, Harsh Prateek Bora
>> <harsh@linux.vnet.ibm.com>  wrote:
>>   
>>> Current testcase for setrlimit for parameter RLIMIT_FSIZE
>>> does not convey the number of bytes actually written from
>>> child process to parent, as the child process writes to its
>>> own copy of global variable. This patch introduces a pipe
>>> to send the information from child to the parent process.
>>>     
>> 1. The style's a bit wonky, but that might be the fault with how the
>> original test was written.
>>   
> So, what change do you suggest in the style? Can you be precise?

Sorry... there's a mixture of tabs and spaces (based on the patch provided) and we need to use straight tabs like Linux does.

>> 2. You aren't checking how many bytes are actually being read/written
>> in your patch but assuming that the stream `bytes' is correctly
>> written each time ;)...
>>   
> I hope you are talking about verifying expected number of bytes after reading/writing from pipe, shall do that.

Yes. read(2) and write(2) pass back the number of bytes read and written from a file descriptor. It's a common mistake that others have made in many LTP testcases, assuming that alll reads and writes will be successful...

Thanks!
-Garrett
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-08-05 13:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-03 10:04 [LTP] [PATCH] setrlimit testcase fix Harsh Prateek Bora
2010-08-03 16:26 ` Garrett Cooper
2010-08-05  9:59   ` Harsh Bora
2010-08-05 13:04     ` Garrett Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox