linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/9] selftests: vDSO: Some cleanups and (warning) fixes
@ 2025-06-11 10:33 Thomas Weißschuh
  2025-06-11 10:33 ` [PATCH v3 1/9] selftests: vDSO: chacha: Correctly skip test if necessary Thomas Weißschuh
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Thomas Weißschuh @ 2025-06-11 10:33 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, Shuah Khan,
	Jason A. Donenfeld
  Cc: Shuah Khan, linux-kernel, linux-kselftest, Muhammad Usama Anjum,
	Thomas Weißschuh

Fixes and cleanups for various issues in the vDSO selftests.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Changes in v3:
- Rebase on v6.16-rc1
- Preserve vgetrandom_put_state()
- Pick up vdso_standalone_test_x86 into this series
- Link to v2: https://lore.kernel.org/r/20250505-selftests-vdso-fixes-v2-0-3bc86e42f242@linutronix.de

Changes in v2:
- Refer to -Wstrict-prototypes over -Wold-style-prototypes
- Pick up Acks
- Enable fixed warnings in Makefile
- Link to v1: https://lore.kernel.org/r/20250502-selftests-vdso-fixes-v1-0-fb5d640a4f78@linutronix.de

---
Thomas Weißschuh (9):
      selftests: vDSO: chacha: Correctly skip test if necessary
      selftests: vDSO: clock_getres: Drop unused include of err.h
      selftests: vDSO: vdso_test_getrandom: Drop unused include of linux/compiler.h
      selftests: vDSO: vdso_test_getrandom: Avoid -Wunused
      selftests: vDSO: vdso_config: Avoid -Wunused-variables
      selftests: vDSO: enable -Wall
      selftests: vDSO: vdso_test_correctness: Fix -Wstrict-prototypes
      selftests: vDSO: vdso_test_getrandom: Always print TAP header
      selftests: vDSO: vdso_standalone_test_x86: Replace source file with symlink

 tools/testing/selftests/vDSO/Makefile              |  2 +-
 tools/testing/selftests/vDSO/vdso_config.h         |  2 +
 .../selftests/vDSO/vdso_standalone_test_x86.c      | 59 +---------------------
 tools/testing/selftests/vDSO/vdso_test_chacha.c    |  3 +-
 .../selftests/vDSO/vdso_test_clock_getres.c        |  1 -
 .../testing/selftests/vDSO/vdso_test_correctness.c |  2 +-
 tools/testing/selftests/vDSO/vdso_test_getrandom.c | 10 ++--
 7 files changed, 13 insertions(+), 66 deletions(-)
---
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
change-id: 20250423-selftests-vdso-fixes-d2ce74142359

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh@linutronix.de>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 1/9] selftests: vDSO: chacha: Correctly skip test if necessary
  2025-06-11 10:33 [PATCH v3 0/9] selftests: vDSO: Some cleanups and (warning) fixes Thomas Weißschuh
@ 2025-06-11 10:33 ` Thomas Weißschuh
  2025-06-11 10:33 ` [PATCH v3 2/9] selftests: vDSO: clock_getres: Drop unused include of err.h Thomas Weißschuh
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Weißschuh @ 2025-06-11 10:33 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, Shuah Khan,
	Jason A. Donenfeld
  Cc: Shuah Khan, linux-kernel, linux-kselftest, Muhammad Usama Anjum,
	Thomas Weißschuh

According to kselftest.h ksft_exit_skip() is not meant to be called when
a plan has already been printed.

Use the recommended function ksft_test_result_skip().

This fixes a bug, where the TAP output would be invalid when skipping:

	TAP version 13
	1..1
	ok 2 # SKIP Not implemented on architecture

The SKIP line should start with "ok 1" as the plan only contains one test.

Fixes: 3b5992eaf730 ("selftests: vDSO: unconditionally build chacha test")
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
I'm not sure if this is not a general bug in ksft_exit_skip().
First ksft_xskip is incremented then read back through ksft_test_num() and
then that result is incremented again.

In any case, using the correct function is better.
---
 tools/testing/selftests/vDSO/vdso_test_chacha.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/vDSO/vdso_test_chacha.c b/tools/testing/selftests/vDSO/vdso_test_chacha.c
index 8757f738b0b1a76a48c83c5e5df79925a30c1bc7..0aad682b12c8836efabb49a65a47cf87466891a3 100644
--- a/tools/testing/selftests/vDSO/vdso_test_chacha.c
+++ b/tools/testing/selftests/vDSO/vdso_test_chacha.c
@@ -76,7 +76,8 @@ static void reference_chacha20_blocks(uint8_t *dst_bytes, const uint32_t *key, u
 
 void __weak __arch_chacha20_blocks_nostack(uint8_t *dst_bytes, const uint32_t *key, uint32_t *counter, size_t nblocks)
 {
-	ksft_exit_skip("Not implemented on architecture\n");
+	ksft_test_result_skip("Not implemented on architecture\n");
+	ksft_finished();
 }
 
 int main(int argc, char *argv[])

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 2/9] selftests: vDSO: clock_getres: Drop unused include of err.h
  2025-06-11 10:33 [PATCH v3 0/9] selftests: vDSO: Some cleanups and (warning) fixes Thomas Weißschuh
  2025-06-11 10:33 ` [PATCH v3 1/9] selftests: vDSO: chacha: Correctly skip test if necessary Thomas Weißschuh
@ 2025-06-11 10:33 ` Thomas Weißschuh
  2025-06-11 10:33 ` [PATCH v3 3/9] selftests: vDSO: vdso_test_getrandom: Drop unused include of linux/compiler.h Thomas Weißschuh
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Weißschuh @ 2025-06-11 10:33 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, Shuah Khan,
	Jason A. Donenfeld
  Cc: Shuah Khan, linux-kernel, linux-kselftest, Muhammad Usama Anjum,
	Thomas Weißschuh

Nothing from err.h is used.

Drop the include.

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_clock_getres.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c b/tools/testing/selftests/vDSO/vdso_test_clock_getres.c
index 38d46a8bf7cba7a9b4a9b13b5eb17aa207972bd0..b5d5f59f725a703c357dfca91bfe170aaaeb42fa 100644
--- a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c
+++ b/tools/testing/selftests/vDSO/vdso_test_clock_getres.c
@@ -13,7 +13,6 @@
 
 #define _GNU_SOURCE
 #include <elf.h>
-#include <err.h>
 #include <fcntl.h>
 #include <stdint.h>
 #include <stdio.h>

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 3/9] selftests: vDSO: vdso_test_getrandom: Drop unused include of linux/compiler.h
  2025-06-11 10:33 [PATCH v3 0/9] selftests: vDSO: Some cleanups and (warning) fixes Thomas Weißschuh
  2025-06-11 10:33 ` [PATCH v3 1/9] selftests: vDSO: chacha: Correctly skip test if necessary Thomas Weißschuh
  2025-06-11 10:33 ` [PATCH v3 2/9] selftests: vDSO: clock_getres: Drop unused include of err.h Thomas Weißschuh
@ 2025-06-11 10:33 ` Thomas Weißschuh
  2025-06-11 10:33 ` [PATCH v3 4/9] selftests: vDSO: vdso_test_getrandom: Avoid -Wunused Thomas Weißschuh
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Weißschuh @ 2025-06-11 10:33 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, Shuah Khan,
	Jason A. Donenfeld
  Cc: Shuah Khan, linux-kernel, linux-kselftest, Muhammad Usama Anjum,
	Thomas Weißschuh

The header is unused. Furthermore this is not a real UAPI header,
but only exists in tools/include/.
This prevents building the selftest against real UAPI headers.

Drop the include.

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

diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
index 95057f7567db22226d9cb09a667a56e387a33a46..f36e50f372f935e6d4da3175c81e210653bdce1d 100644
--- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c
+++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
@@ -21,7 +21,6 @@
 #include <sys/wait.h>
 #include <sys/types.h>
 #include <linux/random.h>
