Skip to contentSkip to conversation

Split waitid02.c test using new LTP API

PATCH In review Andrea Cervesato 2 participants 2 messages Feb 17, 2022 – Feb 21, 2022

v2 of 3 In review Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Split waitid02.c test using new LTP API

waitid02.c has been splitted into multiple tests which are testing a specific waitid functionality. TST_CHECKPOINT_INIT has been replaced by .needs_checkpoints

---
v2 introduces more TST_EXP_ macros and removed waitpid to let library handling process status.

 runtest/syscalls                            |   7 +
 testcases/kernel/syscalls/waitid/.gitignore |   7 +
 testcases/kernel/syscalls/waitid/waitid02.c | 311 ++------------------
 testcases/kernel/syscalls/waitid/waitid03.c |  31 ++
 testcases/kernel/syscalls/waitid/waitid04.c |  43 +++
 testcases/kernel/syscalls/waitid/waitid05.c |  41 +++
 testcases/kernel/syscalls/waitid/waitid06.c |  39 +++
 testcases/kernel/syscalls/waitid/waitid07.c |  47 +++
 testcases/kernel/syscalls/waitid/waitid08.c |  53 ++++
 testcases/kernel/syscalls/waitid/waitid09.c |  44 +++
 10 files changed, 333 insertions(+), 290 deletions(-)
 create mode 100644 testcases/kernel/syscalls/waitid/waitid03.c
 create mode 100644 testcases/kernel/syscalls/waitid/waitid04.c
 create mode 100644 testcases/kernel/syscalls/waitid/waitid05.c
 create mode 100644 testcases/kernel/syscalls/waitid/waitid06.c
 create mode 100644 testcases/kernel/syscalls/waitid/waitid07.c
 create mode 100644 testcases/kernel/syscalls/waitid/waitid08.c
 create mode 100644 testcases/kernel/syscalls/waitid/waitid09.c
runtest/syscalls +7 -0
index 3b2deb64e..306cc255f 100644
@@ -1696,6 +1696,13 @@ waitpid13 waitpid13
 
 waitid01 waitid01
 waitid02 waitid02
+waitid03 waitid03
+waitid04 waitid04
+waitid05 waitid05
+waitid06 waitid06
+waitid07 waitid07
+waitid08 waitid08
+waitid09 waitid09
 
 write01 write01
 write02 write02
testcases/kernel/syscalls/waitid/.gitignore +7 -0
index e200a061b..315af1690 100644
@@ -1,2 +1,9 @@
 /waitid01
 /waitid02
+/waitid03
+/waitid04
+/waitid05
+/waitid06
+/waitid07
+/waitid08
+/waitid09
testcases/kernel/syscalls/waitid/waitid02.c +21 -290

321 lines not on this page · raw message

testcases/kernel/syscalls/waitid/waitid03.c new file +31 -0
new file mode 100644
index 000000000..1dbb578da
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) Crackerjack Project., 2007
+ * Copyright (c) Manas Kumar Nayak [email protected]>
+ * Copyright (C) 2021 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+/*\
+ * [Description]
+ *
+ * This test is checking if waitid() syscall returns ECHILD when the calling
+ * process has no existing unwaited-for child processes.
+ */
+
+#include <sys/wait.h>
+#include "tst_test.h"
+
+static void run(void)
+{
+	siginfo_t infop;
+
+	memset(&infop, 0, sizeof(infop));
+	TST_EXP_FAIL(waitid(P_ALL, 0, &infop, WNOHANG | WEXITED), ECHILD);
+
+	tst_res(TINFO, "si_pid = %d ; si_code = %d ; si_status = %d",
+		infop.si_pid, infop.si_code, infop.si_status);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+};
testcases/kernel/syscalls/waitid/waitid04.c new file +43 -0

43 lines not on this page · raw message

testcases/kernel/syscalls/waitid/waitid05.c new file +41 -0

41 lines not on this page · raw message

testcases/kernel/syscalls/waitid/waitid06.c new file +39 -0
new file mode 100644
index 000000000..886c9b2fd
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) Crackerjack Project., 2007
+ * Copyright (c) Manas Kumar Nayak [email protected]>
+ * Copyright (C) 2021 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+/*\
+ * [Description]
+ *
+ * This test is checking if waitid() syscall filters children which exited.
+ */
+
+#include <sys/wait.h>
+#include "tst_test.h"
+
+static void run(void)
+{
+	siginfo_t infop;
+	pid_t pid_child;
+
+	/* dummy fork */
+	pid_child = SAFE_FORK();
+	if (!pid_child)
+		return;
+
+	tst_res(TINFO, "filter child by WEXITED");
+
+	memset(&infop, 0, sizeof(infop));
+	TST_EXP_PASS(waitid(P_PID, pid_child, &infop, WEXITED));
+
+	tst_res(TINFO, "si_pid = %d ; si_code = %d ; si_status = %d",
+		infop.si_pid, infop.si_code, infop.si_status);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.forks_child = 1,
+};
testcases/kernel/syscalls/waitid/waitid07.c new file +47 -0

47 lines not on this page · raw message

testcases/kernel/syscalls/waitid/waitid08.c new file +53 -0

53 lines not on this page · raw message

testcases/kernel/syscalls/waitid/waitid09.c new file +44 -0

44 lines not on this page · raw message

Signature · 5 lines
2.35.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi!
Pushed, thanks.

FYI: I've added bunch of fixes and cleanups in a follow up patch.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp