public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] wait/wait02: cleanup
@ 2014-06-20  7:19 Zeng Linggang
  2014-06-20  7:20 ` [LTP] [PATCH 2/2] wait/wait01.c: Add ECHILD test Zeng Linggang
  2014-06-20  9:35 ` [LTP] [PATCH 1/2] wait/wait02: cleanup Jan Stancek
  0 siblings, 2 replies; 7+ messages in thread
From: Zeng Linggang @ 2014-06-20  7:19 UTC (permalink / raw)
  To: ltp-list

* Delete some useless commtents and variable.

* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/wait/wait02.c | 166 ++++++--------------------------
 1 file changed, 32 insertions(+), 134 deletions(-)

diff --git a/testcases/kernel/syscalls/wait/wait02.c b/testcases/kernel/syscalls/wait/wait02.c
index a95213d..ef3bf71 100644
--- a/testcases/kernel/syscalls/wait/wait02.c
+++ b/testcases/kernel/syscalls/wait/wait02.c
@@ -1,5 +1,7 @@
 /*
  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
+ *    AUTHOR		: William Roske
+ *    CO-PILOT		: Dave Fenner
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -30,84 +32,6 @@
  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
  *
  */
-/* $Id: wait02.c,v 1.7 2009/10/26 14:55:48 subrata_modak Exp $ */
-/**********************************************************
- *
- *    OS Test - Silicon Graphics, Inc.
- *
- *    TEST IDENTIFIER	: wait02
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Basic test for wait(2)
- *
- *    PARENT DOCUMENT	: usctpl01
- *
- *    TEST CASE TOTAL	: 1
- *
- *    WALL CLOCK TIME	: 1
- *
- *    CPU TYPES		: ALL
- *
- *    AUTHOR		: William Roske
- *
- *    CO-PILOT		: Dave Fenner
- *
- *    DATE STARTED	: 03/30/92
- *
- *    INITIAL RELEASE	: UNICOS 7.0
- *
- *    TEST CASES
- *
- *	1.) wait(2) returns...(See Description)
- *
- *    INPUT SPECIFICATIONS
- *	The standard options for system call tests are accepted.
- *	(See the parse_opts(3) man page).
- *
- *    OUTPUT SPECIFICATIONS
- *
- *    DURATION
- *	Terminates - with frequency and infinite modes.
- *
- *    SIGNALS
- *	Uses SIGUSR1 to pause before test if option set.
- *	(See the parse_opts(3) man page).
- *
- *    RESOURCES
- *	None
- *
- *    ENVIRONMENTAL NEEDS
- *      No run-time environmental needs.
- *
- *    SPECIAL PROCEDURAL REQUIREMENTS
- *	None
- *
- *    INTERCASE DEPENDENCIES
- *	None
- *
- *    DETAILED DESCRIPTION
- *	This is a Phase I test for the wait(2) system call.  It is intended
- *	to provide a limited exposure of the system call, for now.  It
- *	should/will be extended when full functional tests are written for
- *	wait(2).
- *
- *	Setup:
- *	  Setup signal handling.
- *	  Pause for SIGUSR1 if option specified.
- *
- *	Test:
- *	 Loop if the proper options are given.
- *	  Execute system call
- *	  Check return code, if system call failed (return=-1)
- *		Log the errno and Issue a FAIL message.
- *	  Otherwise, Issue a PASS message.
- *
- *	Cleanup:
- *	  Print errno log and/or timing stats if options given
- *
- *
- *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <errno.h>
 #include <string.h>
@@ -118,94 +42,68 @@
 #include "test.h"
 #include "usctest.h"
 
-void setup();
-void cleanup();
+static void setup(void);
+static void cleanup(void);
 
 char *TCID = "wait02";
 int TST_TOTAL = 1;
 
-int exp_enos[] = { 0, 0 };
+static int exp_enos[] = { 0, 0 };
+
+static int fork_pid, ret_code;
 
-int fork_pid, ret_code;
-void trapper();
+static void wait_verify(void);
 
 int main(int ac, char **av)
 {
 	int lc;
 	const char *msg;
 
-    /***************************************************************
-     * parse standard options
-     ***************************************************************/
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 
-    /***************************************************************
-     * perform global setup for test
-     ***************************************************************/
 	setup();
 
-	/* set the expected errnos... */
 	TEST_EXP_ENOS(exp_enos);
 
-    /***************************************************************
-     * check looping state if -c option given
-     ***************************************************************/
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
 		tst_count = 0;
-
-		/* create a child to wait for */
-		if ((fork_pid = FORK_OR_VFORK()) == -1) {
-			tst_brkm(TBROK, cleanup,
-				 "fork() Failure. errno=%d : %s", errno,
-				 strerror(errno));
-		} else if (fork_pid == 0) {
-			/* Child, sleep a second then exit */
-			sleep(1);
-			exit(1);
-		}
-
-		/* Parent, wait for child to die */
-		TEST(wait(&ret_code));
-
-		/* check return code */
-		if (TEST_RETURN == -1) {
-			TEST_ERROR_LOG(TEST_ERRNO);
-			tst_resm(TFAIL, "wait(1) Failed, errno=%d : %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-		} else {
-			tst_resm(TPASS, "wait(&ret_code) returned %ld",
-				 TEST_RETURN);
-		}
+		wait_verify();
 	}
 
 	cleanup();
 	tst_exit();
 }
 