-#include <linux/compiler.h>
 #include <linux/ptrace.h>
 
 #include "../kselftest.h"

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 4/9] selftests: vDSO: vdso_test_getrandom: Avoid -Wunused
  2025-06-11 10:33 [PATCH v3 0/9] selftests: vDSO: Some cleanups and (warning) fixes Thomas Weißschuh
                   ` (2 preceding siblings ...)
  2025-06-11 10:33 ` [PATCH v3 3/9] selftests: vDSO: vdso_test_getrandom: Drop unused include of linux/compiler.h Thomas Weißschuh
@ 2025-06-11 10:33 ` Thomas Weißschuh
  2025-06-11 10:33 ` [PATCH v3 5/9] selftests: vDSO: vdso_config: Avoid -Wunused-variables Thomas Weißschuh
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Weißschuh @ 2025-06-11 10:33 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, Shuah Khan,
	Jason A. Donenfeld
  Cc: Shuah Khan, linux-kernel, linux-kselftest, Muhammad Usama Anjum,
	Thomas Weißschuh

vgetrandom_put_state() and the variable "ret" in kselftest() are unused.

Drop the variable "ret". Suppress the warning for  vgetrandom_put_state()
as it is meant as an example for libc implementors.

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

diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
index f36e50f372f935e6d4da3175c81e210653bdce1d..389ead4e1fe3761f265f7b589b417b6d9f25c565 100644
--- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c
+++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
@@ -100,6 +100,7 @@ static void *vgetrandom_get_state(void)
 	return state;
 }
 
+__attribute__((unused)) /* Example for libc implementors */
 static void vgetrandom_put_state(void *state)
 {
 	if (!state)
@@ -264,7 +265,7 @@ static void kselftest(void)
 	}
 	for (;;) {
 		struct ptrace_syscall_info info = { 0 };
-		int status, ret;
+		int status;
 		ksft_assert(waitpid(child, &status, 0) >= 0);
 		if (WIFEXITED(status)) {
 			ksft_assert(WEXITSTATUS(status) == 0);

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 5/9] selftests: vDSO: vdso_config: Avoid -Wunused-variables
  2025-06-11 10:33 [PATCH v3 0/9] selftests: vDSO: Some cleanups and (warning) fixes Thomas Weißschuh
                   ` (3 preceding siblings ...)
  2025-06-11 10:33 ` [PATCH v3 4/9] selftests: vDSO: vdso_test_getrandom: Avoid -Wunused Thomas Weißschuh
@ 2025-06-11 10:33 ` Thomas Weißschuh
  2025-06-11 10:33 ` [PATCH v3 6/9] selftests: vDSO: enable -Wall Thomas Weißschuh
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Weißschuh @ 2025-06-11 10:33 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, Shuah Khan,
	Jason A. Donenfeld
  Cc: Shuah Khan, linux-kernel, linux-kselftest, Muhammad Usama Anjum,
	Thomas Weißschuh

Not all users of this header make use of all its variables.
For example vdso_test_correctness.c does not use "versions":

In file included from vdso_test_correctness.c:22:
vdso_config.h:61:20: warning: ‘versions’ defined but not used [-Wunused-variable]
   61 | static const char *versions[7] = {
      |                    ^~~~~~~~

Avoid those warnings through attribute((unused)).

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/vDSO/vdso_config.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/vDSO/vdso_config.h b/tools/testing/selftests/vDSO/vdso_config.h
index 722260f9756198956f0dfccced907284b6851e76..5fdd0f36233742bc47ae79f23d2cfae5a0f56dee 100644
--- a/tools/testing/selftests/vDSO/vdso_config.h
+++ b/tools/testing/selftests/vDSO/vdso_config.h
@@ -58,6 +58,7 @@
 #define VDSO_NAMES		1
 #endif
 
+__attribute__((unused))
 static const char *versions[7] = {
 	"LINUX_2.6",
 	"LINUX_2.6.15",
@@ -68,6 +69,7 @@ static const char *versions[7] = {
 	"LINUX_5.10"
 };
 
+__attribute__((unused))
 static const char *names[2][7] = {
 	{
 		"__kernel_gettimeofday",

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 6/9] selftests: vDSO: enable -Wall
  2025-06-11 10:33 [PATCH v3 0/9] selftests: vDSO: Some cleanups and (warning) fixes Thomas Weißschuh
                   ` (4 preceding siblings ...)
  2025-06-11 10:33 ` [PATCH v3 5/9] selftests: vDSO: vdso_config: Avoid -Wunused-variables Thomas Weißschuh
@ 2025-06-11 10:33 ` Thomas Weißschuh
  2025-06-11 10:33 ` [PATCH v3 7/9] selftests: vDSO: vdso_test_correctness: Fix -Wstrict-prototypes Thomas Weißschuh
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Weißschuh @ 2025-06-11 10:33 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, Shuah Khan,
	Jason A. Donenfeld
  Cc: Shuah Khan, linux-kernel, linux-kselftest, Muhammad Usama Anjum,
	Thomas Weißschuh

Protect against common programming errors through compiler warnings.
These warnings are also used for the kernel itself.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
 tools/testing/selftests/vDSO/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/vDSO/Makefile b/tools/testing/selftests/vDSO/Makefile
index 12a0614b9fd4983deffe5d6a7cfa06ba8d92a516..06d72254ec75dbdcc2b20935534199fabc40a9de 100644
--- a/tools/testing/selftests/vDSO/Makefile
+++ b/tools/testing/selftests/vDSO/Makefile
@@ -12,7 +12,7 @@ TEST_GEN_PROGS += vdso_test_correctness
 TEST_GEN_PROGS += vdso_test_getrandom
 TEST_GEN_PROGS += vdso_test_chacha
 
-CFLAGS := -std=gnu99 -O2
+CFLAGS := -std=gnu99 -O2 -Wall
 
 ifeq ($(CONFIG_X86_32),y)
 LDLIBS += -lgcc_s

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 7/9] selftests: vDSO: vdso_test_correctness: Fix -Wstrict-prototypes
  2025-06-11 10:33 [PATCH v3 0/9] selftests: vDSO: Some cleanups and (warning) fixes Thomas Weißschuh
                   ` (5 preceding siblings ...)
  2025-06-11 10:33 ` [PATCH v3 6/9] selftests: vDSO: enable -Wall Thomas Weißschuh
@ 2025-06-11 10:33 ` Thomas Weißschuh
  2025-06-11 10:33 ` [PATCH v3 8/9] selftests: vDSO: vdso_test_getrandom: Always print TAP header Thomas Weißschuh
  2025-06-11 10:33 ` [PATCH v3 9/9] selftests: vDSO: vdso_standalone_test_x86: Replace source file with symlink Thomas Weißschuh
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Weißschuh @ 2025-06-11 10:33 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, Shuah Khan,
	Jason A. Donenfeld
  Cc: Shuah Khan, linux-kernel, linux-kselftest, Muhammad Usama Anjum,
	Thomas Weißschuh

Functions definitions without any argument list produce a warning with
-Wstrict-prototypes:

vdso_test_correctness.c:111:13: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
  111 | static void fill_function_pointers()
      |             ^~~~~~~~~~~~~~~~~~~~~~

Explicitly use an empty argument list.

Now that all selftests a free of this warning, enable it in the Makefile.

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

diff --git a/tools/testing/selftests/vDSO/Makefile b/tools/testing/selftests/vDSO/Makefile
index 06d72254ec75dbdcc2b20935534199fabc40a9de..918a2caa070ebc681a9525f0518afffcf10f5ae3 100644
--- a/tools/testing/selftests/vDSO/Makefile
+++ b/tools/testing/selftests/vDSO/Makefile
@@ -12,7 +12,7 @@ TEST_GEN_PROGS += vdso_test_correctness
 TEST_GEN_PROGS += vdso_test_getrandom
 TEST_GEN_PROGS += vdso_test_chacha
 
-CFLAGS := -std=gnu99 -O2 -Wall
+CFLAGS := -std=gnu99 -O2 -Wall -Wstrict-prototypes
 
 ifeq ($(CONFIG_X86_32),y)
 LDLIBS += -lgcc_s
diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c b/tools/testing/selftests/vDSO/vdso_test_correctness.c
index 5fb97ad67eeaf17b6cfa4f82783c57894f03e5c5..da651cf53c6ca4242085de109c7fc57bd807297c 100644
--- a/tools/testing/selftests/vDSO/vdso_test_correctness.c
+++ b/tools/testing/selftests/vDSO/vdso_test_correctness.c
@@ -108,7 +108,7 @@ static void *vsyscall_getcpu(void)
 }
 
 
-static void fill_function_pointers()
+static void fill_function_pointers(void)
 {
 	void *vdso = dlopen("linux-vdso.so.1",
 			    RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD);

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 8/9] selftests: vDSO: vdso_test_getrandom: Always print TAP header
  2025-06-11 10:33 [PATCH v3 0/9] selftests: vDSO: Some cleanups and (warning) fixes Thomas Weißschuh
                   ` (6 preceding siblings ...)
  2025-06-11 10:33 ` [PATCH v3 7/9] selftests: vDSO: vdso_test_correctness: Fix -Wstrict-prototypes Thomas Weißschuh
@ 2025-06-11 10:33 ` Thomas Weißschuh
  2025-06-11 10:33 ` [PATCH v3 9/9] selftests: vDSO: vdso_standalone_test_x86: Replace source file with symlink Thomas Weißschuh
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Weißschuh @ 2025-06-11 10:33 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, Shuah Khan,
	Jason A. Donenfeld
  Cc: Shuah Khan, linux-kernel, linux-kselftest, Muhammad Usama Anjum,
	Thomas Weißschuh

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 389ead4e1fe3761f265f7b589b417b6d9f25c565..dd1132508a0db29a32ec977b30f64b20aa43e03d 100644
--- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c
+++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
@@ -242,6 +242,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) {
@@ -295,8 +296,6 @@ static void usage(const char *argv0)
 
 int main(int argc, char *argv[])
 {
-	vgetrandom_init();
-
 	if (argc == 1) {
 		kselftest();
 		return 0;
@@ -306,6 +305,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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 9/9] selftests: vDSO: vdso_standalone_test_x86: Replace source file with symlink
  2025-06-11 10:33 [PATCH v3 0/9] selftests: vDSO: Some cleanups and (warning) fixes Thomas Weißschuh
                   ` (7 preceding siblings ...)
  2025-06-11 10:33 ` [PATCH v3 8/9] selftests: vDSO: vdso_test_getrandom: Always print TAP header Thomas Weißschuh
@ 2025-06-11 10:33 ` Thomas Weißschuh
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Weißschuh @ 2025-06-11 10:33 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, Shuah Khan,
	Jason A. Donenfeld
  Cc: Shuah Khan, linux-kernel, linux-kselftest, Muhammad Usama Anjum,
	Thomas Weißschuh

With the switch over to nolibc the source file vdso_standalone_test_x86.c
was intended to be replaced with a symlink to vdso_test_gettimeofday.c.
This was the patch that was submitted to LKML, but during application the
symlink was replaced by a textual copy of the linked-to file.

Having two copies introduces the possibility of divergence and increases
maintenance burden, switch back to a symlink.

Link: https://lore.kernel.org/lkml/20250226-parse_vdso-nolibc-v2-16-28e14e031ed8@linutronix.de/
Fixes: 8770a9183fe1 ("selftests: vDSO: vdso_standalone_test_x86: Switch to nolibc")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

---
If symlinks are problematic an #include shim would also work.
These are not handled really well by the kselftests build system though,
as #include dependencies are not tracked by it.
---
 .../selftests/vDSO/vdso_standalone_test_x86.c      | 59 +---------------------
 1 file changed, 1 insertion(+), 58 deletions(-)

diff --git a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c
deleted file mode 100644
index 9ce795b806f0992b83cef78c7e16fac0e54750da..0000000000000000000000000000000000000000
--- a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c
+++ /dev/null
@@ -1,58 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * vdso_test_gettimeofday.c: Sample code to test parse_vdso.c and
- *                           vDSO gettimeofday()
- * Copyright (c) 2014 Andy Lutomirski
- *
- * Compile with:
- * gcc -std=gnu99 vdso_test_gettimeofday.c parse_vdso_gettimeofday.c
- *
- * Tested on x86, 32-bit and 64-bit.  It may work on other architectures, too.
- */
-
-#include <stdio.h>
-#ifndef NOLIBC
-#include <sys/auxv.h>
-#include <sys/time.h>
-#endif
-
-#include "../kselftest.h"
-#include "parse_vdso.h"
-#include "vdso_config.h"
-#include "vdso_call.h"
-
-int main(int argc, char **argv)
-{
-	const char *version = versions[VDSO_VERSION];
-	const char **name = (const char **)&names[VDSO_NAMES];
-
-	unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
-	if (!sysinfo_ehdr) {
-		printf("AT_SYSINFO_EHDR is not present!\n");
-		return KSFT_SKIP;
-	}
-
-	vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR));
-
-	/* Find gettimeofday. */
-	typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz);
-	gtod_t gtod = (gtod_t)vdso_sym(version, name[0]);
-
-	if (!gtod) {
-		printf("Could not find %s\n", name[0]);
-		return KSFT_SKIP;
-	}
-
-	struct timeval tv;
-	long ret = VDSO_CALL(gtod, 2, &tv, 0);
-
-	if (ret == 0) {
-		printf("The time is %lld.%06lld\n",
-		       (long long)tv.tv_sec, (long long)tv.tv_usec);
-	} else {
-		printf("%s failed\n", name[0]);
-		return KSFT_FAIL;
-	}
-
-	return 0;
-}
diff --git a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c
new file mode 120000
index 0000000000000000000000000000000000000000..4d3d96f1e440c965474681a6f35375a60b3921be
--- /dev/null
+++ b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c
@@ -0,0 +1 @@
+vdso_test_gettimeofday.c
\ No newline at end of file

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-06-11 10:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-11 10:33 [PATCH v3 0/9] selftests: vDSO: Some cleanups and (warning) fixes Thomas Weißschuh
2025-06-11 10:33 ` [PATCH v3 1/9] selftests: vDSO: chacha: Correctly skip test if necessary Thomas Weißschuh
2025-06-11 10:33 ` [PATCH v3 2/9] selftests: vDSO: clock_getres: Drop unused include of err.h Thomas Weißschuh
2025-06-11 10:33 ` [PATCH v3 3/9] selftests: vDSO: vdso_test_getrandom: Drop unused include of linux/compiler.h Thomas Weißschuh
2025-06-11 10:33 ` [PATCH v3 4/9] selftests: vDSO: vdso_test_getrandom: Avoid -Wunused Thomas Weißschuh
2025-06-11 10:33 ` [PATCH v3 5/9] selftests: vDSO: vdso_config: Avoid -Wunused-variables Thomas Weißschuh
2025-06-11 10:33 ` [PATCH v3 6/9] selftests: vDSO: enable -Wall Thomas Weißschuh
2025-06-11 10:33 ` [PATCH v3 7/9] selftests: vDSO: vdso_test_correctness: Fix -Wstrict-prototypes Thomas Weißschuh
2025-06-11 10:33 ` [PATCH v3 8/9] selftests: vDSO: vdso_test_getrandom: Always print TAP header Thomas Weißschuh
2025-06-11 10:33 ` [PATCH v3 9/9] selftests: vDSO: vdso_standalone_test_x86: Replace source file with symlink Thomas Weißschuh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).