Skip to content

Commit e7d2a28

Browse files
broonieakpm00
authored andcommitted
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: 4838cf7 ("selftests/mm: map_fixed_noreplace: conform test to TAP format output") Signed-off-by: Mark Brown <[email protected]> Reviewed-by: Ryan Roberts <[email protected]> Cc: Muhammad Usama Anjum <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 653c5c7 commit e7d2a28

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

tools/testing/selftests/mm/map_fixed_noreplace.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ int main(void)
6767
dump_maps();
6868
ksft_exit_fail_msg("Error: munmap failed!?\n");
6969
}
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");
7172

7273
addr = base_addr + page_size;
7374
size = 3 * page_size;
@@ -76,7 +77,8 @@ int main(void)
7677
dump_maps();
7778
ksft_exit_fail_msg("Error: first mmap() failed unexpectedly\n");
7879
}
79-
ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
80+
ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
81+
ksft_test_result_pass("mmap() 3*PAGE_SIZE at base+PAGE_SIZE\n");
8082

8183
/*
8284
* Exact same mapping again:
@@ -93,7 +95,8 @@ int main(void)
9395
dump_maps();
9496
ksft_exit_fail_msg("Error:1: mmap() succeeded when it shouldn't have\n");
9597
}
96-
ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
98+
ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
99+
ksft_test_result_pass("mmap() 5*PAGE_SIZE at base\n");
97100

98101
/*
99102
* Second mapping contained within first:
@@ -111,7 +114,8 @@ int main(void)
111114
dump_maps();
112115
ksft_exit_fail_msg("Error:2: mmap() succeeded when it shouldn't have\n");
113116
}
114-
ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
117+
ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
118+
ksft_test_result_pass("mmap() 2*PAGE_SIZE at base+PAGE_SIZE\n");
115119

116120
/*
117121
* Overlap end of existing mapping:
@@ -128,7 +132,8 @@ int main(void)
128132
dump_maps();
129133
ksft_exit_fail_msg("Error:3: mmap() succeeded when it shouldn't have\n");
130134
}
131-
ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
135+
ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
136+
ksft_test_result_pass("mmap() 2*PAGE_SIZE at base+(3*PAGE_SIZE)\n");
132137

133138
/*
134139
* Overlap start of existing mapping:
@@ -145,7 +150,8 @@ int main(void)
145150
dump_maps();
146151
ksft_exit_fail_msg("Error:4: mmap() succeeded when it shouldn't have\n");
147152
}
148-
ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
153+
ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
154+
ksft_test_result_pass("mmap() 2*PAGE_SIZE bytes at base\n");
149155

150156
/*
151157
* Adjacent to start of existing mapping:
@@ -162,7 +168,8 @@ int main(void)
162168
dump_maps();
163169
ksft_exit_fail_msg("Error:5: mmap() failed when it shouldn't have\n");
164170
}
165-
ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
171+
ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
172+
ksft_test_result_pass("mmap() PAGE_SIZE at base\n");
166173

167174
/*
168175
* Adjacent to end of existing mapping:
@@ -179,7 +186,8 @@ int main(void)
179186
dump_maps();
180187
ksft_exit_fail_msg("Error:6: mmap() failed when it shouldn't have\n");
181188
}
182-
ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
189+
ksft_print_msg("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
190+
ksft_test_result_pass("mmap() PAGE_SIZE at base+(4*PAGE_SIZE)\n");
183191

184192
addr = base_addr;
185193
size = 5 * page_size;

0 commit comments

Comments
 (0)