selftests/arm64: Print missing MTE TAP headers
authorMuhammad Usama Anjum <usama.anjum@arm.com>
Tue, 25 Aug 2026 11:18:34 +0000 (12:18 +0100)
committerWill Deacon <will@kernel.org>
Thu, 27 Aug 2026 14:18:39 +0000 (14:18 +0000)
Most MTE tests set a TAP plan and emit results without first printing
the TAP version header. Direct execution therefore starts with a plan
such as "1..20" instead of "TAP version 13".

The problem is particularly visible in the GCR_EL1 context-switch test.
It prints its plan before forking 1,024 child processes. When stdout is
fully buffered, the plan remains in the stdio buffer. Each child inherits
the pending "1..1" line and flushes its copy from exit(), producing
repeated plan lines.

ksft_print_header() prints the TAP header and enables line buffering.
Call it in every MTE test that is missing it. In the GCR_EL1 test, call
it before the plan so the plan is flushed before the children are
forked. In the remaining tests, call it before setup and prerequisite
checks so early failures and whole-test skips also retain the header.

Fixes: 29f080881601 ("kselftest/arm64: check GCR_EL1 after context switch")
Signed-off-by: Muhammad Usama Anjum <usama.anjum@arm.com>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Will Deacon <will@kernel.org>
tools/testing/selftests/arm64/mte/check_buffer_fill.c
tools/testing/selftests/arm64/mte/check_child_memory.c
tools/testing/selftests/arm64/mte/check_gcr_el1_cswitch.c
tools/testing/selftests/arm64/mte/check_hugetlb_options.c
tools/testing/selftests/arm64/mte/check_ksm_options.c
tools/testing/selftests/arm64/mte/check_mmap_options.c
tools/testing/selftests/arm64/mte/check_tags_inclusion.c
tools/testing/selftests/arm64/mte/check_user_mem.c

index ff4e075..039b1d7 100644 (file)
@@ -406,6 +406,8 @@ int main(int argc, char *argv[])
        size_t page_size = getpagesize();
        int item = ARRAY_SIZE(sizes);
 
+       ksft_print_header();
+
        sizes[item - 3] = page_size - 1;
        sizes[item - 2] = page_size;
        sizes[item - 1] = page_size + 1;
index 5e97ee7..e6a8acc 100644 (file)
@@ -146,6 +146,8 @@ int main(int argc, char *argv[])
        int err;
        int item = ARRAY_SIZE(sizes);
 
+       ksft_print_header();
+
        page_size = getpagesize();
        if (!page_size) {
                ksft_print_msg("ERR: Unable to get page size\n");
index 325bca0..d23f154 100644 (file)
@@ -131,6 +131,7 @@ int main(int argc, char *argv[])
        if (err)
                return err;
 
+       ksft_print_header();
        ksft_set_plan(1);
 
        evaluate_test(mte_gcr_fork_test(),
index aad1234..23e4a7a 100644 (file)
@@ -230,6 +230,8 @@ int main(int argc, char *argv[])
        void *map_ptr;
        unsigned long map_size;
 
+       ksft_print_header();
+
        err = mte_default_setup();
        if (err)
                return err;
index 0cf5fae..866f092 100644 (file)
@@ -132,6 +132,8 @@ int main(int argc, char *argv[])
 {
        int err;
 
+       ksft_print_header();
+
        err = mte_default_setup();
        if (err)
                return err;
index c100af3..492f2cd 100644 (file)
@@ -945,6 +945,8 @@ int main(int argc, char *argv[])
                },
        };
 
+       ksft_print_header();
+
        err = mte_default_setup();
        if (err)
                return err;
index 4b764f2..6b4fa67 100644 (file)
@@ -175,6 +175,8 @@ int main(int argc, char *argv[])
 {
        int err;
 
+       ksft_print_header();
+
        err = mte_default_setup();
        if (err)
                return err;
index fb7936c..af343aa 100644 (file)
@@ -201,6 +201,8 @@ int main(int argc, char *argv[])
        int tag_offsets[] = {page_sz, MT_GRANULE_SIZE};
        char test_name[TEST_NAME_MAX];
 
+       ksft_print_header();
+
        page_sz = getpagesize();
        if (!page_sz) {
                ksft_print_msg("ERR: Unable to get page size\n");