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

selftests/mm: mremap_dontunmap: conform test to TAP format output

Conform the layout, informational and status messages to TAP. No
functional change is intended other than the layout of output messages.

Link: https://lkml.kernel.org/r/20240202113119.2047740-8-usama.anjum@collabora.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>

authored by

Muhammad Usama Anjum and committed by
Andrew Morton
a0d47057 746f356f

+20 -12
+20 -12
tools/testing/selftests/mm/mremap_dontunmap.c
··· 27 27 system(cmd); 28 28 } 29 29 30 - #define BUG_ON(condition, description) \ 31 - do { \ 32 - if (condition) { \ 33 - fprintf(stderr, "[FAIL]\t%s():%d\t%s:%s\n", __func__, \ 34 - __LINE__, (description), strerror(errno)); \ 35 - dump_maps(); \ 36 - exit(1); \ 37 - } \ 30 + #define BUG_ON(condition, description) \ 31 + do { \ 32 + if (condition) { \ 33 + dump_maps(); \ 34 + ksft_exit_fail_msg("[FAIL]\t%s:%d\t%s:%s\n", \ 35 + __func__, __LINE__, (description), \ 36 + strerror(errno)); \ 37 + } \ 38 38 } while (0) 39 39 40 40 // Try a simple operation for to "test" for kernel support this prevents ··· 122 122 "unable to unmap destination mapping"); 123 123 BUG_ON(munmap(source_mapping, num_pages * page_size) == -1, 124 124 "unable to unmap source mapping"); 125 + ksft_test_result_pass("%s\n", __func__); 125 126 } 126 127 127 128 // This test validates that MREMAP_DONTUNMAP on a shared mapping works as expected. ··· 174 173 "unable to unmap destination mapping"); 175 174 BUG_ON(munmap(source_mapping, num_pages * page_size) == -1, 176 175 "unable to unmap source mapping"); 176 + ksft_test_result_pass("%s\n", __func__); 177 177 } 178 178 179 179 // This test validates MREMAP_DONTUNMAP will move page tables to a specific ··· 221 219 "unable to unmap destination mapping"); 222 220 BUG_ON(munmap(source_mapping, num_pages * page_size) == -1, 223 221 "unable to unmap source mapping"); 222 + ksft_test_result_pass("%s\n", __func__); 224 223 } 225 224 226 225 // This test validates that we can MREMAP_DONTUNMAP for a portion of an ··· 272 269 "unable to unmap destination mapping"); 273 270 BUG_ON(munmap(source_mapping, num_pages * page_size) == -1, 274 271 "unable to unmap source mapping"); 272 + ksft_test_result_pass("%s\n", __func__); 275 273 } 276 274 277 275 // This test validates that we can remap over only a portion of a mapping. ··· 332 328 "unable to unmap destination mapping"); 333 329 BUG_ON(munmap(source_mapping, 5 * page_size) == -1, 334 330 "unable to unmap source mapping"); 331 + ksft_test_result_pass("%s\n", __func__); 335 332 } 336 333 337 334 int main(void) 338 335 { 336 + ksft_print_header(); 337 + 339 338 page_size = sysconf(_SC_PAGE_SIZE); 340 339 341 340 // test for kernel support for MREMAP_DONTUNMAP skipping the test if 342 341 // not. 343 342 if (kernel_support_for_mremap_dontunmap() != 0) { 344 - printf("No kernel support for MREMAP_DONTUNMAP\n"); 345 - return KSFT_SKIP; 343 + ksft_print_msg("No kernel support for MREMAP_DONTUNMAP\n"); 344 + ksft_finished(); 346 345 } 346 + 347 + ksft_set_plan(5); 347 348 348 349 // Keep a page sized buffer around for when we need it. 349 350 page_buffer = ··· 365 356 BUG_ON(munmap(page_buffer, page_size) == -1, 366 357 "unable to unmap page buffer"); 367 358 368 - printf("OK\n"); 369 - return 0; 359 + ksft_finished(); 370 360 }