]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests/mm: use standard ksft_finished() in cow and gup_longterm
authorMark Brown <broonie@kernel.org>
Tue, 27 May 2025 16:04:45 +0000 (17:04 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 1 Jun 2025 05:46:15 +0000 (22:46 -0700)
Patch series "selftests/mm: cow and gup_longterm cleanups", v2.

The bulk of these changes modify the cow and gup_longterm tests to report
unique and stable names for each test, bringing them into line with the
expectations of tooling that works with kselftest.  The string reported as
a test result is used by tooling to both deduplicate tests and track tests
between test runs, using the same string for multiple tests or changing
the string depending on test result causes problems for user interfaces
and automation such as bisection.

It was suggested that converting to use kselftest_harness.h would be a
good way of addressing this, however that really wants the set of tests to
run to be known at compile time but both test programs dynamically
enumarate the set of huge page sizes the system supports and test each.
Refactoring to handle this would be even more invasive than these changes
which are large but straightforward and repetitive.

A version of the main gup_longterm cleanup was previously sent separately,
this version factors out the helpers for logging the start of the test
since the cow test looks very similar.

This patch (of 4):

The cow and gup_longterm test programs open code something that looks a
lot like the standard ksft_finished() helper to summarise the test results
and provide an exit code, convert to use ksft_finished().

Link: https://lkml.kernel.org/r/20250527-selftests-mm-cow-dedupe-v2-0-ff198df8e38e@kernel.org
Link: https://lkml.kernel.org/r/20250527-selftests-mm-cow-dedupe-v2-1-ff198df8e38e@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/mm/cow.c
tools/testing/selftests/mm/gup_longterm.c

index b6cfe0a4b7dfd4114746454e1d82aae103b3e8af..e70cd3d900cc2dfca5341b991bdc25d434c9fbbc 100644 (file)
@@ -1771,7 +1771,6 @@ static int tests_per_non_anon_test_case(void)
 
 int main(int argc, char **argv)
 {
-       int err;
        struct thp_settings default_settings;
 
        ksft_print_header();
@@ -1811,9 +1810,5 @@ int main(int argc, char **argv)
                thp_restore_settings();
        }
 
-       err = ksft_get_fail_cnt();
-       if (err)
-               ksft_exit_fail_msg("%d out of %d tests failed\n",
-                                  err, ksft_test_num());
-       ksft_exit_pass();
+       ksft_finished();
 }
index 21595b20bbc391a0e5d0ab0563ac4ce5e1e0069f..e60e628091860fab63f94dff48c46f5c462793c0 100644 (file)
@@ -455,7 +455,7 @@ static int tests_per_test_case(void)
 
 int main(int argc, char **argv)
 {
-       int i, err;
+       int i;
 
        pagesize = getpagesize();
        nr_hugetlbsizes = detect_hugetlb_page_sizes(hugetlbsizes,
@@ -469,9 +469,5 @@ int main(int argc, char **argv)
        for (i = 0; i < ARRAY_SIZE(test_cases); i++)
                run_test_case(&test_cases[i]);
 
-       err = ksft_get_fail_cnt();
-       if (err)
-               ksft_exit_fail_msg("%d out of %d tests failed\n",
-                                  err, ksft_test_num());
-       ksft_exit_pass();
+       ksft_finished();
 }