pidns05: Use tst_getpid()
PATCH 1/1 pidns05: Use tst_getpid()
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.
--- testcases/kernel/containers/pidns/pidns05.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/containers/pidns/pidns05.c +2 -2
@@ -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++) {
Signature · 5 lines
2.42.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Martin,
Obviously candidate for pre-release fix.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 12 lines
testcases/kernel/containers/pidns/pidns05.c +1
-1@@ -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 );
testcases/kernel/containers/pidns/pidns05.c static int find_cinit_pids(pid_t *pids) · line 58
Quoted 5 lines
testcases/kernel/containers/pidns/pidns05.c +1
-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()
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi all,
Quoted 16 lines
Hi!
Quoted 14 lines
testcases/kernel/containers/pidns/pidns05.c +1
-1@@ -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;
Quoted 5 lines
testcases/kernel/containers/pidns/pidns05.c static int find_cinit_pids(pid_t *pids) · line 58
Quoted 2 lines
testcases/kernel/containers/pidns/pidns05.c +1
-1- 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
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 2 lines
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:
I mean that the second instance of getpid() is not called from cloned() process, the first one has to be replaced for sure.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 6 lines
Hi!
Quoted 2 lines
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:
I mean that the second instance of
getpid()is not called fromcloned()process, the first one has to be replaced for sure.
Ah, right. But be consistent with tst_getpid() looks to me slightly better.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp