* [LTP] [PATCH] syscalls: Replace getppid02 with getpid02 implementation
@ 2026-07-07 15:35 Jinseok Kim
2026-07-07 16:34 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 2+ messages in thread
From: Jinseok Kim @ 2026-07-07 15:35 UTC (permalink / raw)
To: ltp
Remove the existing getppid02.c as its coverage is overlapped by
getpid02.c. Then, replace it by renaming and adapting the broader checks
from getpid02.c to serve as the new getppid02.c.
Signed-off-by: Jinseok Kim <always.starving0@gmail.com>
---
runtest/syscalls | 1 -
testcases/kernel/syscalls/getpid/.gitignore | 1 -
testcases/kernel/syscalls/getpid/getpid02.c | 67 -------------------
testcases/kernel/syscalls/getppid/getppid02.c | 49 +++++++++++---
4 files changed, 40 insertions(+), 78 deletions(-)
delete mode 100644 testcases/kernel/syscalls/getpid/getpid02.c
diff --git a/runtest/syscalls b/runtest/syscalls
index a38743ded..62a33e3a6 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -517,7 +517,6 @@ getpgid02 getpgid02
getpgrp01 getpgrp01
getpid01 getpid01
-getpid02 getpid02
getppid01 getppid01
getppid02 getppid02
diff --git a/testcases/kernel/syscalls/getpid/.gitignore b/testcases/kernel/syscalls/getpid/.gitignore
index f44bc9eac..8e7ab0185 100644
--- a/testcases/kernel/syscalls/getpid/.gitignore
+++ b/testcases/kernel/syscalls/getpid/.gitignore
@@ -1,2 +1 @@
/getpid01
-/getpid02
diff --git a/testcases/kernel/syscalls/getpid/getpid02.c b/testcases/kernel/syscalls/getpid/getpid02.c
deleted file mode 100644
index 08fcd5337..000000000
--- a/testcases/kernel/syscalls/getpid/getpid02.c
+++ /dev/null
@@ -1,67 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Copyright (c) International Business Machines Corp., 2001
- */
-
-/*\
- * Check that:
- *
- * - :manpage:`fork(2)` in parent returns the same pid as
- * :manpage:`getpid(2)` in child
- * - :manpage:`getppid(2)` in child returns the same pid as
- * :manpage:`getpid(2)` in parent
- */
-
-#include "tst_test.h"
-
-static pid_t *child_pid;
-
-static void verify_getpid(void)
-{
- pid_t proc_id;
- pid_t pid;
- pid_t pproc_id;
-
- proc_id = getpid();
- pid = SAFE_FORK();
-
- if (pid == 0) {
- pproc_id = getppid();
-
- if (pproc_id != proc_id) {
- tst_res(TFAIL, "child getppid() (%d) != parent getpid() (%d)",
- pproc_id, proc_id);
- } else {
- tst_res(TPASS, "child getppid() == parent getpid() (%d)", proc_id);
- }
-
- *child_pid = getpid();
-
- return;
- }
-
- tst_reap_children();
-
- if (*child_pid != pid)
- tst_res(TFAIL, "child getpid() (%d) != parent fork() (%d)", *child_pid, pid);
- else
- tst_res(TPASS, "child getpid() == parent fork() (%d)", pid);
-}
-
-static void setup(void)
-{
- child_pid = SAFE_MMAP(NULL, sizeof(pid_t), PROT_READ | PROT_WRITE,
- MAP_ANONYMOUS | MAP_SHARED, -1, 0);
-}
-
-static void cleanup(void)
-{
- SAFE_MUNMAP(child_pid, sizeof(pid_t));
-}
-
-static struct tst_test test = {
- .forks_child = 1,
- .setup = setup,
- .cleanup = cleanup,
- .test_all = verify_getpid,
-};
diff --git a/testcases/kernel/syscalls/getppid/getppid02.c b/testcases/kernel/syscalls/getppid/getppid02.c
index 7497eba12..08fcd5337 100644
--- a/testcases/kernel/syscalls/getppid/getppid02.c
+++ b/testcases/kernel/syscalls/getppid/getppid02.c
@@ -4,14 +4,19 @@
*/
/*\
- * Check that getppid() in child returns the same pid as getpid() in parent.
+ * Check that:
+ *
+ * - :manpage:`fork(2)` in parent returns the same pid as
+ * :manpage:`getpid(2)` in child
+ * - :manpage:`getppid(2)` in child returns the same pid as
+ * :manpage:`getpid(2)` in parent
*/
-#include <errno.h>
-
#include "tst_test.h"
-static void verify_getppid(void)
+static pid_t *child_pid;
+
+static void verify_getpid(void)
{
pid_t proc_id;
pid_t pid;
@@ -19,18 +24,44 @@ static void verify_getppid(void)
proc_id = getpid();
pid = SAFE_FORK();
+
if (pid == 0) {
pproc_id = getppid();
- if (pproc_id != proc_id)
- tst_res(TFAIL, "child's ppid(%d) not equal to parent's pid(%d)",
+ if (pproc_id != proc_id) {
+ tst_res(TFAIL, "child getppid() (%d) != parent getpid() (%d)",
pproc_id, proc_id);
- else
- tst_res(TPASS, "getppid() returned parent pid (%d)", proc_id);
+ } else {
+ tst_res(TPASS, "child getppid() == parent getpid() (%d)", proc_id);
+ }
+
+ *child_pid = getpid();
+
+ return;
}
+
+ tst_reap_children();
+
+ if (*child_pid != pid)
+ tst_res(TFAIL, "child getpid() (%d) != parent fork() (%d)", *child_pid, pid);
+ else
+ tst_res(TPASS, "child getpid() == parent fork() (%d)", pid);
+}
+
+static void setup(void)
+{
+ child_pid = SAFE_MMAP(NULL, sizeof(pid_t), PROT_READ | PROT_WRITE,
+ MAP_ANONYMOUS | MAP_SHARED, -1, 0);
+}
+
+static void cleanup(void)
+{
+ SAFE_MUNMAP(child_pid, sizeof(pid_t));
}
static struct tst_test test = {
.forks_child = 1,
- .test_all = verify_getppid,
+ .setup = setup,
+ .cleanup = cleanup,
+ .test_all = verify_getpid,
};
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [LTP] syscalls: Replace getppid02 with getpid02 implementation
2026-07-07 15:35 [LTP] [PATCH] syscalls: Replace getppid02 with getpid02 implementation Jinseok Kim
@ 2026-07-07 16:34 ` linuxtestproject.agent
0 siblings, 0 replies; 2+ messages in thread
From: linuxtestproject.agent @ 2026-07-07 16:34 UTC (permalink / raw)
To: Jinseok Kim; +Cc: ltp
Hi Jinseok,
On Tue, 07 Jul 2026 16:31:02 +0000, Jinseok Kim wrote:
> syscalls: Replace getppid02 with getpid02 implementation
> Remove the existing getppid02.c as its coverage is overlapped by
> getpid02.c. Then, replace it by renaming and adapting the broader checks
> from getpid02.c to serve as the new getppid02.c.
The commit message says "Remove the existing getppid02.c" but the file
that is actually deleted is getpid02.c. getppid02.c is replaced, not
removed. The sentence reads as if getppid02.c disappears, which is the
opposite of what happens.
> +static void verify_getpid(void)
This function is in getppid02.c but the name still says `verify_getpid`.
The function tests both fork/getpid consistency and getppid correctness,
but it was copied from getpid02.c without renaming. Could it be renamed
to `verify_getppid` to match the file it now lives in?
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-07 16:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 15:35 [LTP] [PATCH] syscalls: Replace getppid02 with getpid02 implementation Jinseok Kim
2026-07-07 16:34 ` [LTP] " linuxtestproject.agent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox