Skip to content

Commit 17a2409

Browse files
brooniectmarinas
authored andcommitted
kselftest/arm64: Use ksft_perror() to log MTE failures
The logging in the allocation helpers variously uses ksft_print_msg() with very intermittent logging of errno and perror() (which won't produce KTAP conformant output) when logging the result of API calls that set errno. Standardise on using the ksft_perror() helper in these cases so that more information is available should the tests fail. Signed-off-by: Mark Brown <[email protected]> Acked-by: Lorenzo Stoakes <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent dca93d2 commit 17a2409

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tools/testing/selftests/arm64/mte/mte_common_util.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ static void *__mte_allocate_memory_range(size_t size, int mem_type, int mapping,
150150
map_flag |= MAP_PRIVATE;
151151
ptr = mmap(NULL, entire_size, prot_flag, map_flag, fd, 0);
152152
if (ptr == MAP_FAILED) {
153-
ksft_print_msg("FAIL: mmap allocation\n");
153+
ksft_perror("mmap()");
154154
return NULL;
155155
}
156156
if (mem_type == USE_MPROTECT) {
157157
if (mprotect(ptr, entire_size, prot_flag | PROT_MTE)) {
158+
ksft_perror("mprotect(PROT_MTE)");
158159
munmap(ptr, size);
159-
ksft_print_msg("FAIL: mprotect PROT_MTE property\n");
160160
return NULL;
161161
}
162162
}
@@ -190,13 +190,13 @@ void *mte_allocate_file_memory(size_t size, int mem_type, int mapping, bool tags
190190
lseek(fd, 0, SEEK_SET);
191191
for (index = INIT_BUFFER_SIZE; index < size; index += INIT_BUFFER_SIZE) {
192192
if (write(fd, buffer, INIT_BUFFER_SIZE) != INIT_BUFFER_SIZE) {
193-
perror("initialising buffer");
193+
ksft_perror("initialising buffer");
194194
return NULL;
195195
}
196196
}
197197
index -= INIT_BUFFER_SIZE;
198198
if (write(fd, buffer, size - index) != size - index) {
199-
perror("initialising buffer");
199+
ksft_perror("initialising buffer");
200200
return NULL;
201201
}
202202
return __mte_allocate_memory_range(size, mem_type, mapping, 0, 0, tags, fd);
@@ -217,12 +217,12 @@ void *mte_allocate_file_memory_tag_range(size_t size, int mem_type, int mapping,
217217
lseek(fd, 0, SEEK_SET);
218218
for (index = INIT_BUFFER_SIZE; index < map_size; index += INIT_BUFFER_SIZE)
219219
if (write(fd, buffer, INIT_BUFFER_SIZE) != INIT_BUFFER_SIZE) {
220-
perror("initialising buffer");
220+
ksft_perror("initialising buffer");
221221
return NULL;
222222
}
223223
index -= INIT_BUFFER_SIZE;
224224
if (write(fd, buffer, map_size - index) != map_size - index) {
225-
perror("initialising buffer");
225+
ksft_perror("initialising buffer");
226226
return NULL;
227227
}
228228
return __mte_allocate_memory_range(size, mem_type, mapping, range_before,
@@ -358,7 +358,7 @@ int create_temp_file(void)
358358
/* Create a file in the tmpfs filesystem */
359359
fd = mkstemp(&filename[0]);
360360
if (fd == -1) {
361-
perror(filename);
361+
ksft_perror(filename);
362362
ksft_print_msg("FAIL: Unable to open temporary file\n");
363363
return 0;
364364
}

0 commit comments

Comments
 (0)