selftests: pidfd: skip test on kcmp() ENOSYS
authorTommi Rantala <tommi.t.rantala@nokia.com>
Thu, 8 Oct 2020 12:26:26 +0000 (15:26 +0300)
committerShuah Khan <skhan@linuxfoundation.org>
Tue, 27 Oct 2020 23:01:45 +0000 (17:01 -0600)
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>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/pidfd/pidfd_getfd_test.c

index 7758c98..0930e24 100644 (file)
@@ -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);