Re: [PATCH v2 4/4] selftests/mm: Fix test result reporting in gup_longterm

From: David Hildenbrand
Date: Tue Jun 03 2025 - 08:36:20 EST


On 27.05.25 18:04, Mark Brown wrote:
The kselftest framework uses the string logged when a test result is
reported as the unique identifier for a test, using it to track test
results between runs. The gup_longterm test fails to follow this
pattern, it runs a single test function repeatedly with various
parameters but each result report is a string logging an error message
which is fixed between runs.

Since the code already logs each test uniquely before it starts refactor
to also print this to a buffer, then use that name as the test result.
This isn't especially pretty but is relatively straightforward and is a
great help to tooling.

Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
---
tools/testing/selftests/mm/gup_longterm.c | 150 +++++++++++++++++++-----------
1 file changed, 94 insertions(+), 56 deletions(-)

diff --git a/tools/testing/selftests/mm/gup_longterm.c b/tools/testing/selftests/mm/gup_longterm.c
index e60e62809186..f84ea97c2543 100644
--- a/tools/testing/selftests/mm/gup_longterm.c
+++ b/tools/testing/selftests/mm/gup_longterm.c
@@ -93,33 +93,48 @@ static void do_test(int fd, size_t size, enum test_type type, bool shared)
__fsword_t fs_type = get_fs_type(fd);
bool should_work;
char *mem;
+ int result = KSFT_PASS;
int ret;
+ if (fd < 0) {
+ result = KSFT_FAIL;
+ goto report;
+ }

Not a fan of that, especially as it suddenly converts ksft_test_result_skip() -- e.g., on the memfd path -- to KSFT_FAIL.

Can we just do the log_test_result(KSFT_FAIL/KSFT_SKIP) in the caller?


--
Cheers,

David / dhildenb