wait/wait01.c: Add ECHILD test
Add ECHILD test for wait(2).
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
Signed-off-by: Jan Stancek <jstancek@redhat.com>
diff --git a/runtest/ltplite b/runtest/ltplite
index 939ea35..37e3119 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -979,6 +979,7 @@
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 @@
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 @@
#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..ab2396e
--- /dev/null
+++ b/testcases/kernel/syscalls/wait/wait01.c
@@ -0,0 +1,86 @@
+/*
+ * 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: %ld",
+ TEST_RETURN);
+ 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;
+}