Skip to content

Commit d1d86ce

Browse files
musamaanjumakpm00
authored andcommitted
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.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>
1 parent c811b0c commit d1d86ce

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

tools/testing/selftests/mm/virtual_address_range.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <errno.h>
1313
#include <sys/mman.h>
1414
#include <sys/time.h>
15+
#include "../kselftest.h"
1516

1617
/*
1718
* Maximum address range mapped with a single mmap()
@@ -68,23 +69,15 @@ static char *hind_addr(void)
6869
return (char *) (1UL << bits);
6970
}
7071

71-
static int validate_addr(char *ptr, int high_addr)
72+
static void validate_addr(char *ptr, int high_addr)
7273
{
7374
unsigned long addr = (unsigned long) ptr;
7475

75-
if (high_addr) {
76-
if (addr < HIGH_ADDR_MARK) {
77-
printf("Bad address %lx\n", addr);
78-
return 1;
79-
}
80-
return 0;
81-
}
76+
if (high_addr && addr < HIGH_ADDR_MARK)
77+
ksft_exit_fail_msg("Bad address %lx\n", addr);
8278

83-
if (addr > HIGH_ADDR_MARK) {
84-
printf("Bad address %lx\n", addr);
85-
return 1;
86-
}
87-
return 0;
79+
if (addr > HIGH_ADDR_MARK)
80+
ksft_exit_fail_msg("Bad address %lx\n", addr);
8881
}
8982

9083
static int validate_lower_address_hint(void)
@@ -107,23 +100,29 @@ int main(int argc, char *argv[])
107100
char *hint;
108101
unsigned long i, lchunks, hchunks;
109102

103+
ksft_print_header();
104+
ksft_set_plan(1);
105+
110106
for (i = 0; i < NR_CHUNKS_LOW; i++) {
111107
ptr[i] = mmap(NULL, MAP_CHUNK_SIZE, PROT_READ | PROT_WRITE,
112108
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
113109

114110
if (ptr[i] == MAP_FAILED) {
115-
if (validate_lower_address_hint())
116-
return 1;
111+
if (validate_lower_address_hint()) {
112+
ksft_test_result_skip("Memory constraint not fulfilled\n");
113+
ksft_finished();
114+
}
117115
break;
118116
}
119117

120-
if (validate_addr(ptr[i], 0))
121-
return 1;
118+
validate_addr(ptr[i], 0);
122119
}
123120
lchunks = i;
124121
hptr = (char **) calloc(NR_CHUNKS_HIGH, sizeof(char *));
125-
if (hptr == NULL)
126-
return 1;
122+
if (hptr == NULL) {
123+
ksft_test_result_skip("Memory constraint not fulfilled\n");
124+
ksft_finished();
125+
}
127126

128127
for (i = 0; i < NR_CHUNKS_HIGH; i++) {
129128
hint = hind_addr();
@@ -133,8 +132,7 @@ int main(int argc, char *argv[])
133132
if (hptr[i] == MAP_FAILED)
134133
break;
135134

136-
if (validate_addr(hptr[i], 1))
137-
return 1;
135+
validate_addr(hptr[i], 1);
138136
}
139137
hchunks = i;
140138

@@ -145,5 +143,7 @@ int main(int argc, char *argv[])
145143
munmap(hptr[i], MAP_CHUNK_SIZE);
146144

147145
free(hptr);
148-
return 0;
146+
147+
ksft_test_result_pass("Test\n");
148+
ksft_finished();
149149
}

0 commit comments

Comments
 (0)