[PATCH 1/5] selftests: vDSO: vdso_test_abi: Split out the alarm clock handling

From: Thomas Weißschuh

Date: Sat Dec 05 2026 - 09:34:57 EST


It is going to be reused in more places.

Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
tools/testing/selftests/vDSO/vdso_test_abi.c | 39 +++++++++++++++-------------
1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/tools/testing/selftests/vDSO/vdso_test_abi.c b/tools/testing/selftests/vDSO/vdso_test_abi.c
index b98ede039151..18073f83ac27 100644
--- a/tools/testing/selftests/vDSO/vdso_test_abi.c
+++ b/tools/testing/selftests/vDSO/vdso_test_abi.c
@@ -78,6 +78,26 @@ static void vdso_test_gettimeofday(void)
}
}

+static void vdso_test_fail_skip(const char *func, clockid_t clk_id, const char *clk_name, int ret)
+{
+ switch (clk_id) {
+ case CLOCK_REALTIME_ALARM:
+ case CLOCK_BOOTTIME_ALARM:
+ /*
+ * If no RTC device available or disabled in Kconfig
+ * the syscall fallback returns -EINVAL.
+ */
+ if (ret == -EINVAL) {
+ ksft_test_result_skip("%s %s\n", func, clk_name);
+ return;
+ }
+
+ /* fallthrough; */
+ default:
+ ksft_test_result_fail("%s %s\n", func, clk_name);
+ }
+}
+
static void vdso_test_clock_gettime64(clockid_t clk_id)
{
/* Find clock_gettime64. */
@@ -129,24 +149,7 @@ static void vdso_test_clock_gettime(clockid_t clk_id)
return;
}

- switch (clk_id) {
- case CLOCK_REALTIME_ALARM:
- case CLOCK_BOOTTIME_ALARM:
- /*
- * If no RTC device available or disabled in Kconfig
- * the syscall fallback returns -EINVAL.
- */
- if (ret == -EINVAL) {
- ksft_test_result_skip("%s %s\n", name[1],
- vdso_clock_name[clk_id]);
- return;
- }
-
- /* fallthrough; */
- default:
- ksft_test_result_fail("%s %s\n", name[1],
- vdso_clock_name[clk_id]);
- }
+ vdso_test_fail_skip(name[1], clk_id, vdso_clock_name[clk_id], ret);
}

static void vdso_test_time(void)

--
2.56.1