-/***************************************************************
- * setup() - performs all ONE TIME setup for this test.
- ***************************************************************/
-void setup(void)
+static void setup(void)
 {
-
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 
 	TEST_PAUSE;
+}
+
+static void wait_verify(void)
+{
+	fork_pid = FORK_OR_VFORK();
+	if (fork_pid == -1) {
+		tst_brkm(TBROK | TERRNO, cleanup, "fork() Failure");
+	} else if (fork_pid == 0) {
+		sleep(1);
+		exit(1);
+	}
+
+	TEST(wait(&ret_code));
 
+	if (TEST_RETURN == -1) {
+		TEST_ERROR_LOG(TEST_ERRNO);
+		tst_resm(TFAIL | TTERRNO, "wait(1) Failed");
+	} else {
+		tst_resm(TPASS, "wait(&ret_code) returned %ld", TEST_RETURN);
+	}
 }
 
-/***************************************************************
- * cleanup() - performs all ONE TIME cleanup for this test at
- *		completion or premature exit.
- ***************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
-	/*
-	 * print timing stats if that option was specified.
-	 * print errno log if that option was specified.
-	 */
 	TEST_CLEANUP;
-
 }
-- 
1.9.3




------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 2/2] wait/wait01.c: Add ECHILD test
  2014-06-20  7:19 [LTP] [PATCH 1/2] wait/wait02: cleanup Zeng Linggang
@ 2014-06-20  7:20 ` Zeng Linggang
  2014-06-20  9:35 ` [LTP] [PATCH 1/2] wait/wait02: cleanup Jan Stancek
  1 sibling, 0 replies; 7+ messages in thread
From: Zeng Linggang @ 2014-06-20  7:20 UTC (permalink / raw)
  To: ltp-list

Add ECHILD test for wait(2)

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 runtest/ltplite                         |  1 +
 runtest/stress.part3                    |  1 +
 runtest/syscalls                        |  1 +
 testcases/kernel/syscalls/.gitignore    |  1 +
 testcases/kernel/syscalls/wait/wait01.c | 85 +++++++++++++++++++++++++++++++++
 5 files changed, 89 insertions(+)
 create mode 100644 testcases/kernel/syscalls/wait/wait01.c

diff --git a/runtest/ltplite b/runtest/ltplite
index 939ea35..37e3119 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -979,6 +979,7 @@ vfork02 vfork02
 vhangup01 vhangup01
 vhangup02 vhangup02
 
+wait01 wait01
 wait02 wait02
 
 wait401 wait401
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index 2b05363..254f77d 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -857,6 +857,7 @@ vfork02 vfork02
 vhangup01 vhangup01
 vhangup02 vhangup02
 
+wait01 wait01
 wait02 wait02
 
 wait401 wait401
diff --git a/runtest/syscalls b/runtest/syscalls
index adefa49..fd22b3c 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1325,6 +1325,7 @@ vhangup02 vhangup02
 #vmsplice test cases
 vmsplice01 vmsplice01
 
+wait01 wait01
 wait02 wait02
 
 wait401 wait401
diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index 252e3c8..7fbe226 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -1005,6 +1005,7 @@
 /vhangup/vhangup01
 /vhangup/vhangup02
 /vmsplice/vmsplice01
+/wait/wait01
 /wait/wait02
 /wait4/wait401
 /wait4/wait402
diff --git a/testcases/kernel/syscalls/wait/wait01.c b/testcases/kernel/syscalls/wait/wait01.c
new file mode 100644
index 0000000..69d91ae
--- /dev/null
+++ b/testcases/kernel/syscalls/wait/wait01.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2014 Fujitsu Ltd.
+ * Author: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+/*
+ * Test Description:
+ *  Verify that,
+ *	The calling process does not have any unwaited-for children,
+ *	ECHILD would return.
+ */
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "test.h"
+#include "usctest.h"
+
+char *TCID = "wait01";
+int TST_TOTAL = 1;
+static void setup(void);
+static void wait_verify(void);
+static void cleanup(void);
+
+int main(int argc, char **argv)
+{
+	int lc;
+	const char *msg;
+
+	msg = parse_opts(argc, argv, NULL, NULL);
+	if (msg != NULL)
+		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+	setup();
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		tst_count = 0;
+		wait_verify();
+	}
+
+	cleanup();
+	tst_exit();
+}
+
+static void setup(void)
+{
+	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+	TEST_PAUSE;
+}
+
+static void wait_verify(void)
+{
+	TEST(wait(NULL));
+
+	if (TEST_RETURN != -1) {
+		tst_resm(TFAIL | TTERRNO, "wait failed unexpectedly");
+		return;
+	}
+
+	if (TEST_ERRNO == ECHILD) {
+		tst_resm(TPASS | TTERRNO, "wait failed as expected");
+	} else {
+		tst_resm(TFAIL | TTERRNO,
+			 "wait failed unexpectedly; expected: %d - %s",
+			 ECHILD, strerror(ECHILD));
+	}
+}
+
+static void cleanup(void)
+{
+	TEST_CLEANUP;
+}
-- 
1.9.3




