[PATCH 6/7] selftests: vDSO: vdso_test_getrandom: Always print TAP header

Thomas Weißschuh posted 7 patches 9 months, 1 week ago
[PATCH 6/7] selftests: vDSO: vdso_test_getrandom: Always print TAP header
Posted by Thomas Weißschuh 9 months, 1 week ago
The TAP specification requires that the output begins with a header line.
If vgetrandom_init() fails and skips the test, that header line is missing.

Call vgetrandom_init() after ksft_print_header().

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
 tools/testing/selftests/vDSO/vdso_test_getrandom.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
index b0e0d664508a38d6dde9df0a61ec8198ee928a17..01892d8e65d754d0353f7df2b63910d5be8cd1bc 100644
--- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c
+++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
@@ -232,6 +232,7 @@ static void kselftest(void)
 	pid_t child;
 
 	ksft_print_header();
+	vgetrandom_init();
 	ksft_set_plan(2);
 
 	for (size_t i = 0; i < 1000; ++i) {
@@ -285,8 +286,6 @@ static void usage(const char *argv0)
 
 int main(int argc, char *argv[])
 {
-	vgetrandom_init();
-
 	if (argc == 1) {
 		kselftest();
 		return 0;
@@ -296,6 +295,9 @@ int main(int argc, char *argv[])
 		usage(argv[0]);
 		return 1;
 	}
+
+	vgetrandom_init();
+
 	if (!strcmp(argv[1], "bench-single"))
 		bench_single();
 	else if (!strcmp(argv[1], "bench-multi"))

-- 
2.49.0

Re: [PATCH 6/7] selftests: vDSO: vdso_test_getrandom: Always print TAP header
Posted by Muhammad Usama Anjum 9 months, 1 week ago
On 5/2/25 5:40 PM, Thomas Weißschuh wrote:
> The TAP specification requires that the output begins with a header line.
> If vgetrandom_init() fails and skips the test, that header line is missing.
> 
> Call vgetrandom_init() after ksft_print_header().
> 
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>

> ---
>  tools/testing/selftests/vDSO/vdso_test_getrandom.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
> index b0e0d664508a38d6dde9df0a61ec8198ee928a17..01892d8e65d754d0353f7df2b63910d5be8cd1bc 100644
> --- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c
> +++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
> @@ -232,6 +232,7 @@ static void kselftest(void)
>  	pid_t child;
>  
>  	ksft_print_header();
> +	vgetrandom_init();
>  	ksft_set_plan(2);
>  
>  	for (size_t i = 0; i < 1000; ++i) {
> @@ -285,8 +286,6 @@ static void usage(const char *argv0)
>  
>  int main(int argc, char *argv[])
>  {
> -	vgetrandom_init();
> -
>  	if (argc == 1) {
>  		kselftest();
>  		return 0;
> @@ -296,6 +295,9 @@ int main(int argc, char *argv[])
>  		usage(argv[0]);
>  		return 1;
>  	}
> +
> +	vgetrandom_init();
> +
>  	if (!strcmp(argv[1], "bench-single"))
>  		bench_single();
>  	else if (!strcmp(argv[1], "bench-multi"))
> 


-- 
Regards,
Usama