From: David Hildenbrand <david@redhat.com>
To: Mark Brown <broonie@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Shuah Khan <shuah@kernel.org>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/4] selftests/mm: Add helper for logging test start and results
Date: Tue, 3 Jun 2025 14:37:41 +0200 [thread overview]
Message-ID: <63e00cf8-8592-4117-bb27-42bc8c1f8921@redhat.com> (raw)
In-Reply-To: <20250527-selftests-mm-cow-dedupe-v2-2-ff198df8e38e@kernel.org>
On 27.05.25 18:04, Mark Brown wrote:
> Several of the MM tests have a pattern of printing a description of the
> test to be run then reporting the actual TAP result using a generic string
> not connected to the specific test, often in a shared function used by many
> tests. The name reported typically varies depending on the specific result
> rather than the test too. This causes problems for tooling that works with
> test results, the names reported with the results are used to deduplicate
> tests and track them between runs so both duplicated names and changing
> names cause trouble for things like UIs and automated bisection.
>
> As a first step towards matching these tests better with the expectations
> of kselftest provide helpers which record the test name as part of the
> initial print and then use that as part of reporting a result.
>
> This is not added as a generic kselftest helper partly because the use of
> a variable to store the test name doesn't fit well with the header only
> implementation of kselftest.h and partly because it's not really an
> intended pattern. Ideally at some point the mm tests that use it will be
> updated to not need it.
>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
> tools/testing/selftests/mm/vm_util.h | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/tools/testing/selftests/mm/vm_util.h b/tools/testing/selftests/mm/vm_util.h
> index 6effafdc4d8a..4944e4c79051 100644
> --- a/tools/testing/selftests/mm/vm_util.h
> +++ b/tools/testing/selftests/mm/vm_util.h
> @@ -3,6 +3,7 @@
> #include <stdbool.h>
> #include <sys/mman.h>
> #include <err.h>
> +#include <stdarg.h>
> #include <strings.h> /* ffsl() */
> #include <unistd.h> /* _SC_PAGESIZE */
> #include "../kselftest.h"
> @@ -74,6 +75,25 @@ int uffd_register_with_ioctls(int uffd, void *addr, uint64_t len,
> unsigned long get_free_hugepages(void);
> bool check_vmflag_io(void *addr);
>
> +/* These helpers need to be inline to match the kselftest.h idiom. */
> +static char test_name[1024];
> +
> +static inline void log_test_start(const char *name, ...)
> +{
> + va_list args;
> + va_start(args, name);
> +
> + vsnprintf(test_name, sizeof(test_name), name, args);
> + ksft_print_msg("[RUN] %s\n", test_name);
> +
> + va_end(args);
> +}
> +
> +static inline void log_test_result(int result)
> +{
> + ksft_test_result_report(result, "%s\n", test_name);
> +}
Won't win a beauty contest, but should get the job done.
We could allocate the array in log_test_start() and free it in
log_test_result(). Then, we could assert more easily that we always have
a log_test_result() follow exactly one log_test_start() etc.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-06-03 12:37 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-27 16:04 [PATCH v2 0/4] selftests/mm: cow and gup_longterm cleanups Mark Brown
2025-05-27 16:04 ` [PATCH v2 1/4] selftests/mm: Use standard ksft_finished() in cow and gup_longterm Mark Brown
2025-05-27 16:04 ` [PATCH v2 2/4] selftests/mm: Add helper for logging test start and results Mark Brown
2025-06-03 12:37 ` David Hildenbrand [this message]
2025-06-03 18:27 ` Mark Brown
2025-06-03 20:18 ` David Hildenbrand
2025-05-27 16:04 ` [PATCH v2 3/4] selftests/mm: Report unique test names for each cow test Mark Brown
2025-06-03 12:51 ` David Hildenbrand
2025-06-03 13:21 ` Mark Brown
2025-06-03 14:15 ` David Hildenbrand
2025-06-03 14:58 ` Mark Brown
2025-06-03 15:06 ` David Hildenbrand
2025-06-03 15:22 ` Mark Brown
2025-06-03 16:57 ` David Hildenbrand
2025-06-03 17:48 ` Mark Brown
2025-06-03 17:55 ` Mark Brown
2025-06-03 20:21 ` David Hildenbrand
2025-05-27 16:04 ` [PATCH v2 4/4] selftests/mm: Fix test result reporting in gup_longterm Mark Brown
2025-06-03 12:36 ` David Hildenbrand
2025-06-03 13:05 ` Mark Brown
2025-06-05 16:00 ` Lorenzo Stoakes
2025-06-05 16:15 ` Mark Brown
2025-06-05 16:26 ` Lorenzo Stoakes
2025-06-05 16:42 ` Mark Brown
2025-06-05 16:55 ` David Hildenbrand
2025-06-05 17:19 ` Mark Brown
2025-06-05 17:34 ` David Hildenbrand
2025-06-05 18:24 ` Mark Brown
2025-06-05 17:09 ` Lorenzo Stoakes
2025-06-05 17:38 ` Mark Brown
2025-06-05 17:47 ` Lorenzo Stoakes
2025-06-05 18:29 ` Mark Brown
2025-06-05 18:35 ` Lorenzo Stoakes
2025-06-05 16:48 ` David Hildenbrand
2025-06-05 20:32 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=63e00cf8-8592-4117-bb27-42bc8c1f8921@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox