diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2020-07-07 11:39:27 -0400 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2020-07-07 13:28:58 -0600 |
commit | 05790fd7f8d3a77c26f1acd16b6d0f8f7d61d98a (patch) | |
tree | 0e49672a45956aeb32490cf643a241069e8133be /tools/testing | |
parent | bb91c0ca7b74efde2257ca4f0b1ba93e834e47e1 (diff) | |
download | linux-stable-05790fd7f8d3a77c26f1acd16b6d0f8f7d61d98a.tar.gz linux-stable-05790fd7f8d3a77c26f1acd16b6d0f8f7d61d98a.tar.bz2 linux-stable-05790fd7f8d3a77c26f1acd16b6d0f8f7d61d98a.zip |
selftests: pidfd: skip test if unshare fails with EPERM
Similar to how ENOSYS causes a skip if pidfd_send_signal is not present,
we can do the same for unshare if it fails with EPERM. This way, running
the test without privileges causes four tests to skip but no early bail out.
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing')
-rw-r--r-- | tools/testing/selftests/pidfd/pidfd_test.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tools/testing/selftests/pidfd/pidfd_test.c b/tools/testing/selftests/pidfd/pidfd_test.c index d2b001425cf8..c585aaa2acd8 100644 --- a/tools/testing/selftests/pidfd/pidfd_test.c +++ b/tools/testing/selftests/pidfd/pidfd_test.c @@ -162,15 +162,26 @@ static int test_pidfd_send_signal_recycled_pid_fail(void) } ret = unshare(CLONE_NEWPID); - if (ret < 0) + if (ret < 0) { + if (errno == EPERM) { + ksft_test_result_skip("%s test: Unsharing pid namespace not permitted\n", + test_name); + return 0; + } ksft_exit_fail_msg("%s test: Failed to unshare pid namespace\n", test_name); + } ret = unshare(CLONE_NEWNS); - if (ret < 0) - ksft_exit_fail_msg( - "%s test: Failed to unshare mount namespace\n", - test_name); + if (ret < 0) { + if (errno == EPERM) { + ksft_test_result_skip("%s test: Unsharing mount namespace not permitted\n", + test_name); + return 0; + } + ksft_exit_fail_msg("%s test: Failed to unshare mount namespace\n", + test_name); + } ret = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0); if (ret < 0) |