From: Saravana Kannan <saravanak@google.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] setpriority01: Skip only PRIO_USER when unable to add test user
Date: Wed, 6 Mar 2019 13:58:59 -0800 [thread overview]
Message-ID: <20190306215859.66044-1-saravanak@google.com> (raw)
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.
Signed-off-by: Saravana Kannan <saravanak@google.com>
---
.../kernel/syscalls/setpriority/Makefile | 5 -----
.../syscalls/setpriority/setpriority01.c | 22 +++++++++++--------
2 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/testcases/kernel/syscalls/setpriority/Makefile b/testcases/kernel/syscalls/setpriority/Makefile
index 5d00984ea..7a1a87a28 100644
--- a/testcases/kernel/syscalls/setpriority/Makefile
+++ b/testcases/kernel/syscalls/setpriority/Makefile
@@ -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
diff --git a/testcases/kernel/syscalls/setpriority/setpriority01.c b/testcases/kernel/syscalls/setpriority/setpriority01.c
index 38b77b77f..147d173c5 100644
--- a/testcases/kernel/syscalls/setpriority/setpriority01.c
+++ b/testcases/kernel/syscalls/setpriority/setpriority01.c
@@ -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)
--
2.21.0.352.gf09ad66450-goog
next reply other threads:[~2019-03-06 21:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-06 21:58 Saravana Kannan [this message]
2019-03-07 10:59 ` [LTP] [PATCH] setpriority01: Skip only PRIO_USER when unable to add test user Cyril Hrubis
2019-03-07 15:44 ` Saravana Kannan
2019-03-07 22:36 ` Saravana Kannan
2019-03-11 16:04 ` Cyril Hrubis
2019-03-11 18:23 ` Saravana Kannan
2019-03-13 18:54 ` Saravana Kannan
2019-03-19 10:06 ` Cyril Hrubis
2019-03-11 16:00 ` Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190306215859.66044-1-saravanak@google.com \
--to=saravanak@google.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.