diff mbox series

[06/13] selftests: pidfd: skip test on kcmp() ENOSYS

Message ID 20201008122633.687877-7-tommi.t.rantala@nokia.com (mailing list archive)
State Accepted
Headers show
Series selftests fixes | expand

Commit Message

Rantala, Tommi T. (Nokia - FI/Espoo) Oct. 8, 2020, 12:26 p.m. UTC
Skip test if kcmp() is not available, for example if kernel is compiled
without CONFIG_CHECKPOINT_RESTORE=y.

Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com>
---
 tools/testing/selftests/pidfd/pidfd_getfd_test.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Christian Brauner Oct. 9, 2020, 12:04 p.m. UTC | #1
On Thu, Oct 08, 2020 at 03:26:26PM +0300, Tommi Rantala wrote:
> Skip test if kcmp() is not available, for example if kernel is compiled
> without CONFIG_CHECKPOINT_RESTORE=y.
> 
> Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com>
> ---

Good catch, thanks!
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
diff mbox series

Patch

diff --git a/tools/testing/selftests/pidfd/pidfd_getfd_test.c b/tools/testing/selftests/pidfd/pidfd_getfd_test.c
index 7758c98be015..0930e2411dfb 100644
--- a/tools/testing/selftests/pidfd/pidfd_getfd_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_getfd_test.c
@@ -204,7 +204,10 @@  TEST_F(child, fetch_fd)
 	fd = sys_pidfd_getfd(self->pidfd, self->remote_fd, 0);
 	ASSERT_GE(fd, 0);
 
-	EXPECT_EQ(0, sys_kcmp(getpid(), self->pid, KCMP_FILE, fd, self->remote_fd));
+	ret = sys_kcmp(getpid(), self->pid, KCMP_FILE, fd, self->remote_fd);
+	if (ret < 0 && errno == ENOSYS)
+		SKIP(return, "kcmp() syscall not supported");
+	EXPECT_EQ(ret, 0);
 
 	ret = fcntl(fd, F_GETFD);
 	ASSERT_GE(ret, 0);