All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/getxattr05: skip userns test cases when not supported
Date: Wed, 19 Jun 2019 15:47:07 +0300	[thread overview]
Message-ID: <20190619124707.2981-1-amir73il@gmail.com> (raw)

These test cases are failing when CONFIG_USER_NS is not defined.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 testcases/kernel/syscalls/getxattr/getxattr05.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/getxattr/getxattr05.c b/testcases/kernel/syscalls/getxattr/getxattr05.c
index 31b985ee0..c0d339f29 100644
--- a/testcases/kernel/syscalls/getxattr/getxattr05.c
+++ b/testcases/kernel/syscalls/getxattr/getxattr05.c
@@ -37,11 +37,13 @@
 #if defined(HAVE_SYS_XATTR_H) && defined(HAVE_LIBACL)
 
 #define TEST_FILE	"testfile"
+#define SELF_USERNS	"/proc/self/ns/user"
 #define MAX_USERNS	"/proc/sys/user/max_user_namespaces"
 #define UID_MAP	"/proc/self/uid_map"
 
 static acl_t acl;
 static int orig_max_userns = -1;
+static int user_ns_supported = 1;
 
 static struct tcase {
 	/* 0: without userns, 1: with userns */
@@ -110,6 +112,11 @@ static void do_getxattr(unsigned int n)
 	struct tcase *tc = &tcases[n];
 	pid_t pid;
 
+	if (tc->set_userns && !user_ns_supported) {
+		tst_res(TCONF, "user namespace not available");
+		return;
+	}
+
 	pid = SAFE_FORK();
 	if (!pid) {
 		if (tc->set_userns)
@@ -144,10 +151,13 @@ static void setup(void)
 	/* The default value of max_user_namespaces is set to 0 on some distros,
 	 * We need to change the default value to call unshare().
 	 */
-	if (!access(MAX_USERNS, F_OK)) {
+	if (access(SELF_USERNS, F_OK) != 0) {
+		user_ns_supported = 0;
+	} else if (!access(MAX_USERNS, F_OK)) {
 		SAFE_FILE_SCANF(MAX_USERNS, "%d", &orig_max_userns);
 		SAFE_FILE_PRINTF(MAX_USERNS, "%d", 10);
 	}
+
 }
 
 static void cleanup(void)
-- 
2.17.1


             reply	other threads:[~2019-06-19 12:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-19 12:47 Amir Goldstein [this message]
2019-06-19 14:23 ` [LTP] [PATCH] syscalls/getxattr05: skip userns test cases when not supported Cyril Hrubis
2019-06-20 13:30   ` Amir Goldstein

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=20190619124707.2981-1-amir73il@gmail.com \
    --to=amir73il@gmail.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.