[PATCH 1/5] selftests: vDSO: vdso_test_correctness: Store the clock id in the array
From: Thomas Weißschuh
Date: Tue Jul 28 2026 - 03:58:49 EST
The tests iterate over all elements of the array.
No gaps are possible with the current logic.
This prevents the test of auxiliary clocks which start at 16.
Transform the array so the clock id is part of the array entry and not
the entries index.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
---
.../testing/selftests/vDSO/vdso_test_correctness.c | 37 ++++++++++++----------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c b/tools/testing/selftests/vDSO/vdso_test_correctness.c
index 5c5a07dd1128..bcce5053e822 100644
--- a/tools/testing/selftests/vDSO/vdso_test_correctness.c
+++ b/tools/testing/selftests/vDSO/vdso_test_correctness.c
@@ -251,19 +251,22 @@ static bool tv_leq(const struct timeval *a, const struct timeval *b)
return a->tv_usec <= b->tv_usec;
}
-static char const * const clocknames[] = {
- [0] = "CLOCK_REALTIME",
- [1] = "CLOCK_MONOTONIC",
- [2] = "CLOCK_PROCESS_CPUTIME_ID",
- [3] = "CLOCK_THREAD_CPUTIME_ID",
- [4] = "CLOCK_MONOTONIC_RAW",
- [5] = "CLOCK_REALTIME_COARSE",
- [6] = "CLOCK_MONOTONIC_COARSE",
- [7] = "CLOCK_BOOTTIME",
- [8] = "CLOCK_REALTIME_ALARM",
- [9] = "CLOCK_BOOTTIME_ALARM",
- [10] = "CLOCK_SGI_CYCLE",
- [11] = "CLOCK_TAI",
+static const struct {
+ clockid_t id;
+ const char *const name;
+} clocks[] = {
+ { 0, "CLOCK_REALTIME"},
+ { 1, "CLOCK_MONOTONIC"},
+ { 2, "CLOCK_PROCESS_CPUTIME_ID"},
+ { 3, "CLOCK_THREAD_CPUTIME_ID"},
+ { 4, "CLOCK_MONOTONIC_RAW"},
+ { 5, "CLOCK_REALTIME_COARSE"},
+ { 6, "CLOCK_MONOTONIC_COARSE"},
+ { 7, "CLOCK_BOOTTIME"},
+ { 8, "CLOCK_REALTIME_ALARM"},
+ { 9, "CLOCK_BOOTTIME_ALARM"},
+ { 10, "CLOCK_SGI_CYCLE"},
+ { 11, "CLOCK_TAI"},
};
static void test_one_clock_gettime(int clock, const char *name)
@@ -319,8 +322,8 @@ static void test_clock_gettime(void)
return;
}
- for (int clock = 0; clock < ARRAY_SIZE(clocknames); clock++)
- test_one_clock_gettime(clock, clocknames[clock]);
+ for (int clock = 0; clock < ARRAY_SIZE(clocks); clock++)
+ test_one_clock_gettime(clocks[clock].id, clocks[clock].name);
/* Also test some invalid clock ids */
test_one_clock_gettime(-1, "invalid");
@@ -381,8 +384,8 @@ static void test_clock_gettime64(void)
return;
}
- for (int clock = 0; clock < ARRAY_SIZE(clocknames); clock++)
- test_one_clock_gettime64(clock, clocknames[clock]);
+ for (int clock = 0; clock < ARRAY_SIZE(clocks); clock++)
+ test_one_clock_gettime64(clocks[clock].id, clocks[clock].name);
/* Also test some invalid clock ids */
test_one_clock_gettime64(-1, "invalid");
--
2.55.0