------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/2] wait/wait02: cleanup
  2014-06-20  7:19 [LTP] [PATCH 1/2] wait/wait02: cleanup Zeng Linggang
  2014-06-20  7:20 ` [LTP] [PATCH 2/2] wait/wait01.c: Add ECHILD test Zeng Linggang
@ 2014-06-20  9:35 ` Jan Stancek
  2014-06-23  2:27   ` Zeng Linggang
  1 sibling, 1 reply; 7+ messages in thread
From: Jan Stancek @ 2014-06-20  9:35 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list





----- Original Message -----
> From: "Zeng Linggang" <zenglg.jy@cn.fujitsu.com>
> To: "ltp-list" <ltp-list@lists.sourceforge.net>
> Sent: Friday, 20 June, 2014 9:19:56 AM
> Subject: [LTP] [PATCH 1/2] wait/wait02: cleanup
> 
> * Delete some useless commtents and variable.
> 
> * Some cleanup.
> 
> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
> ---
>  testcases/kernel/syscalls/wait/wait02.c | 166
>  ++++++--------------------------
>  1 file changed, 32 insertions(+), 134 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/wait/wait02.c
> b/testcases/kernel/syscalls/wait/wait02.c
> index a95213d..ef3bf71 100644
> --- a/testcases/kernel/syscalls/wait/wait02.c
> +++ b/testcases/kernel/syscalls/wait/wait02.c
> @@ -1,5 +1,7 @@
>  /*
>   * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
> + *    AUTHOR		: William Roske
> + *    CO-PILOT		: Dave Fenner
>   *
>   * This program is free software; you can redistribute it and/or modify it
>   * under the terms of version 2 of the GNU General Public License as
> @@ -30,84 +32,6 @@
>   * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
>   *
>   */
> -/* $Id: wait02.c,v 1.7 2009/10/26 14:55:48 subrata_modak Exp $ */
> -/**********************************************************
> - *
> - *    OS Test - Silicon Graphics, Inc.
> - *
> - *    TEST IDENTIFIER	: wait02
> - *
> - *    EXECUTED BY	: anyone
> - *
> - *    TEST TITLE	: Basic test for wait(2)
> - *
> - *    PARENT DOCUMENT	: usctpl01
> - *
> - *    TEST CASE TOTAL	: 1
> - *
> - *    WALL CLOCK TIME	: 1
> - *
> - *    CPU TYPES		: ALL
> - *
> - *    AUTHOR		: William Roske
> - *
> - *    CO-PILOT		: Dave Fenner
> - *
> - *    DATE STARTED	: 03/30/92
> - *
> - *    INITIAL RELEASE	: UNICOS 7.0
> - *
> - *    TEST CASES
> - *
> - *	1.) wait(2) returns...(See Description)
> - *
> - *    INPUT SPECIFICATIONS
> - *	The standard options for system call tests are accepted.
> - *	(See the parse_opts(3) man page).
> - *
> - *    OUTPUT SPECIFICATIONS
> - *
> - *    DURATION
> - *	Terminates - with frequency and infinite modes.
> - *
> - *    SIGNALS
> - *	Uses SIGUSR1 to pause before test if option set.
> - *	(See the parse_opts(3) man page).
> - *
> - *    RESOURCES
> - *	None
> - *
> - *    ENVIRONMENTAL NEEDS
> - *      No run-time environmental needs.
> - *
> - *    SPECIAL PROCEDURAL REQUIREMENTS
> - *	None
> - *
> - *    INTERCASE DEPENDENCIES
> - *	None
> - *
> - *    DETAILED DESCRIPTION
> - *	This is a Phase I test for the wait(2) system call.  It is intended
> - *	to provide a limited exposure of the system call, for now.  It
> - *	should/will be extended when full functional tests are written for
> - *	wait(2).
> - *
> - *	Setup:
> - *	  Setup signal handling.
> - *	  Pause for SIGUSR1 if option specified.
> - *
> - *	Test:
> - *	 Loop if the proper options are given.
> - *	  Execute system call
> - *	  Check return code, if system call failed (return=-1)
> - *		Log the errno and Issue a FAIL message.
> - *	  Otherwise, Issue a PASS message.
> - *
> - *	Cleanup:
> - *	  Print errno log and/or timing stats if options given
> - *
> - *
> - *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
>  
>  #include <errno.h>
>  #include <string.h>
> @@ -118,94 +42,68 @@
>  #include "test.h"
>  #include "usctest.h"
>  
> -void setup();
> -void cleanup();
> +static void setup(void);
> +static void cleanup(void);
>  
>  char *TCID = "wait02";
>  int TST_TOTAL = 1;
>  
> -int exp_enos[] = { 0, 0 };
> +static int exp_enos[] = { 0, 0 };

This looks like it can be removed along with TEST_EXP_ENOS().

> +
> +static int fork_pid, ret_code;

These can be local variables.

>  
> -int fork_pid, ret_code;
> -void trapper();
> +static void wait_verify(void);
>  
>  int main(int ac, char **av)
>  {
>  	int lc;
>  	const char *msg;
>  
> -    /***************************************************************
> -     * parse standard options
> -     ***************************************************************/
> -	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
> +	msg = parse_opts(ac, av, NULL, NULL);
> +	if (msg != NULL)
>  		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
>  
> -    /***************************************************************
> -     * perform global setup for test
> -     ***************************************************************/
>  	setup();
>  
> -	/* set the expected errnos... */
>  	TEST_EXP_ENOS(exp_enos);
>  
> -    /***************************************************************
> -     * check looping state if -c option given
> -     ***************************************************************/
>  	for (lc = 0; TEST_LOOPING(lc); lc++) {
> -
>  		tst_count = 0;
> -
> -		/* create a child to wait for */
> -		if ((fork_pid = FORK_OR_VFORK()) == -1) {
> -			tst_brkm(TBROK, cleanup,
> -				 "fork() Failure. errno=%d : %s", errno,
> -				 strerror(errno));
> -		} else if (fork_pid == 0) {
> -			/* Child, sleep a second then exit */
> -			sleep(1);
> -			exit(1);
> -		}
> -
> -		/* Parent, wait for child to die */
> -		TEST(wait(&ret_code));
> -
> -		/* check return code */
> -		if (TEST_RETURN == -1) {
> -			TEST_ERROR_LOG(TEST_ERRNO);
> -			tst_resm(TFAIL, "wait(1) Failed, errno=%d : %s",
> -				 TEST_ERRNO, strerror(TEST_ERRNO));
> -		} else {
> -			tst_resm(TPASS, "wait(&ret_code) returned %ld",
> -				 TEST_RETURN);
> -		}
> +		wait_verify();
>  	}
>  
>  	cleanup();
>  	tst_exit();
>  }
>  
> -/***************************************************************
> - * setup() - performs all ONE TIME setup for this test.
> - ***************************************************************/
> -void setup(void)
> +static void setup(void)
>  {
> -
>  	tst_sig(FORK, DEF_HANDLER, cleanup);
>  
>  	TEST_PAUSE;
> +}
> +
> +static void wait_verify(void)
> +{
> +	fork_pid = FORK_OR_VFORK();
> +	if (fork_pid == -1) {
> +		tst_brkm(TBROK | TERRNO, cleanup, "fork() Failure");
> +	} else if (fork_pid == 0) {
> +		sleep(1);
> +		exit(1);
> +	}
> +
> +	TEST(wait(&ret_code));

I know this wasn't in original code, but I suggest to add some check for
ret_code too (WIFEXITED() && WEXITSTATUS() == 1).

Regards,
Jan

>  
> +	if (TEST_RETURN == -1) {
> +		TEST_ERROR_LOG(TEST_ERRNO);
> +		tst_resm(TFAIL | TTERRNO, "wait(1) Failed");
> +	} else {
> +		tst_resm(TPASS, "wait(&ret_code) returned %ld", TEST_RETURN);
> +	}
>  }
>  
> -/***************************************************************
> - * cleanup() - performs all ONE TIME cleanup for this test at
> - *		completion or premature exit.
> - ***************************************************************/
> -void cleanup(void)
> +static void cleanup(void)
>  {
> -	/*
> -	 * print timing stats if that option was specified.
> -	 * print errno log if that option was specified.
> -	 */
>  	TEST_CLEANUP;
> -
>  }
> --
> 1.9.3
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
> Find What Matters Most in Your Big Data with HPCC Systems
> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
> http://p.sf.net/sfu/hpccsystems
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/2] wait/wait02: cleanup
  2014-06-20  9:35 ` [LTP] [PATCH 1/2] wait/wait02: cleanup Jan Stancek
