public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] LTP : Fix connectors event_generator program : gen_fork
@ 2009-09-08 15:49 Suzuki Poulose
  2009-09-09  5:11 ` Li Zefan
  0 siblings, 1 reply; 5+ messages in thread
From: Suzuki Poulose @ 2009-09-08 15:49 UTC (permalink / raw)
  To: ltp-list

[-- Attachment #1: Type: text/plain, Size: 827 bytes --]

Hi,

There is a testcase issue in the event_generator code. The gen_fork() is 
called to generate the fork event.

The child process prints the following message:

static inline void gen_fork(void)
{
         pid_t pid;
         int status;

         pid = fork();
         if (pid == 0) {
                 printf("fork parent: %d, child: %d\n", getppid(), 
getpid());
                 exit(0);
         } else if (pid < 0) {
                 fprintf(stderr, "fork() failed\n");
                 exit(1);
         }
}

Now the parent process just exits after this call. So, if the child 
doesn't get to run before parent exits, the child will see the ppid as 
1, that of INIT and this contradicts the actual data. Hence the test fails.

Attached patch fixes the issue. I have verified the same. Please apply.


Thanks

Suzuki


[-- Attachment #2: connectors-gen_fork-wait-for-child.diff --]
[-- Type: text/plain, Size: 796 bytes --]

Index: ltp/testcases/kernel/connectors/pec/event_generator.c
===================================================================
--- ltp.orig/testcases/kernel/connectors/pec/event_generator.c	2008-10-22 13:40:31.000000000 +0000
+++ ltp/testcases/kernel/connectors/pec/event_generator.c	2009-09-08 13:52:14.000000000 +0000
@@ -25,6 +25,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <pwd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
 #include "test.h"
 
 #define DEFAULT_EVENT_NUM       1
@@ -94,6 +97,7 @@
 static inline void gen_fork(void)
 {
 	pid_t pid;
+	int status;
 
 	pid = fork();
 	if (pid == 0) {
@@ -102,6 +106,8 @@
 	} else if (pid < 0) {
 		fprintf(stderr, "fork() failed\n");
 		exit(1);
+	} else {  /* Parent should wait for the child */
+		wait(&status);
 	}
 }
 

[-- Attachment #3: Type: text/plain, Size: 355 bytes --]

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2009-09-09 21:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-08 15:49 [LTP] LTP : Fix connectors event_generator program : gen_fork Suzuki Poulose
2009-09-09  5:11 ` Li Zefan
2009-09-09  5:18   ` Suzuki Poulose
2009-09-09  6:49     ` Subrata Modak
2009-09-09 21:31       ` Garrett Cooper

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