* [LTP] [PATCH] pidns05: Use tst_getpid()
@ 2023-09-20 15:31 Martin Doucha
2023-09-20 15:37 ` Petr Vorel
2023-09-22 12:13 ` Cyril Hrubis
0 siblings, 2 replies; 6+ messages in thread
From: Martin Doucha @ 2023-09-20 15:31 UTC (permalink / raw)
To: Andrea Cervesato, ltp
Older glibc versions cache getpid() results. Calling clone() through
the direct syscall interface (bypassing glibc) with the CLONE_NEWPID
argument will result in stale getpid() cache and the test will fail.
Use tst_getpid() instead to get the correct PID value.
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
testcases/kernel/containers/pidns/pidns05.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/containers/pidns/pidns05.c b/testcases/kernel/containers/pidns/pidns05.c
index ec9ce9bf2..0e7739aaa 100644
--- a/testcases/kernel/containers/pidns/pidns05.c
+++ b/testcases/kernel/containers/pidns/pidns05.c
@@ -28,7 +28,7 @@ static void child_func(int *level)
{
pid_t cpid, ppid;
- cpid = getpid();
+ cpid = tst_getpid();
ppid = getppid();
TST_EXP_EQ_LI(cpid, 1);
@@ -55,7 +55,7 @@ static int find_cinit_pids(pid_t *pids)
int next = 0;
pid_t parentpid, pgid, pgid2;
- parentpid = getpid();
+ parentpid = tst_getpid();
pgid = SAFE_GETPGID(parentpid);
for (pid = 2; pid < pid_max; pid++) {
--
2.42.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [LTP] [PATCH] pidns05: Use tst_getpid()
2023-09-20 15:31 [LTP] [PATCH] pidns05: Use tst_getpid() Martin Doucha
@ 2023-09-20 15:37 ` Petr Vorel
2023-09-22 12:13 ` Cyril Hrubis
1 sibling, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2023-09-20 15:37 UTC (permalink / raw)
To: Martin Doucha; +Cc: ltp
Hi Martin,
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Obviously candidate for pre-release fix.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] pidns05: Use tst_getpid()
2023-09-20 15:31 [LTP] [PATCH] pidns05: Use tst_getpid() Martin Doucha
2023-09-20 15:37 ` Petr Vorel
@ 2023-09-22 12:13 ` Cyril Hrubis
2023-09-25 13:12 ` Petr Vorel
1 sibling, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2023-09-22 12:13 UTC (permalink / raw)
To: Martin Doucha; +Cc: ltp
Hi!
> --- a/testcases/kernel/containers/pidns/pidns05.c
> +++ b/testcases/kernel/containers/pidns/pidns05.c
> @@ -28,7 +28,7 @@ static void child_func(int *level)
> {
> pid_t cpid, ppid;
>
> - cpid = getpid();
> + cpid = tst_getpid();
> ppid = getppid();
>
> TST_EXP_EQ_LI(cpid, 1);
> @@ -55,7 +55,7 @@ static int find_cinit_pids(pid_t *pids)
> int next = 0;
> pid_t parentpid, pgid, pgid2;
>
> - parentpid = getpid();
> + parentpid = tst_getpid();
I suppose that this one is not strictly required, but it does not harm
to consistently use tst_getpid()
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [LTP] [PATCH] pidns05: Use tst_getpid()
2023-09-22 12:13 ` Cyril Hrubis
@ 2023-09-25 13:12 ` Petr Vorel
2023-09-25 13:17 ` Cyril Hrubis
0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2023-09-25 13:12 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Hi all,
> Hi!
> > --- a/testcases/kernel/containers/pidns/pidns05.c
> > +++ b/testcases/kernel/containers/pidns/pidns05.c
> > @@ -28,7 +28,7 @@ static void child_func(int *level)
> > {
> > pid_t cpid, ppid;
> > - cpid = getpid();
> > + cpid = tst_getpid();
> > ppid = getppid();
> > TST_EXP_EQ_LI(cpid, 1);
> > @@ -55,7 +55,7 @@ static int find_cinit_pids(pid_t *pids)
> > int next = 0;
> > pid_t parentpid, pgid, pgid2;
> > - parentpid = getpid();
> > + parentpid = tst_getpid();
> I suppose that this one is not strictly required, but it does not harm
> to consistently use tst_getpid()
Well, Martin found that some of SLES versions (e.g. some SLES versions based on
kernel 4.12 or older) started to fail after rewrite:
8c201e55f ("Remove libclone dependency from pidns05 test")
tst_test.c:1684: TINFO: LTP version: 20230516
tst_test.c:1570: TINFO: Timeout per run is 0h 00m 30s
pidns05.c:34: TFAIL: cpid (2075) != 1 (1)
pidns05.c:35: TPASS: ppid == 0 (0)
pidns05.c:34: TFAIL: cpid (2075) != 1 (1)
pidns05.c:35: TPASS: ppid == 0 (0)
pidns05.c:34: TFAIL: cpid (2075) != 1 (1)
pidns05.c:35: TPASS: ppid == 0 (0)
pidns05.c:34: TFAIL: cpid (2075) != 1 (1)
pidns05.c:35: TPASS: ppid == 0 (0)
pidns05.c:34: TFAIL: cpid (2075) != 1 (1)
pidns05.c:35: TPASS: ppid == 0 (0)
pidns05.c:34: TFAIL: cpid (2075) != 1 (1)
pidns05.c:35: TPASS: ppid == 0 (0)
pidns05.c:97: TPASS: find_cinit_pids(pids) returned 6
pidns05.c:115: TPASS: No children left after sending SIGKILL to the first child
Therefore it was needed.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-09-25 17:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-20 15:31 [LTP] [PATCH] pidns05: Use tst_getpid() Martin Doucha
2023-09-20 15:37 ` Petr Vorel
2023-09-22 12:13 ` Cyril Hrubis
2023-09-25 13:12 ` Petr Vorel
2023-09-25 13:17 ` Cyril Hrubis
2023-09-25 17:45 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox