Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: mm: make map_fixed_noreplace test names stable

KTAP parsers interpret the output of ksft_test_result_*() as being the
name of the test. The map_fixed_noreplace test uses a dynamically
allocated base address for the mmap()s that it tests and currently
includes this in the test names that it logs so the test names that are
logged are not stable between runs. It also uses multiples of PAGE_SIZE
which mean that runs for kernels with different PAGE_SIZE configurations
can't be directly compared. Both these factors cause issues for CI
systems when interpreting and displaying results.

Fix this by replacing the current test names with fixed strings describing
the intent of the mappings that are logged, the existing messages with the
actual addresses and sizes are retained as diagnostic prints to aid in
debugging.

Link: https://lkml.kernel.org/r/20240605-kselftest-mm-fixed-noreplace-v1-1-a235db8b9be9@kernel.org
Fixes: 4838cf70e539 ("selftests/mm: map_fixed_noreplace: conform test to TAP format output")
Signed-off-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>
Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Mark Brown and committed by
Andrew Morton
e7d2a28b 653c5c75

+16 -8
+16 -8
tools/testing/selftests/mm/map_fixed_noreplace.c
··· 67 67 dump_maps(); 68 68 ksft_exit_fail_msg("Error: munmap failed!?\n"); 69 69 } 70 - ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 70 + ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 71 + ksft_test_result_pass("mmap() 5*PAGE_SIZE at base\n"); 71 72 72 73 addr = base_addr + page_size; 73 74 size = 3 * page_size; ··· 77 76 dump_maps(); 78 77 ksft_exit_fail_msg("Error: first mmap() failed unexpectedly\n"); 79 78 } 80 - ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 79 + ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 80 + ksft_test_result_pass("mmap() 3*PAGE_SIZE at base+PAGE_SIZE\n"); 81 81 82 82 /* 83 83 * Exact same mapping again: ··· 95 93 dump_maps(); 96 94 ksft_exit_fail_msg("Error:1: mmap() succeeded when it shouldn't have\n"); 97 95 } 98 - ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 96 + ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 97 + ksft_test_result_pass("mmap() 5*PAGE_SIZE at base\n"); 99 98 100 99 /* 101 100 * Second mapping contained within first: ··· 114 111 dump_maps(); 115 112 ksft_exit_fail_msg("Error:2: mmap() succeeded when it shouldn't have\n"); 116 113 } 117 - ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 114 + ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 115 + ksft_test_result_pass("mmap() 2*PAGE_SIZE at base+PAGE_SIZE\n"); 118 116 119 117 /* 120 118 * Overlap end of existing mapping: ··· 132 128 dump_maps(); 133 129 ksft_exit_fail_msg("Error:3: mmap() succeeded when it shouldn't have\n"); 134 130 } 135 - ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 131 + ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 132 + ksft_test_result_pass("mmap() 2*PAGE_SIZE at base+(3*PAGE_SIZE)\n"); 136 133 137 134 /* 138 135 * Overlap start of existing mapping: ··· 150 145 dump_maps(); 151 146 ksft_exit_fail_msg("Error:4: mmap() succeeded when it shouldn't have\n"); 152 147 } 153 - ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 148 + ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 149 + ksft_test_result_pass("mmap() 2*PAGE_SIZE bytes at base\n"); 154 150 155 151 /* 156 152 * Adjacent to start of existing mapping: ··· 168 162 dump_maps(); 169 163 ksft_exit_fail_msg("Error:5: mmap() failed when it shouldn't have\n"); 170 164 } 171 - ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 165 + ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 166 + ksft_test_result_pass("mmap() PAGE_SIZE at base\n"); 172 167 173 168 /* 174 169 * Adjacent to end of existing mapping: ··· 186 179 dump_maps(); 187 180 ksft_exit_fail_msg("Error:6: mmap() failed when it shouldn't have\n"); 188 181 } 189 - ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 182 + ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); 183 + ksft_test_result_pass("mmap() PAGE_SIZE at base+(4*PAGE_SIZE)\n"); 190 184 191 185 addr = base_addr; 192 186 size = 5 * page_size;