[LTP] [PATCH] pidns05: Use tst_getpid()

Petr Vorel pvorel@suse.cz
Mon Sep 25 15:12:35 CEST 2023


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


More information about the ltp mailing list