@ 2014-06-23  2:27   ` Zeng Linggang
  2014-06-23  2:37     ` [LTP] [PATCH v2 " Zeng Linggang
  2014-06-23  2:38     ` [LTP] [PATCH v2 2/2] wait/wait01.c: Add ECHILD test Zeng Linggang
  0 siblings, 2 replies; 7+ messages in thread
From: Zeng Linggang @ 2014-06-23  2:27 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp-list

On Fri, 2014-06-20 at 05:35 -0400, Jan Stancek wrote:
> >  int TST_TOTAL = 1;
> >  
> > -int exp_enos[] = { 0, 0 };
> > +static int exp_enos[] = { 0, 0 };
> 
> This looks like it can be removed along with TEST_EXP_ENOS().
> 

Got it.

> > +
> > +static int fork_pid, ret_code;
> 
> These can be local variables.
> 

Yeah, these should be local variables.

> > +
> > +	TEST(wait(&ret_code));
> 
> I know this wasn't in original code, but I suggest to add some check for
> ret_code too (WIFEXITED() && WEXITSTATUS() == 1).
> 

OK. I will add them.
And thanks for your review.

Best regards,
Zeng

> Regards,
> Jan
> 
> >  
> > +	if (TEST_RETURN == -1) {
> > +		TEST_ERROR_LOG(TEST_ERRNO);
> > +		tst_resm(TFAIL | TTERRNO, "wait(1) Failed");
> > +	} else {
> > +		tst_resm(TPASS, "wait(&ret_code) returned %ld", TEST_RETURN);
> > +	}
> >  }
> >  
> > -/***************************************************************
> > - * cleanup() - performs all ONE TIME cleanup for this test at
> > - *		completion or premature exit.
> > - ***************************************************************/
> > -void cleanup(void)
> > +static void cleanup(void)
> >  {
> > -	/*
> > -	 * print timing stats if that option was specified.
> > -	 * print errno log if that option was specified.
> > -	 */
> >  	TEST_CLEANUP;
> > -
> >  }
> > --
> > 1.9.3
> > 
> > 
> > 
> > 
> > ------------------------------------------------------------------------------
> > HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
> > Find What Matters Most in Your Big Data with HPCC Systems
> > Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
> > Leverages Graph Analysis for Fast Processing & Easy Data Exploration
> > http://p.sf.net/sfu/hpccsystems
> > _______________________________________________
> > Ltp-list mailing list
> > Ltp-list@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/ltp-list
> > 



------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH v2 1/2] wait/wait02: cleanup
  2014-06-23  2:27   ` Zeng Linggang
@ 2014-06-23  2:37     ` Zeng Linggang
  2014-06-23  7:00       ` Jan Stancek
  2014-06-23  2:38     ` [LTP] [PATCH v2 2/2] wait/wait01.c: Add ECHILD test Zeng Linggang
  1 sibling, 1 reply; 7+ messages in thread
From: Zeng Linggang @ 2014-06-23  2:37 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp-list

* Delete some useless commtents and variable.

* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/wait/wait02.c | 171 +++++++-------------------------
 1 file changed, 34 insertions(+), 137 deletions(-)

diff --git a/testcases/kernel/syscalls/wait/wait02.c b/testcases/kernel/syscalls/wait/wait02.c
index a95213d..0cbcd48 100644
--- a/testcases/kernel/syscalls/wait/wait02.c
+++ b/testcases/kernel/syscalls/wait/wait02.c
@@ -1,5 +1,7 @@
 /*
  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
+ *    AUTHOR		: William Roske
+ *    CO-PILOT		: Dave Fenner
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -30,84 +32,6 @@
  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
  *
  */
-/* $Id: wait02.c,v 1.7 2009/10/26 14:55:48 subrata_modak Exp $ */
-/**********************************************************
- *
- *    OS Test - Silicon Graphics, Inc.
- *
- *    TEST IDENTIFIER	: wait02
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Basic test for wait(2)
- *
- *    PARENT DOCUMENT	: usctpl01
- *
- *    TEST CASE TOTAL	: 1
- *
- *    WALL CLOCK TIME	: 1
- *
- *    CPU TYPES		: ALL
- *
- *    AUTHOR		: William Roske
- *
- *    CO-PILOT		: Dave Fenner
- *
- *    DATE STARTED	: 03/30/92
- *
- *    INITIAL RELEASE	: UNICOS 7.0
- *
- *    TEST CASES
- *
- *	1.) wait(2) returns...(See Description)
- *
- *    INPUT SPECIFICATIONS
- *	The standard options for system call tests are accepted.
- *	(See the parse_opts(3) man page).
- *
- *    OUTPUT SPECIFICATIONS
- *
- *    DURATION
- *	Terminates - with frequency and infinite modes.
- *
- *    SIGNALS
- *	Uses SIGUSR1 to pause before test if option set.
- *	(See the parse_opts(3) man page).
- *
- *    RESOURCES
- *	None
- *
- *    ENVIRONMENTAL NEEDS
- *      No run-time environmental needs.
- *
- *    SPECIAL PROCEDURAL REQUIREMENTS
- *	None
- *
- *    INTERCASE DEPENDENCIES
- *	None
- *
- *    DETAILED DESCRIPTION
- *	This is a Phase I test for the wait(2) system call.  It is intended
- *	to provide a limited exposure of the system call, for now.  It
- *	should/will be extended when full functional tests are written for
- *	wait(2).
- *
- *	Setup:
- *	  Setup signal handling.
- *	  Pause for SIGUSR1 if option specified.
- *
- *	Test:
- *	 Loop if the proper options are given.
- *	  Execute system call
- *	  Check return code, if system call failed (return=-1)
- *		Log the errno and Issue a FAIL message.
- *	  Otherwise, Issue a PASS message.
- *
- *	Cleanup:
- *	  Print errno log and/or timing stats if options given
- *
- *
- *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <errno.h>
 #include <string.h>
@@ -118,94 +42,67 @@
 #include "test.h"
 #include "usctest.h"
 
-void setup();
-void cleanup();
+static void setup(void);
+static void cleanup(void);
 
 char *TCID = "wait02";
 int TST_TOTAL = 1;
 
-int exp_enos[] = { 0, 0 };
-
-int fork_pid, ret_code;
-void trapper();
+static void wait_verify(void);
 
 int main(int ac, char **av)
 {
 	int lc;
 	const char *msg;
 
-    /***************************************************************
-     * parse standard options
-     ***************************************************************/
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 
-    /***************************************************************
-     * perform global setup for test
-     ***************************************************************/
 	setup();
 
-	/* set the expected errnos... */
-	TEST_EXP_ENOS(exp_enos);
-
-    /***************************************************************
-     * check looping state if -c option given
-     ***************************************************************/
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
 		tst_count = 0;
-
-		/* create a child to wait for */
-		if ((fork_pid = FORK_OR_VFORK()) == -1) {
-			tst_brkm(TBROK, cleanup,
-				 "fork() Failure. errno=%d : %s", errno,
-				 strerror(errno));
-		} else if (fork_pid == 0) {
-			/* Child, sleep a second then exit */
-			sleep(1);
-			exit(1);
-		}
-
-		/* Parent, wait for child to die */
-		TEST(wait(&ret_code));
-
-		/* check return code */
-		if (TEST_RETURN == -1) {
-			TEST_ERROR_LOG(TEST_ERRNO);
-			tst_resm(TFAIL, "wait(1) Failed, errno=%d : %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-		} else {
-			tst_resm(TPASS, "wait(&ret_code) returned %ld",
-				 TEST_RETURN);
-		}
+		wait_verify();
 	}
 
 	cleanup();
 	tst_exit();
 }
 
-/***************************************************************
- * setup() - performs all ONE TIME setup for this test.
- ***************************************************************/
-void setup(void)
+static void setup(void)
 {
-
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 
 	TEST_PAUSE;
+}
 
+static void wait_verify(void)
+{
+	int fork_pid, status, exit_child = 1;
+
+	fork_pid = FORK_OR_VFORK();
+	if (fork_pid == -1) {
+		tst_brkm(TBROK | TERRNO, cleanup, "fork() Failure");
+	} else if (fork_pid == 0) {
+		sleep(1);
+		exit(exit_child);
+	}
+
+	TEST(wait(&status));
+
+	if (TEST_RETURN == -1) {
+		tst_resm(TFAIL | TTERRNO, "wait(1) Failed");
+	} else if (WIFEXITED(status) && WEXITSTATUS(status) == 1) {
+		tst_resm(TPASS, "wait(&status) returned %ld", TEST_RETURN);
+	} else {
+		tst_resm(TFAIL,
+			 "wait(1) Failed, exit_child - 0x%x, status - 0x%x",
+			 exit_child, status);
+	}
 }
 
-/***************************************************************
- * cleanup() - performs all ONE TIME cleanup for this test at
- *		completion or premature exit.
- ***************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
-	/*
-	 * print timing stats if that option was specified.
-	 * print errno log if that option was specified.
-	 */
 	TEST_CLEANUP;
-
 }
-- 
1.9.3




------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH v2 2/2] wait/wait01.c: Add ECHILD test
  2014-06-23  2:27   ` Zeng Linggang
  2014-06-23  2:37     ` [LTP] [PATCH v2 " Zeng Linggang
@ 2014-06-23  2:38     ` Zeng Linggang
  1 sibling, 0 replies; 7+ messages in thread
From: Zeng Linggang @ 2014-06-23  2:38 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp-list

Add ECHILD test for wait(2)

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 runtest/ltplite                         |  1 +
 runtest/stress.part3                    |  1 +
 runtest/syscalls                        |  1 +
 testcases/kernel/syscalls/.gitignore    |  1 +
 testcases/kernel/syscalls/wait/wait01.c | 85 +++++++++++++++++++++++++++++++++
 5 files changed, 89 insertions(+)
 create mode 100644 testcases/kernel/syscalls/wait/wait01.c

diff --git a/runtest/ltplite b/runtest/ltplite
index 939ea35..37e3119 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -979,6 +979,7 @@ vfork02 vfork02
 vhangup01 vhangup01
 vhangup02 vhangup02
 
+wait01 wait01
 wait02 wait02
 
 wait401 wait401
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index 2b05363..254f77d 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -857,6 +857,7 @@ vfork02 vfork02
 vhangup01 vhangup01
 vhangup02 vhangup02
 
+wait01 wait01
 wait02 wait02
 
 wait401 wait401
diff --git a/runtest/syscalls b/runtest/syscalls
index adefa49..fd22b3c 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1325,6 +1325,7 @@ vhangup02 vhangup02
 #vmsplice test cases
 vmsplice01 vmsplice01
 
+wait01 wait01
 wait02 wait02
 
 wait401 wait401
diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index 252e3c8..7fbe226 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -1005,6 +1005,7 @@
 /vhangup/vhangup01
 /vhangup/vhangup02
 /vmsplice/vmsplice01
+/wait/wait01
 /wait/wait02
 /wait4/wait401
 /wait4/wait402
diff --git a/testcases/kernel/syscalls/wait/wait01.c b/testcases/kernel/syscalls/wait/wait01.c
new file mode 100644
index 0000000..69d91ae
--- /dev/null
+++ b/testcases/kernel/syscalls/wait/wait01.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2014 Fujitsu Ltd.
+ * Author: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+/*
+ * Test Description:
+ *  Verify that,
+ *	The calling process does not have any unwaited-for children,
+ *	ECHILD would return.
+ */
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "test.h"
+#include "usctest.h"
+
+char *TCID = "wait01";
+int TST_TOTAL = 1;
+static void setup(void);
+static void wait_verify(void);
+static void cleanup(void);
+
+int main(int argc, char **argv)
+{
+	int lc;
+	const char *msg;
+
+	msg = parse_opts(argc, argv, NULL, NULL);
+	if (msg != NULL)
+		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+	setup();
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		tst_count = 0;
+		wait_verify();
+	}
+
+	cleanup();
+	tst_exit();
+}
+
+static void setup(void)
+{
+	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+	TEST_PAUSE;
+}
+
+static void wait_verify(void)
+{
+	TEST(wait(NULL));
+
+	if (TEST_RETURN != -1) {
+		tst_resm(TFAIL | TTERRNO, "wait failed unexpectedly");
+		return;
+	}
+
+	if (TEST_ERRNO == ECHILD) {
+		tst_resm(TPASS | TTERRNO, "wait failed as expected");
+	} else {
+		tst_resm(TFAIL | TTERRNO,
+			 "wait failed unexpectedly; expected: %d - %s",
+			 ECHILD, strerror(ECHILD));
+	}
+}
+
+static void cleanup(void)
+{
+	TEST_CLEANUP;
+}
-- 
1.9.3




------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH v2 1/2] wait/wait02: cleanup
  2014-06-23  2:37     ` [LTP] [PATCH v2 " Zeng Linggang
@ 2014-06-23  7:00       ` Jan Stancek
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Stancek @ 2014-06-23  7:00 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list





----- Original Message -----
> From: "Zeng Linggang" <zenglg.jy@cn.fujitsu.com>
> To: "Jan Stancek" <jstancek@redhat.com>
> Cc: "ltp-list" <ltp-list@lists.sourceforge.net>
> Sent: Monday, 23 June, 2014 4:37:45 AM
> Subject: [PATCH v2 1/2] wait/wait02: cleanup
> 
> * Delete some useless commtents and variable.
> 
> * Some cleanup.
> 
> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>

Series pushed with these changes:

1. print TEST_RETURN in wait01.c if it has unexpected value:
        if (TEST_RETURN != -1) {
-               tst_resm(TFAIL | TTERRNO, "wait failed unexpectedly");
+               tst_resm(TFAIL | TTERRNO, "wait failed unexpectedly: %ld",
+                       TEST_RETURN);
                return;

2. compare exit status code with exit_child in wait02.c:
-       } else if (WIFEXITED(status) && WEXITSTATUS(status) == 1) {
+       } else if (WIFEXITED(status) && WEXITSTATUS(status) == exit_child) {

3. small typo fix in commit message.

Regards,
Jan

> ---
>  testcases/kernel/syscalls/wait/wait02.c | 171
>  +++++++-------------------------
>  1 file changed, 34 insertions(+), 137 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/wait/wait02.c
> b/testcases/kernel/syscalls/wait/wait02.c
> index a95213d..0cbcd48 100644
> --- a/testcases/kernel/syscalls/wait/wait02.c
> +++ b/testcases/kernel/syscalls/wait/wait02.c
> @@ -1,5 +1,7 @@
>  /*
>   * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
> + *    AUTHOR		: William Roske
> + *    CO-PILOT		: Dave Fenner
>   *
>   * This program is free software; you can redistribute it and/or modify it
>   * under the terms of version 2 of the GNU General Public License as
> @@ -30,84 +32,6 @@
>   * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
>   *
>   */
> -/* $Id: wait02.c,v 1.7 2009/10/26 14:55:48 subrata_modak Exp $ */
> -/**********************************************************
> - *
> - *    OS Test - Silicon Graphics, Inc.
> - *
> - *    TEST IDENTIFIER	: wait02
> - *
> - *    EXECUTED BY	: anyone
> - *
> - *    TEST TITLE	: Basic test for wait(2)
> - *
> - *    PARENT DOCUMENT	: usctpl01
> - *
> - *    TEST CASE TOTAL	: 1
> - *
> - *    WALL CLOCK TIME	: 1
> - *
> - *    CPU TYPES		: ALL
> - *
> - *    AUTHOR		: William Roske
> - *
> - *    CO-PILOT		: Dave Fenner
> - *
> - *    DATE STARTED	: 03/30/92
> - *
> - *    INITIAL RELEASE	: UNICOS 7.0
> - *
> - *    TEST CASES
> - *
> - *	1.) wait(2) returns...(See Description)
> - *
> - *    INPUT SPECIFICATIONS
> - *	The standard options for system call tests are accepted.
> - *	(See the parse_opts(3) man page).
> - *
> - *    OUTPUT SPECIFICATIONS
> - *
> - *    DURATION
> - *	Terminates - with frequency and infinite modes.
> - *
> - *    SIGNALS
> - *	Uses SIGUSR1 to pause before test if option set.
> - *	(See the parse_opts(3) man page).
> - *
> - *    RESOURCES
> - *	None
> - *
> - *    ENVIRONMENTAL NEEDS
> - *      No run-time environmental needs.
> - *
> - *    SPECIAL PROCEDURAL REQUIREMENTS
> - *	None
> - *
> - *    INTERCASE DEPENDENCIES
> - *	None
> - *
> - *    DETAILED DESCRIPTION
> - *	This is a Phase I test for the wait(2) system call.  It is intended
> - *	to provide a limited exposure of the system call, for now.  It
> - *	should/will be extended when full functional tests are written for
> - *	wait(2).
> - *
> - *	Setup:
> - *	  Setup signal handling.
> - *	  Pause for SIGUSR1 if option specified.
> - *
> - *	Test:
> - *	 Loop if the proper options are given.
> - *	  Execute system call
> - *	  Check return code, if system call failed (return=-1)
> - *		Log the errno and Issue a FAIL message.
> - *	  Otherwise, Issue a PASS message.
> - *
> - *	Cleanup:
> - *	  Print errno log and/or timing stats if options given
> - *
> - *
> - *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
>  
>  #include <errno.h>
>  #include <string.h>
> @@ -118,94 +42,67 @@
>  #include "test.h"
>  #include "usctest.h"
>  
> -void setup();
> -void cleanup();
> +static void setup(void);
> +static void cleanup(void);
>  
>  char *TCID = "wait02";
>  int TST_TOTAL = 1;
>  
> -int exp_enos[] = { 0, 0 };
> -
> -int fork_pid, ret_code;
> -void trapper();
> +static void wait_verify(void);
>  
>  int main(int ac, char **av)
>  {
>  	int lc;
>  	const char *msg;
>  
> -    /***************************************************************
> -     * parse standard options
> -     ***************************************************************/
> -	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
> +	msg = parse_opts(ac, av, NULL, NULL);
> +	if (msg != NULL)
>  		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
>  
> -    /***************************************************************
> -     * perform global setup for test
> -     ***************************************************************/
>  	setup();
>  
> -	/* set the expected errnos... */
> -	TEST_EXP_ENOS(exp_enos);
> -
> -    /***************************************************************
> -     * check looping state if -c option given
> -     ***************************************************************/
>  	for (lc = 0; TEST_LOOPING(lc); lc++) {
> -
>  		tst_count = 0;
> -
> -		/* create a child to wait for */
> -		if ((fork_pid = FORK_OR_VFORK()) == -1) {
> -			tst_brkm(TBROK, cleanup,
> -				 "fork() Failure. errno=%d : %s", errno,
> -				 strerror(errno));
> -		} else if (fork_pid == 0) {
> -			/* Child, sleep a second then exit */
> -			sleep(1);
> -			exit(1);
> -		}
> -
> -		/* Parent, wait for child to die */
> -		TEST(wait(&ret_code));
> -
> -		/* check return code */
> -		if (TEST_RETURN == -1) {
> -			TEST_ERROR_LOG(TEST_ERRNO);
> -			tst_resm(TFAIL, "wait(1) Failed, errno=%d : %s",
> -				 TEST_ERRNO, strerror(TEST_ERRNO));
> -		} else {
> -			tst_resm(TPASS, "wait(&ret_code) returned %ld",
> -				 TEST_RETURN);
> -		}
> +		wait_verify();
>  	}
>  
>  	cleanup();
>  	tst_exit();
>  }
>  
> -/***************************************************************
> - * setup() - performs all ONE TIME setup for this test.
> - ***************************************************************/
> -void setup(void)
> +static void setup(void)
>  {
> -
>  	tst_sig(FORK, DEF_HANDLER, cleanup);
>  
>  	TEST_PAUSE;
> +}
>  
> +static void wait_verify(void)
> +{
> +	int fork_pid, status, exit_child = 1;
> +
> +	fork_pid = FORK_OR_VFORK();
> +	if (fork_pid == -1) {
> +		tst_brkm(TBROK | TERRNO, cleanup, "fork() Failure");
> +	} else if (fork_pid == 0) {
> +		sleep(1);
> +		exit(exit_child);
> +	}
> +
> +	TEST(wait(&status));
> +
> +	if (TEST_RETURN == -1) {
> +		tst_resm(TFAIL | TTERRNO, "wait(1) Failed");
> +	} else if (WIFEXITED(status) && WEXITSTATUS(status) == 1) {
> +		tst_resm(TPASS, "wait(&status) returned %ld", TEST_RETURN);
> +	} else {
> +		tst_resm(TFAIL,
> +			 "wait(1) Failed, exit_child - 0x%x, status - 0x%x",
> +			 exit_child, status);
> +	}
>  }
>  
> -/***************************************************************
> - * cleanup() - performs all ONE TIME cleanup for this test at
> - *		completion or premature exit.
> - ***************************************************************/
> -void cleanup(void)
> +static void cleanup(void)
>  {
> -	/*
> -	 * print timing stats if that option was specified.
> -	 * print errno log if that option was specified.
> -	 */
>  	TEST_CLEANUP;
> -
>  }
> --
> 1.9.3
> 
> 
> 
> 

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2014-06-23  7:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-20  7:19 [LTP] [PATCH 1/2] wait/wait02: cleanup Zeng Linggang
2014-06-20  7:20 ` [LTP] [PATCH 2/2] wait/wait01.c: Add ECHILD test Zeng Linggang
2014-06-20  9:35 ` [LTP] [PATCH 1/2] wait/wait02: cleanup Jan Stancek
2014-06-23  2:27   ` Zeng Linggang
2014-06-23  2:37     ` [LTP] [PATCH v2 " Zeng Linggang
2014-06-23  7:00       ` Jan Stancek
2014-06-23  2:38     ` [LTP] [PATCH v2 2/2] wait/wait01.c: Add ECHILD test Zeng Linggang

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