setpriority01: Skip only PRIO_USER when unable to add test user
PATCH 1/1 setpriority01: Skip only PRIO_USER when unable to add test user
We don't need to skip all the tests just because we are unable to add a test user. Not having a test user only affects PRIO_USER test case. So just skip that one and continue running the rest of the tests.
This also allows this test case to be built and run on Android.
--- .../kernel/syscalls/setpriority/Makefile | 5 ----- .../syscalls/setpriority/setpriority01.c | 22 +++++++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-)
testcases/kernel/syscalls/setpriority/Makefile +0 -5
@@ -19,9 +19,4 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk - -ifeq ($(ANDROID), 1) -FILTER_OUT_MAKE_TARGETS += setpriority01 -endif - include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/setpriority/setpriority01.c +13 -9
@@ -92,9 +92,16 @@ static void verify_setpriority(unsigned int n) {struct tcase *tc = &tcases[n]; +if (tc->which ==PRIO_USER && !user_added) { +tst_res (TCONF ,"setpriority(%s(%d), %d, -20..19) skipped - Can't add user" , +str_which (tc->which), tc->which, *tc->who); +return ; + } + pid =SAFE_FORK ();if (pid ==0 ) { -SAFE_SETUID (uid); +if (user_added) +SAFE_SETUID (uid);SAFE_SETPGID (0 ,0 );TST_CHECKPOINT_WAKE_AND_WAIT (0 );
@@ -116,14 +123,11 @@ static void setup(void)const char *const cmd_useradd[] = {"useradd" , username,NULL };struct passwd *ltpuser; -if (eaccess ("/etc/passwd" ,W_OK )) -tst_brk (TCONF ,"/etc/passwd is not accessible" ); - -tst_run_cmd (cmd_useradd,NULL ,NULL ,0 ); - user_added =1 ; - - ltpuser =SAFE_GETPWNAM (username); - uid = ltpuser->pw_uid; +if (!tst_run_cmd (cmd_useradd,NULL ,NULL ,1 )) { + user_added =1 ; + ltpuser =SAFE_GETPWNAM (username); + uid = ltpuser->pw_uid; + } }static void cleanup (void )
Signature · 1 line
2.21.0.352.gf09ad66450-goog
PATCH 1/1 setpriority01: Skip only PRIO_USER when unable to add test user
Hi!
testcases/kernel/syscalls/setpriority/setpriority01.c static void setup(void) · line 130
Quoted 7 lines
testcases/kernel/syscalls/setpriority/setpriority01.c +5
-2- ltpuser =SAFE_GETPWNAM (username); - uid = ltpuser->pw_uid; +if (!tst_run_cmd (cmd_useradd,NULL ,NULL ,1 )) { + user_added =1 ; + ltpuser =SAFE_GETPWNAM (username); + uid = ltpuser->pw_uid; + }
The only thing that I don't like here is that we do not check the cause of failure here. What exactly happens on android, is useradd missing there completely? If so we should proceed with TCONF only if tst_run_cmd() returned 255 and TBROK the test on other non-zero return values.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 setpriority01: Skip only PRIO_USER when unable to add test user
Quoted 9 lines · Cyril Hrubis
Hi!
testcases/kernel/syscalls/setpriority/setpriority01.c static void setup(void) · line 130
Quoted 7 lines
testcases/kernel/syscalls/setpriority/setpriority01.c +5
-2- ltpuser =SAFE_GETPWNAM (username); - uid = ltpuser->pw_uid; +if (!tst_run_cmd (cmd_useradd,NULL ,NULL ,1 )) { + user_added =1 ; + ltpuser =SAFE_GETPWNAM (username); + uid = ltpuser->pw_uid; + }
Quoted 3 lines
The only thing that I don't like here is that we do not check the cause of failure here. What exactly happens on android, is useradd missing there completely?
Correct, useradd is missing.
If so we should proceed with TCONF only if
Quoted 3 lines
tst_run_cmd()returned 255 and TBROK the test on other non-zero return values.
But is the test that's broken if useradd fails for wherever reason? Isn't it a configuration issue?
Thanks,
Saravana
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190307/b2e08468/attachment.html>
PATCH 1/1 setpriority01: Skip only PRIO_USER when unable to add test user
Quoted 20 lines · Saravana Kannan
Quoted 9 lines · Cyril Hrubis
Hi!
testcases/kernel/syscalls/setpriority/setpriority01.c static void setup(void) · line 130
Quoted 7 lines
testcases/kernel/syscalls/setpriority/setpriority01.c +5
-2- ltpuser =SAFE_GETPWNAM (username); - uid = ltpuser->pw_uid; +if (!tst_run_cmd (cmd_useradd,NULL ,NULL ,1 )) { + user_added =1 ; + ltpuser =SAFE_GETPWNAM (username); + uid = ltpuser->pw_uid; + }Quoted 3 lines
The only thing that I don't like here is that we do not check the cause of failure here. What exactly happens on android, is useradd missing there completely?
Correct, useradd is missing.
Quoted 9 lines
If so we should proceed with TCONF only if
Quoted 3 lines
tst_run_cmd()returned 255 and TBROK the test on other non-zero return values.But is the test that's broken if useradd fails for wherever reason? Isn't it a configuration issue?
Looking more into the definition of TBROK, TCONF and the code before my changes:
- if (eaccess("/etc/passwd", W_OK))
- tst_brk(TCONF, "/etc/passwd is not accessible");
-
- tst_run_cmd(cmd_useradd, NULL, NULL, 0);
- user_added = 1;
-
Should an eaccess write failure have resulted in a TCONF? Shouldn't that have been a TBROK too?
I'm fine with whatever way we go, except not wanting to fail the entire test case just because useradd isn't present in android. It's still very useful to run the other setpriority tests.
Thanks,
Saravana
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190307/9349e098/attachment-0001.html>
PATCH 1/1 setpriority01: Skip only PRIO_USER when unable to add test user
Hi!
Quoted 14 lines
Quoted 4 lines
But is the test that's broken if useradd fails for wherever reason? Isn't it a configuration issue?
Looking more into the definition of TBROK, TCONF and the code before my changes:
testcases/kernel/syscalls/setpriority/setpriority01.c +0
-6-if (eaccess ("/etc/passwd" ,W_OK )) -tst_brk (TCONF ,"/etc/passwd is not accessible" ); - -tst_run_cmd (cmd_useradd,NULL ,NULL ,0 ); - user_added =1 ; -
Quoted 2 lines
Should an eaccess write failure have resulted in a TCONF? Shouldn't that have been a TBROK too?
Looking at the git log this seems to be handling very specific case where the rootfs is read only, quite likely this test was failing on some specific embedded hardware. As far as I can tell this sounds like a reasonable solution to the problem.
Quoted 3 lines
I'm fine with whatever way we go, except not wanting to fail the entire test case just because useradd isn't present in android. It's still very useful to run the other setpriority tests.
Sounds good, there is no point not to map missing useradd to TCONF, I just want to avoid mapping segfaulting or otherwise faulty useradd to TCONF as well.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 setpriority01: Skip only PRIO_USER when unable to add test user
Quoted 24 lines · Cyril Hrubis
Hi!
Quoted 1 line
Quoted 1 line
But is the test that's broken if useradd fails for wherever reason?
Isn't
Quoted 13 lines
Quoted 3 lines
it a configuration issue?
Looking more into the definition of TBROK, TCONF and the code before my changes:
testcases/kernel/syscalls/setpriority/setpriority01.c +0
-6-if (eaccess ("/etc/passwd" ,W_OK )) -tst_brk (TCONF ,"/etc/passwd is not accessible" ); - -tst_run_cmd (cmd_useradd,NULL ,NULL ,0 ); - user_added =1 ; -Quoted 2 lines
Should an eaccess write failure have resulted in a TCONF? Shouldn't that have been a TBROK too?
Looking at the git log this seems to be handling very specific case where the rootfs is read only, quite likely this test was failing on some specific embedded hardware. As far as I can tell this sounds like a reasonable solution to the problem.
Quoted 8 lines
Quoted 3 lines
I'm fine with whatever way we go, except not wanting to fail the entire test case just because useradd isn't present in android. It's still very useful to run the other setpriority tests.
Sounds good, there is no point not to map missing useradd to TCONF, I just want to avoid mapping segfaulting or otherwise faulty useradd to TCONF as well.
Thanks for the reviews and comments! I sent out a v2 patch that addressed your concerns. Can you please take a look at that and accept or suggest changes to it? In that patch, I treated the "no write permissions to /etc/passwd" as a TBROK and not TCONF as that seemed more appropriate to me. But if you want I can map that back to TCONF -- according to man pages, useradd has an error code for not being able to write to /etc/passwd.
Thanks,
Saravana
Quoted 1 line
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190311/22cd6b68/attachment.html>
PATCH 1/1 setpriority01: Skip only PRIO_USER when unable to add test user
Hi Cyril,
Did you have any thoughts on the v2 patch? Want me to make any updates to it?
Thanks,
Saravana
Quoted 44 lines · Saravana Kannan
Quoted 24 lines · Cyril Hrubis
Hi!
Quoted 1 line
Quoted 1 line
But is the test that's broken if useradd fails for wherever reason?
Isn't
Quoted 13 lines
Quoted 3 lines
it a configuration issue?
Looking more into the definition of TBROK, TCONF and the code before my changes:
testcases/kernel/syscalls/setpriority/setpriority01.c +0
-6-if (eaccess ("/etc/passwd" ,W_OK )) -tst_brk (TCONF ,"/etc/passwd is not accessible" ); - -tst_run_cmd (cmd_useradd,NULL ,NULL ,0 ); - user_added =1 ; -Quoted 2 lines
Should an eaccess write failure have resulted in a TCONF? Shouldn't that have been a TBROK too?
Looking at the git log this seems to be handling very specific case where the rootfs is read only, quite likely this test was failing on some specific embedded hardware. As far as I can tell this sounds like a reasonable solution to the problem.
Quoted 8 lines
Quoted 3 lines
I'm fine with whatever way we go, except not wanting to fail the entire test case just because useradd isn't present in android. It's still very useful to run the other setpriority tests.
Sounds good, there is no point not to map missing useradd to TCONF, I just want to avoid mapping segfaulting or otherwise faulty useradd to TCONF as well.
Thanks for the reviews and comments! I sent out a v2 patch that addressed your concerns. Can you please take a look at that and accept or suggest changes to it? In that patch, I treated the "no write permissions to
/etc/passwd" as a TBROK and not TCONF as that seemed more appropriate to me. But if you want I can map that back to TCONF -- according to man pages, useradd has an error code for not being able to write to/etc/passwd.
Quoted 5 lines
Thanks,
SaravanaQuoted 1 line
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190313/fa165e48/attachment.html>
PATCH 1/1 setpriority01: Skip only PRIO_USER when unable to add test user
Hi!
Sorry for late reply, looking into useradd manual mapping return value 1 to TCONF should do the job here.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 setpriority01: Skip only PRIO_USER when unable to add test user
In reply to Saravana KannanHi!
Quoted 2 lines
But is the test that's broken if useradd fails for wherever reason? Isn't it a configuration issue?
TBROK means "Test broken in preparation phase", while TCONF means "test not applicable". Generally we use TCONF for missing functionality. If useradd binary is present and fails to add a user for unknown reason it's more likely failure in setting up the test environment than missing functionality.
Signature · 2 lines
Cyril Hrubis [email protected]