]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
kselftest/arm64: Use ksft_perror() to log MTE failures
authorMark Brown <broonie@kernel.org>
Tue, 29 Oct 2024 12:34:21 +0000 (12:34 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 1 Nov 2024 15:47:17 +0000 (15:47 +0000)
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 <broonie@kernel.org>
Acked-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Link: https://lore.kernel.org/r/20241029-arm64-mte-test-logging-v1-1-a128e732e36e@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
tools/testing/selftests/arm64/mte/mte_common_util.c

index 17fbe5cfe4724a2f6ea0c1b0d2cb32bd6766c1d9..a1dc2fe5285b88f7848d815e05ad2d071b8e623c 100644 (file)
@@ -150,13 +150,13 @@ static void *__mte_allocate_memory_range(size_t size, int mem_type, int mapping,
                map_flag |= MAP_PRIVATE;
        ptr = mmap(NULL, entire_size, prot_flag, map_flag, fd, 0);
        if (ptr == MAP_FAILED) {
-               ksft_print_msg("FAIL: mmap allocation\n");
+               ksft_perror("mmap()");
                return NULL;
        }
        if (mem_type == USE_MPROTECT) {
                if (mprotect(ptr, entire_size, prot_flag | PROT_MTE)) {
+                       ksft_perror("mprotect(PROT_MTE)");
                        munmap(ptr, size);
-                       ksft_print_msg("FAIL: mprotect PROT_MTE property\n");
                        return NULL;
                }
        }
@@ -190,13 +190,13 @@ void *mte_allocate_file_memory(size_t size, int mem_type, int mapping, bool tags
        lseek(fd, 0, SEEK_SET);
        for (index = INIT_BUFFER_SIZE; index < size; index += INIT_BUFFER_SIZE) {
                if (write(fd, buffer, INIT_BUFFER_SIZE) != INIT_BUFFER_SIZE) {
-                       perror("initialising buffer");
+                       ksft_perror("initialising buffer");
                        return NULL;
                }
        }
        index -= INIT_BUFFER_SIZE;
        if (write(fd, buffer, size - index) != size - index) {
-               perror("initialising buffer");
+               ksft_perror("initialising buffer");
                return NULL;
        }
        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,
        lseek(fd, 0, SEEK_SET);
        for (index = INIT_BUFFER_SIZE; index < map_size; index += INIT_BUFFER_SIZE)
                if (write(fd, buffer, INIT_BUFFER_SIZE) != INIT_BUFFER_SIZE) {
-                       perror("initialising buffer");
+                       ksft_perror("initialising buffer");
                        return NULL;
                }
        index -= INIT_BUFFER_SIZE;
        if (write(fd, buffer, map_size - index) != map_size - index) {
-               perror("initialising buffer");
+               ksft_perror("initialising buffer");
                return NULL;
        }
        return __mte_allocate_memory_range(size, mem_type, mapping, range_before,
@@ -358,7 +358,7 @@ int create_temp_file(void)
        /* Create a file in the tmpfs filesystem */
        fd = mkstemp(&filename[0]);
        if (fd == -1) {
-               perror(filename);
+               ksft_perror(filename);
                ksft_print_msg("FAIL: Unable to open temporary file\n");
                return 0;
        }