<div dir="ltr">Sent the wrong patch by mistake. Sending the right one (with minor edits to commit text).</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 7, 2019 at 3:28 PM Saravana Kannan <<a href="mailto:saravanak@google.com">saravanak@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">We don't need to skip all the tests just because we are unable to add<br>
a test user. Not having a test user only affects PRIO_USER test case.<br>
So just skip that one and continue running the rest of the tests.<br>
<br>
This also allows this test case to be built and run on Android.<br>
<br>
Change-Id: Ie6eaf771002842fc1c768adf70bb2d1ef534f120<br>
Signed-off-by: Saravana Kannan <<a href="mailto:saravanak@google.com" target="_blank">saravanak@google.com</a>><br>
---<br>
.../kernel/syscalls/setpriority/Makefile | 5 ----<br>
.../syscalls/setpriority/setpriority01.c | 29 +++++++++++++------<br>
2 files changed, 20 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/testcases/kernel/syscalls/setpriority/Makefile b/testcases/kernel/syscalls/setpriority/Makefile<br>
index 5d00984ea..7a1a87a28 100644<br>
--- a/testcases/kernel/syscalls/setpriority/Makefile<br>
+++ b/testcases/kernel/syscalls/setpriority/Makefile<br>
@@ -19,9 +19,4 @@<br>
top_srcdir ?= ../../../..<br>
<br>
include $(top_srcdir)/include/mk/<a href="http://testcases.mk" rel="noreferrer" target="_blank">testcases.mk</a><br>
-<br>
-ifeq ($(ANDROID), 1)<br>
-FILTER_OUT_MAKE_TARGETS += setpriority01<br>
-endif<br>
-<br>
include $(top_srcdir)/include/mk/<a href="http://generic_leaf_target.mk" rel="noreferrer" target="_blank">generic_leaf_target.mk</a><br>
diff --git a/testcases/kernel/syscalls/setpriority/setpriority01.c b/testcases/kernel/syscalls/setpriority/setpriority01.c<br>
index 38b77b77f..92b1b4ef4 100644<br>
--- a/testcases/kernel/syscalls/setpriority/setpriority01.c<br>
+++ b/testcases/kernel/syscalls/setpriority/setpriority01.c<br>
@@ -92,9 +92,16 @@ static void verify_setpriority(unsigned int n)<br>
{<br>
struct tcase *tc = &tcases[n];<br>
<br>
+ if (tc->which == PRIO_USER && !user_added) {<br>
+ tst_res(TCONF, "setpriority(%s(%d), %d, -20..19) skipped - Can't add user",<br>
+ str_which(tc->which), tc->which, *tc->who);<br>
+ return;<br>
+ }<br>
+<br>
pid = SAFE_FORK();<br>
if (pid == 0) {<br>
- SAFE_SETUID(uid);<br>
+ if (user_added)<br>
+ SAFE_SETUID(uid);<br>
SAFE_SETPGID(0, 0);<br>
<br>
TST_CHECKPOINT_WAKE_AND_WAIT(0);<br>
@@ -115,15 +122,19 @@ static void setup(void)<br>
{<br>
const char *const cmd_useradd[] = {"useradd", username, NULL};<br>
struct passwd *ltpuser;<br>
+ int rc;<br>
<br>
- if (eaccess("/etc/passwd", W_OK))<br>
- tst_brk(TCONF, "/etc/passwd is not accessible");<br>
-<br>
- tst_run_cmd(cmd_useradd, NULL, NULL, 0);<br>
- user_added = 1;<br>
-<br>
- ltpuser = SAFE_GETPWNAM(username);<br>
- uid = ltpuser->pw_uid;<br>
+ switch ((rc = tst_run_cmd(cmd_useradd, NULL, NULL, 1))) {<br>
+ case 0:<br>
+ user_added = 1;<br>
+ ltpuser = SAFE_GETPWNAM(username);<br>
+ uid = ltpuser->pw_uid;<br>
+ return;<br>
+ case 255:<br>
+ return;<br>
+ default:<br>
+ tst_brk(TBROK, "Useradd failed (%d)", rc);<br>
+ }<br>
}<br>
<br>
static void cleanup(void)<br>
-- <br>
2.21.0.360.g471c308f928-goog<br>
<br>
</blockquote></div>