Skip to content

Commit 019b277

Browse files
Muhammad Usama Anjumakpm00
authored andcommitted
selftests: mm: skip whole test instead of failure
Some architectures don't support userfaultfd. Skip running the whole test on them instead of registering the failure. Link: https://lkml.kernel.org/r/20231103182343.2874015-1-usama.anjum@collabora.com Fixes: 46fd75d ("selftests: mm: add pagemap ioctl tests") Reported-by: Ryan Roberts <ryan.roberts@arm.com> Closes: https://lore.kernel.org/all/f8463381-2697-49e9-9460-9dc73452830d@arm.com Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 85c2cea commit 019b277

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

tools/testing/selftests/mm/pagemap_ioctl.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,19 @@ int init_uffd(void)
9494

9595
uffd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK | UFFD_USER_MODE_ONLY);
9696
if (uffd == -1)
97-
ksft_exit_fail_msg("uffd syscall failed\n");
97+
return uffd;
9898

9999
uffdio_api.api = UFFD_API;
100100
uffdio_api.features = UFFD_FEATURE_WP_UNPOPULATED | UFFD_FEATURE_WP_ASYNC |
101101
UFFD_FEATURE_WP_HUGETLBFS_SHMEM;
102102
if (ioctl(uffd, UFFDIO_API, &uffdio_api))
103-
ksft_exit_fail_msg("UFFDIO_API\n");
103+
return -1;
104104

105105
if (!(uffdio_api.api & UFFDIO_REGISTER_MODE_WP) ||
106106
!(uffdio_api.features & UFFD_FEATURE_WP_UNPOPULATED) ||
107107
!(uffdio_api.features & UFFD_FEATURE_WP_ASYNC) ||
108108
!(uffdio_api.features & UFFD_FEATURE_WP_HUGETLBFS_SHMEM))
109-
ksft_exit_fail_msg("UFFDIO_API error %llu\n", uffdio_api.api);
109+
return -1;
110110

111111
return 0;
112112
}
@@ -1479,6 +1479,10 @@ int main(void)
14791479
struct stat sbuf;
14801480

14811481
ksft_print_header();
1482+
1483+
if (init_uffd())
1484+
return ksft_exit_pass();
1485+
14821486
ksft_set_plan(115);
14831487

14841488
page_size = getpagesize();
@@ -1488,9 +1492,6 @@ int main(void)
14881492
if (pagemap_fd < 0)
14891493
return -EINVAL;
14901494

1491-
if (init_uffd())
1492-
ksft_exit_fail_msg("uffd init failed\n");
1493-
14941495
/* 1. Sanity testing */
14951496
sanity_tests_sd();
14961497

0 commit comments

Comments
 (0)