]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/mm: protection_keys: use descriptive test names in the output
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Mon, 11 May 2026 16:28:00 +0000 (19:28 +0300)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 21 Jun 2026 18:37:21 +0000 (11:37 -0700)
Replace the numeric test index in TAP output with the actual test function
name.

Use a structure containing function pointer and its name rather than only
the function pointer in the pkey_tests array.

Link: https://lore.kernel.org/20260511162840.375890-17-rppt@kernel.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Reviewed-by: Donet Tom <donettom@linux.ibm.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Tested-by: Luiz Capitulino <luizcap@redhat.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <baohua@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: Liam Howlett <liam@infradead.org>
Cc: Li Wang <li.wang@linux.dev>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Nico Pache <npache@redhat.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Sarthak Sharma <sarthak.sharma@arm.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/mm/protection_keys.c

index 2085982dba6969124a9b53428322a33cef0c60a5..80c6124e837878fc0654cc43508ed38a4137d738 100644 (file)
@@ -1692,29 +1692,36 @@ static void test_mprotect_pkey_on_unsupported_cpu(int *ptr, u16 pkey)
        pkey_assert(sret < 0);
 }
 
-static void (*pkey_tests[])(int *ptr, u16 pkey) = {
-       test_read_of_write_disabled_region,
-       test_read_of_access_disabled_region,
-       test_read_of_access_disabled_region_with_page_already_mapped,
-       test_write_of_write_disabled_region,
-       test_write_of_write_disabled_region_with_page_already_mapped,
-       test_write_of_access_disabled_region,
-       test_write_of_access_disabled_region_with_page_already_mapped,
-       test_kernel_write_of_access_disabled_region,
-       test_kernel_write_of_write_disabled_region,
-       test_kernel_gup_of_access_disabled_region,
-       test_kernel_gup_write_to_write_disabled_region,
-       test_executing_on_unreadable_memory,
-       test_implicit_mprotect_exec_only_memory,
-       test_mprotect_with_pkey_0,
-       test_ptrace_of_child,
-       test_pkey_init_state,
-       test_pkey_syscalls_on_non_allocated_pkey,
-       test_pkey_syscalls_bad_args,
-       test_pkey_alloc_exhaust,
-       test_pkey_alloc_free_attach_pkey0,
+struct pkey_test {
+       void (*func)(int *ptr, u16 pkey);
+       const char *name;
+};
+
+#define PKEY_TEST(fn) { fn, #fn }
+
+static struct pkey_test pkey_tests[] = {
+       PKEY_TEST(test_read_of_write_disabled_region),
+       PKEY_TEST(test_read_of_access_disabled_region),
+       PKEY_TEST(test_read_of_access_disabled_region_with_page_already_mapped),
+       PKEY_TEST(test_write_of_write_disabled_region),
+       PKEY_TEST(test_write_of_write_disabled_region_with_page_already_mapped),
+       PKEY_TEST(test_write_of_access_disabled_region),
+       PKEY_TEST(test_write_of_access_disabled_region_with_page_already_mapped),
+       PKEY_TEST(test_kernel_write_of_access_disabled_region),
+       PKEY_TEST(test_kernel_write_of_write_disabled_region),
+       PKEY_TEST(test_kernel_gup_of_access_disabled_region),
+       PKEY_TEST(test_kernel_gup_write_to_write_disabled_region),
+       PKEY_TEST(test_executing_on_unreadable_memory),
+       PKEY_TEST(test_implicit_mprotect_exec_only_memory),
+       PKEY_TEST(test_mprotect_with_pkey_0),
+       PKEY_TEST(test_ptrace_of_child),
+       PKEY_TEST(test_pkey_init_state),
+       PKEY_TEST(test_pkey_syscalls_on_non_allocated_pkey),
+       PKEY_TEST(test_pkey_syscalls_bad_args),
+       PKEY_TEST(test_pkey_alloc_exhaust),
+       PKEY_TEST(test_pkey_alloc_free_attach_pkey0),
 #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
-       test_ptrace_modifies_pkru,
+       PKEY_TEST(test_ptrace_modifies_pkru),
 #endif
 };
 
@@ -1735,7 +1742,7 @@ static void run_tests_once(void)
                dprintf1("test %d starting with pkey: %d\n", test_nr, pkey);
                ptr = malloc_pkey(PAGE_SIZE, prot, pkey);
                dprintf1("test %d starting...\n", test_nr);
-               pkey_tests[test_nr](ptr, pkey);
+               pkey_tests[test_nr].func(ptr, pkey);
                dprintf1("freeing test memory: %p\n", ptr);
                free_pkey_malloc(ptr);
                sys_pkey_free(pkey);
@@ -1746,7 +1753,7 @@ static void run_tests_once(void)
                tracing_off();
                close_test_fds();
 
-               printf("test %2d PASSED (iteration %d)\n", test_nr, iteration_nr);
+               printf("test %s PASSED (iteration %d)\n", pkey_tests[test_nr].name, iteration_nr);
                dprintf1("======================\n\n");
        }
        iteration_nr++;