[LTP] [PATCH] getpgid01: On Android, pgid(1) is 0 instead of 1

Cyril Hrubis chrubis@suse.cz
Thu Oct 26 13:11:13 CEST 2023


Hi!
> > diff --git a/testcases/kernel/syscalls/getpgid/getpgid01.c b/testcases/kernel/syscalls/getpgid/getpgid01.c
> > index 479fe5dcb..8640f2c93 100644
> > --- a/testcases/kernel/syscalls/getpgid/getpgid01.c
> > +++ b/testcases/kernel/syscalls/getpgid/getpgid01.c
> > @@ -37,7 +37,7 @@ static void run(void)
> >  		TST_EXP_EQ_LI(TST_RET, pgid);
> 
> >  		TST_EXP_PID(getpgid(1));
> > -		TST_EXP_EQ_LI(TST_RET, 1);
> > +		TST_EXP_EXPR(TST_RET == 1 || TST_RET == 0, "getpgid(1) == 1 or 0");
> Although I don't prefer using often libc specific code, here I'd use it:
> 
> #ifndef __ANDROID__ 
> 		TST_EXP_EQ_LI(TST_RET, 0);
> #else
> 		TST_EXP_EQ_LI(TST_RET, 1);
> #endif
> 
> Because your code would loosen testing for other libc.
> Cyril, Li, WDYT?

@Peter what about the case where we bypass all init and boot with
init=/bin/sh or init=ltx? I suppose that we will have pgrp set to 0
as well.

What about parsing /proc/1/stat and checking that the value there is the
same as reported here, that should work regardless of what pid is the
init.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list