]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/mm: add messages about test errors to the cow tests
authorMark Brown <broonie@kernel.org>
Tue, 10 Jun 2025 14:13:57 +0000 (15:13 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 10 Jul 2025 05:42:04 +0000 (22:42 -0700)
It is not sufficiently clear what the individual tests in the cow test
program are checking so add messages for the failure cases.

Link: https://lkml.kernel.org/r/20250610-selftest-mm-cow-tweaks-v1-4-43cd7457500f@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Suggested-by: David Hildenbrand <david@redhat.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/mm/cow.c

index 48fcf03aa4cd985f423589b890c21046b517fa1e..29767e2afdd018edff8076e70a426b849a1bbaa0 100644 (file)
@@ -268,8 +268,10 @@ static void do_test_cow_in_parent(char *mem, size_t size, bool do_mprotect,
                 * fail because (a) harder to fix and (b) nobody really cares.
                 * Flag them as expected failure for now.
                 */
+               ksft_print_msg("Leak from parent into child\n");
                log_test_result(KSFT_XFAIL);
        } else {
+               ksft_print_msg("Leak from parent into child\n");
                log_test_result(KSFT_FAIL);
        }
 close_comm_pipes:
@@ -397,8 +399,10 @@ static void do_test_vmsplice_in_parent(char *mem, size_t size,
                 * fail because (a) harder to fix and (b) nobody really cares.
                 * Flag them as expected failure for now.
                 */
+               ksft_print_msg("Leak from child into parent\n");
                log_test_result(KSFT_XFAIL);
        } else {
+               ksft_print_msg("Leak from child into parent\n");
                log_test_result(KSFT_FAIL);
        }
 close_pipe:
@@ -570,10 +574,12 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork)
        }
 
        /* Finally, check if we read what we expected. */
-       if (!memcmp(mem, tmp, size))
+       if (!memcmp(mem, tmp, size)) {
                log_test_result(KSFT_PASS);
-       else
+       } else {
+               ksft_print_msg("Longtom R/W pin is not reliable\n");
                log_test_result(KSFT_FAIL);
+       }
 
 quit_child:
        if (use_fork) {
@@ -725,10 +731,12 @@ static void do_test_ro_pin(char *mem, size_t size, enum ro_pin_test test,
                ksft_perror("PIN_LONGTERM_TEST_READ failed");
                log_test_result(KSFT_FAIL);
        } else {
-               if (!memcmp(mem, tmp, size))
+               if (!memcmp(mem, tmp, size)) {
                        log_test_result(KSFT_PASS);
-               else
+               } else {
+                       ksft_print_msg("Longterm R/O pin is not reliable\n");
                        log_test_result(KSFT_FAIL);
+               }
        }
 
        ret = ioctl(gup_fd, PIN_LONGTERM_TEST_STOP);
@@ -1417,10 +1425,12 @@ static void do_test_anon_thp_collapse(char *mem, size_t size,
        else
                ret = -EINVAL;
 
-       if (!ret)
+       if (!ret) {
                log_test_result(KSFT_PASS);
-       else
+       } else {
+               ksft_print_msg("Leak from parent into child\n");
                log_test_result(KSFT_FAIL);
+       }
 close_comm_pipes:
        close_comm_pipes(&comm_pipes);
 }
@@ -1528,10 +1538,12 @@ static void test_cow(char *mem, const char *smem, size_t size)
        memset(mem, 0xff, size);
 
        /* See if we still read the old values via the other mapping. */
-       if (!memcmp(smem, old, size))
+       if (!memcmp(smem, old, size)) {
                log_test_result(KSFT_PASS);
-       else
+       } else {
+               ksft_print_msg("Other mapping modified\n");
                log_test_result(KSFT_FAIL);
+       }
        free(old);
 }