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@cloudflare.com> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
a724707976
commit
38c957f070
@ -56,6 +56,7 @@
|
|||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -1107,15 +1108,19 @@ void __run_test(struct __fixture_metadata *f,
|
|||||||
struct __fixture_variant_metadata *variant,
|
struct __fixture_variant_metadata *variant,
|
||||||
struct __test_metadata *t)
|
struct __test_metadata *t)
|
||||||
{
|
{
|
||||||
|
char test_name[LINE_MAX];
|
||||||
|
|
||||||
/* reset test struct */
|
/* reset test struct */
|
||||||
t->passed = 1;
|
t->passed = 1;
|
||||||
t->skip = 0;
|
t->skip = 0;
|
||||||
t->trigger = 0;
|
t->trigger = 0;
|
||||||
memset(t->results->reason, 0, sizeof(t->results->reason));
|
memset(t->results->reason, 0, sizeof(t->results->reason));
|
||||||
|
|
||||||
ksft_print_msg(" RUN %s%s%s.%s ...\n",
|
snprintf(test_name, sizeof(test_name), "%s%s%s.%s",
|
||||||
f->name, variant->name[0] ? "." : "", variant->name, t->name);
|
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 */
|
/* Make sure output buffers are flushed before fork */
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
@ -1135,15 +1140,14 @@ void __run_test(struct __fixture_metadata *f,
|
|||||||
} else {
|
} else {
|
||||||
__wait_for_test(t);
|
__wait_for_test(t);
|
||||||
}
|
}
|
||||||
ksft_print_msg(" %4s %s%s%s.%s\n", t->passed ? "OK" : "FAIL",
|
ksft_print_msg(" %4s %s\n",
|
||||||
f->name, variant->name[0] ? "." : "", variant->name, t->name);
|
t->passed ? "OK" : "FAIL", test_name);
|
||||||
|
|
||||||
if (t->skip)
|
if (t->skip)
|
||||||
ksft_test_result_skip("%s\n", t->results->reason[0] ?
|
ksft_test_result_skip("%s\n", t->results->reason[0] ?
|
||||||
t->results->reason : "unknown");
|
t->results->reason : "unknown");
|
||||||
else
|
else
|
||||||
ksft_test_result(t->passed, "%s%s%s.%s\n",
|
ksft_test_result(t->passed, "%s\n", test_name);
|
||||||
f->name, variant->name[0] ? "." : "", variant->name, t->name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int test_harness_run(int argc, char **argv)
|
static int test_harness_run(int argc, char **argv)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user