]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/mm: fix exit code in pagemap_ioctl
authorKevin Brodsky <kevin.brodsky@arm.com>
Thu, 22 Jan 2026 17:02:23 +0000 (17:02 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 31 Jan 2026 22:22:42 +0000 (14:22 -0800)
Make sure pagemap_ioctl exits with an appropriate value:

* If the tests are run, call ksft_finished() to report the right
  status instead of reporting PASS unconditionally.

* Report SKIP if userfaultfd isn't available (in line with other
  tests)

* Report FAIL if we failed to open /proc/self/pagemap, as this file
  has been added a long time ago and doesn't depend on any CONFIG
  option (returning -EINVAL from main() is meaningless)

Link: https://lkml.kernel.org/r/20260122170224.4056513-9-kevin.brodsky@arm.com
Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
Acked-by: SeongJae Park <sj@kernel.org>
Reviewed-by: wang lian <lianux.mm@gmail.com>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Cc: Usama Anjum <Usama.Anjum@arm.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/mm/pagemap_ioctl.c

index 1896c7d4f72eeef0c0bd0a2aa2b72f3e74e6505b..2ca8a7e3c27ef965b6b345100718749875a9feea 100644 (file)
@@ -1552,7 +1552,7 @@ int main(int __attribute__((unused)) argc, char *argv[])
        ksft_print_header();
 
        if (init_uffd())
-               ksft_exit_pass();
+               ksft_exit_skip("Failed to initialize userfaultfd\n");
 
        ksft_set_plan(117);
 
@@ -1561,7 +1561,7 @@ int main(int __attribute__((unused)) argc, char *argv[])
 
        pagemap_fd = open(PAGEMAP, O_RDONLY);
        if (pagemap_fd < 0)
-               return -EINVAL;
+               ksft_exit_fail_msg("Failed to open " PAGEMAP "\n");
 
        /* 1. Sanity testing */
        sanity_tests_sd();
@@ -1733,5 +1733,5 @@ int main(int __attribute__((unused)) argc, char *argv[])
        zeropfn_tests();
 
        close(pagemap_fd);
-       ksft_exit_pass();
+       ksft_finished();
 }