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

selftests/mm: virtual_address_range: conform 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-13-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 c811b0ce
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <errno.h> #include <errno.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/time.h> #include <sys/time.h>
#include "../kselftest.h"
/* /*
* Maximum address range mapped with a single mmap() * Maximum address range mapped with a single mmap()
...@@ -68,23 +69,15 @@ static char *hind_addr(void) ...@@ -68,23 +69,15 @@ static char *hind_addr(void)
return (char *) (1UL << bits); return (char *) (1UL << bits);
} }
static int validate_addr(char *ptr, int high_addr) static void validate_addr(char *ptr, int high_addr)
{ {
unsigned long addr = (unsigned long) ptr; unsigned long addr = (unsigned long) ptr;
if (high_addr) { if (high_addr && addr < HIGH_ADDR_MARK)
if (addr < HIGH_ADDR_MARK) { ksft_exit_fail_msg("Bad address %lx\n", addr);
printf("Bad address %lx\n", addr);
return 1;
}
return 0;
}
if (addr > HIGH_ADDR_MARK) { if (addr > HIGH_ADDR_MARK)
printf("Bad address %lx\n", addr); ksft_exit_fail_msg("Bad address %lx\n", addr);
return 1;
}
return 0;
} }
static int validate_lower_address_hint(void) static int validate_lower_address_hint(void)
...@@ -107,23 +100,29 @@ int main(int argc, char *argv[]) ...@@ -107,23 +100,29 @@ int main(int argc, char *argv[])
char *hint; char *hint;
unsigned long i, lchunks, hchunks; unsigned long i, lchunks, hchunks;
ksft_print_header();
ksft_set_plan(1);
for (i = 0; i < NR_CHUNKS_LOW; i++) { for (i = 0; i < NR_CHUNKS_LOW; i++) {
ptr[i] = mmap(NULL, MAP_CHUNK_SIZE, PROT_READ | PROT_WRITE, ptr[i] = mmap(NULL, MAP_CHUNK_SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (ptr[i] == MAP_FAILED) { if (ptr[i] == MAP_FAILED) {
if (validate_lower_address_hint()) if (validate_lower_address_hint()) {
return 1; ksft_test_result_skip("Memory constraint not fulfilled\n");
ksft_finished();
}
break; break;
} }
if (validate_addr(ptr[i], 0)) validate_addr(ptr[i], 0);
return 1;
} }
lchunks = i; lchunks = i;
hptr = (char **) calloc(NR_CHUNKS_HIGH, sizeof(char *)); hptr = (char **) calloc(NR_CHUNKS_HIGH, sizeof(char *));
if (hptr == NULL) if (hptr == NULL) {
return 1; ksft_test_result_skip("Memory constraint not fulfilled\n");
ksft_finished();
}
for (i = 0; i < NR_CHUNKS_HIGH; i++) { for (i = 0; i < NR_CHUNKS_HIGH; i++) {
hint = hind_addr(); hint = hind_addr();
...@@ -133,8 +132,7 @@ int main(int argc, char *argv[]) ...@@ -133,8 +132,7 @@ int main(int argc, char *argv[])
if (hptr[i] == MAP_FAILED) if (hptr[i] == MAP_FAILED)
break; break;
if (validate_addr(hptr[i], 1)) validate_addr(hptr[i], 1);
return 1;
} }
hchunks = i; hchunks = i;
...@@ -145,5 +143,7 @@ int main(int argc, char *argv[]) ...@@ -145,5 +143,7 @@ int main(int argc, char *argv[])
munmap(hptr[i], MAP_CHUNK_SIZE); munmap(hptr[i], MAP_CHUNK_SIZE);
free(hptr); free(hptr);
return 0;
ksft_test_result_pass("Test\n");
ksft_finished();
} }
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