[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240229005920.2407409-5-kuba@kernel.org>
Date: Wed, 28 Feb 2024 16:59:11 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org,
edumazet@...gle.com,
pabeni@...hat.com,
shuah@...nel.org,
linux-kselftest@...r.kernel.org,
mic@...ikod.net,
linux-security-module@...r.kernel.org,
keescook@...omium.org,
jakub@...udflare.com,
Jakub Kicinski <kuba@...nel.org>
Subject: [PATCH v4 04/12] selftests: kselftest_harness: generate test name once
Since we added variant support generating full test case
name takes 4 string arguments. We're about to need it
in another two places. Stop the duplication and print
once into a temporary buffer.
Suggested-by: Jakub Sitnicki <jakub@...udflare.com>
Acked-by: Kees Cook <keescook@...omium.org>
Signed-off-by: Jakub Kicinski <kuba@...nel.org>
---
tools/testing/selftests/kselftest_harness.h | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index 62ce258b0853..4a2bda6a67ed 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -56,6 +56,7 @@
#include <asm/types.h>
#include <ctype.h>
#include <errno.h>
+#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
@@ -1107,14 +1108,18 @@ void __run_test(struct __fixture_metadata *f,
struct __fixture_variant_metadata *variant,
struct __test_metadata *t)
{
+ char test_name[LINE_MAX];
+
/* reset test struct */
t->passed = 1;
t->skip = 0;
t->trigger = 0;
memset(t->results->reason, 0, sizeof(t->results->reason));
- ksft_print_msg(" RUN %s%s%s.%s ...\n",
- f->name, variant->name[0] ? "." : "", variant->name, t->name);
+ snprintf(test_name, sizeof(test_name), "%s%s%s.%s",
+ f->name, variant->name[0] ? "." : "", variant->name, t->name);
+
+ ksft_print_msg(" RUN %s ...\n", test_name);
/* Make sure output buffers are flushed before fork */
fflush(stdout);
@@ -1135,15 +1140,14 @@ void __run_test(struct __fixture_metadata *f,
} else {
__wait_for_test(t);
}
- ksft_print_msg(" %4s %s%s%s.%s\n", t->passed ? "OK" : "FAIL",
- f->name, variant->name[0] ? "." : "", variant->name, t->name);
+ ksft_print_msg(" %4s %s\n",
+ t->passed ? "OK" : "FAIL", test_name);
if (t->skip)
ksft_test_result_skip("%s\n", t->results->reason[0] ?
t->results->reason : "unknown");
else
- ksft_test_result(t->passed, "%s%s%s.%s\n",
- f->name, variant->name[0] ? "." : "", variant->name, t->name);
+ ksft_test_result(t->passed, "%s\n", test_name);
}
static int test_harness_run(int argc, char **argv)
--
2.43.2
Powered by blists - more mailing lists