Commit a0d47057 authored by Muhammad Usama Anjum's avatar Muhammad Usama Anjum Committed by Andrew Morton

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.comSigned-off-by: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 746f356f
...@@ -30,10 +30,10 @@ static void dump_maps(void) ...@@ -30,10 +30,10 @@ static void dump_maps(void)
#define BUG_ON(condition, description) \ #define BUG_ON(condition, description) \
do { \ do { \
if (condition) { \ if (condition) { \
fprintf(stderr, "[FAIL]\t%s():%d\t%s:%s\n", __func__, \
__LINE__, (description), strerror(errno)); \
dump_maps(); \ dump_maps(); \
exit(1); \ ksft_exit_fail_msg("[FAIL]\t%s:%d\t%s:%s\n", \
__func__, __LINE__, (description), \
strerror(errno)); \
} \ } \
} while (0) } while (0)
...@@ -122,6 +122,7 @@ static void mremap_dontunmap_simple() ...@@ -122,6 +122,7 @@ static void mremap_dontunmap_simple()
"unable to unmap destination mapping"); "unable to unmap destination mapping");
BUG_ON(munmap(source_mapping, num_pages * page_size) == -1, BUG_ON(munmap(source_mapping, num_pages * page_size) == -1,
"unable to unmap source mapping"); "unable to unmap source mapping");
ksft_test_result_pass("%s\n", __func__);
} }
// This test validates that MREMAP_DONTUNMAP on a shared mapping works as expected. // This test validates that MREMAP_DONTUNMAP on a shared mapping works as expected.
...@@ -173,6 +174,7 @@ static void mremap_dontunmap_simple_shmem() ...@@ -173,6 +174,7 @@ static void mremap_dontunmap_simple_shmem()
"unable to unmap destination mapping"); "unable to unmap destination mapping");
BUG_ON(munmap(source_mapping, num_pages * page_size) == -1, BUG_ON(munmap(source_mapping, num_pages * page_size) == -1,
"unable to unmap source mapping"); "unable to unmap source mapping");
ksft_test_result_pass("%s\n", __func__);
} }
// This test validates MREMAP_DONTUNMAP will move page tables to a specific // This test validates MREMAP_DONTUNMAP will move page tables to a specific
...@@ -219,6 +221,7 @@ static void mremap_dontunmap_simple_fixed() ...@@ -219,6 +221,7 @@ static void mremap_dontunmap_simple_fixed()
"unable to unmap destination mapping"); "unable to unmap destination mapping");
BUG_ON(munmap(source_mapping, num_pages * page_size) == -1, BUG_ON(munmap(source_mapping, num_pages * page_size) == -1,
"unable to unmap source mapping"); "unable to unmap source mapping");
ksft_test_result_pass("%s\n", __func__);
} }
// This test validates that we can MREMAP_DONTUNMAP for a portion of an // This test validates that we can MREMAP_DONTUNMAP for a portion of an
...@@ -269,6 +272,7 @@ static void mremap_dontunmap_partial_mapping() ...@@ -269,6 +272,7 @@ static void mremap_dontunmap_partial_mapping()
"unable to unmap destination mapping"); "unable to unmap destination mapping");
BUG_ON(munmap(source_mapping, num_pages * page_size) == -1, BUG_ON(munmap(source_mapping, num_pages * page_size) == -1,
"unable to unmap source mapping"); "unable to unmap source mapping");
ksft_test_result_pass("%s\n", __func__);
} }
// This test validates that we can remap over only a portion of a mapping. // This test validates that we can remap over only a portion of a mapping.
...@@ -328,19 +332,24 @@ static void mremap_dontunmap_partial_mapping_overwrite(void) ...@@ -328,19 +332,24 @@ static void mremap_dontunmap_partial_mapping_overwrite(void)
"unable to unmap destination mapping"); "unable to unmap destination mapping");
BUG_ON(munmap(source_mapping, 5 * page_size) == -1, BUG_ON(munmap(source_mapping, 5 * page_size) == -1,
"unable to unmap source mapping"); "unable to unmap source mapping");
ksft_test_result_pass("%s\n", __func__);
} }
int main(void) int main(void)
{ {
ksft_print_header();
page_size = sysconf(_SC_PAGE_SIZE); page_size = sysconf(_SC_PAGE_SIZE);
// test for kernel support for MREMAP_DONTUNMAP skipping the test if // test for kernel support for MREMAP_DONTUNMAP skipping the test if
// not. // not.
if (kernel_support_for_mremap_dontunmap() != 0) { if (kernel_support_for_mremap_dontunmap() != 0) {
printf("No kernel support for MREMAP_DONTUNMAP\n"); ksft_print_msg("No kernel support for MREMAP_DONTUNMAP\n");
return KSFT_SKIP; ksft_finished();
} }
ksft_set_plan(5);
// Keep a page sized buffer around for when we need it. // Keep a page sized buffer around for when we need it.
page_buffer = page_buffer =
mmap(NULL, page_size, PROT_READ | PROT_WRITE, mmap(NULL, page_size, PROT_READ | PROT_WRITE,
...@@ -356,6 +365,5 @@ int main(void) ...@@ -356,6 +365,5 @@ int main(void)
BUG_ON(munmap(page_buffer, page_size) == -1, BUG_ON(munmap(page_buffer, page_size) == -1,
"unable to unmap page buffer"); "unable to unmap page buffer");
printf("OK\n"); ksft_finished();
return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment