From 78e46e5fc2c79b99b42224398eaac3852048bcd1 Mon Sep 17 00:00:00 2001 From: Edward Liaw Date: Thu, 28 Apr 2022 20:17:56 +0000 Subject: [PATCH 15/20] binderfs: skip when user namespace unavailable Skips the unprivileged test as this depends on CONFIG_USER_NS which we don't set for Android platforms. Signed-off-by: Edward Liaw --- .../selftests/filesystems/binderfs/binderfs_test.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c index 5f362c0fd890..047b228fcb91 100644 --- a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c +++ b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c @@ -291,6 +291,11 @@ static int write_id_mapping(enum idmap_type type, pid_t pid, const char *buf, return 0; } +static bool has_userns() +{ + return (access("/proc/self/ns/user", F_OK) == 0); +} + static void change_userns(struct __test_metadata *_metadata, int syncfds[2]) { int ret; @@ -378,6 +383,9 @@ static void *binder_version_thread(void *data) */ TEST(binderfs_stress) { + if (!has_userns()) + SKIP(return, "%s: user namespace not supported\n", __func__); + int fds[1000]; int syncfds[2]; pid_t pid; @@ -502,6 +510,8 @@ TEST(binderfs_test_privileged) TEST(binderfs_test_unprivileged) { + if (!has_userns()) + SKIP(return, "%s: user namespace not supported\n", __func__); int ret; int syncfds[2]; pid_t pid; -- 2.42.0.609.gbb76f46606-goog