Skip to content

Commit 6d21130

Browse files
x-y-zakpm00
authored andcommitted
selftests/mm: skip guard_regions.uffd tests when uffd is not present
Patch series "Skip mm selftests instead when kernel features are not present", v2. Two guard_regions tests on userfaultfd fail when userfaultfd is not present. Skip them instead. hugevm test reads kernel config to get page table level information and fails when neither /proc/config.gz nor /boot/config-* is present. Skip it instead. This patch (of 2): When userfaultfd is not compiled into kernel, userfaultfd() returns -1, causing guard_regions.uffd tests to fail. Skip the tests instead. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Zi Yan <[email protected]> Reviewed-by: Lorenzo Stoakes <[email protected]> Reviewed-by: Pedro Falcato <[email protected]> Cc: Adam Sindelar <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent c5a9dea commit 6d21130

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tools/testing/selftests/mm/guard-regions.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,8 +1453,21 @@ TEST_F(guard_regions, uffd)
14531453

14541454
/* Set up uffd. */
14551455
uffd = userfaultfd(0);
1456-
if (uffd == -1 && errno == EPERM)
1457-
ksft_exit_skip("No userfaultfd permissions, try running as root.\n");
1456+
if (uffd == -1) {
1457+
switch (errno) {
1458+
case EPERM:
1459+
SKIP(return, "No userfaultfd permissions, try running as root.");
1460+
break;
1461+
case ENOSYS:
1462+
SKIP(return, "userfaultfd is not supported/not enabled.");
1463+
break;
1464+
default:
1465+
ksft_exit_fail_msg("userfaultfd failed with %s\n",
1466+
strerror(errno));
1467+
break;
1468+
}
1469+
}
1470+
14581471
ASSERT_NE(uffd, -1);
14591472

14601473
ASSERT_EQ(ioctl(uffd, UFFDIO_API, &api), 0);

0 commit comments

Comments
 (0)