Extend the test to also cover auxiliary clocks. The hardcoded boundary of 'CLOCK_AUX + 8' is intentional. If the number of auxiliary clocks ever changes we will not access the vdso_clock_name array out of bounds but instead kselftest.h will report a mismatch between the executed tests and the test plan.
Signed-off-by: Thomas Weißschuh <[email protected]> --- tools/testing/selftests/vDSO/vdso_test_abi.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_abi.c b/tools/testing/selftests/vDSO/vdso_test_abi.c index b162a4ba9c4f..d34d112f9860 100644 --- a/tools/testing/selftests/vDSO/vdso_test_abi.c +++ b/tools/testing/selftests/vDSO/vdso_test_abi.c @@ -23,6 +23,14 @@ #include "vdso_call.h" #include "parse_vdso.h" +#ifndef CLOCK_AUX +#define CLOCK_AUX 16 +#endif + +#ifndef CLOCK_AUX_LAST +#define CLOCK_AUX_LAST 23 +#endif + static const char *version; static const char **name; @@ -52,6 +60,14 @@ static const char * const vdso_clock_name[] = { [CLOCK_BOOTTIME_ALARM] = "CLOCK_BOOTTIME_ALARM", [10 /* CLOCK_SGI_CYCLE */] = "CLOCK_SGI_CYCLE", [CLOCK_TAI] = "CLOCK_TAI", + [CLOCK_AUX + 0] = "CLOCK_AUX0", + [CLOCK_AUX + 1] = "CLOCK_AUX1", + [CLOCK_AUX + 2] = "CLOCK_AUX2", + [CLOCK_AUX + 3] = "CLOCK_AUX3", + [CLOCK_AUX + 4] = "CLOCK_AUX4", + [CLOCK_AUX + 5] = "CLOCK_AUX5", + [CLOCK_AUX + 6] = "CLOCK_AUX6", + [CLOCK_AUX + 7] = "CLOCK_AUX7", }; static void vdso_test_gettimeofday(void) @@ -99,6 +115,9 @@ static void vdso_test_clock_gettime64(clockid_t clk_id) (long long)ts.tv_sec, (long long)ts.tv_nsec); ksft_test_result_pass("%s %s\n", name[5], vdso_clock_name[clk_id]); + } else if (ret == -ENODEV) { + ksft_test_result_skip("%s %s\n", name[5], + vdso_clock_name[clk_id]); } else { ksft_test_result_fail("%s %s\n", name[5], vdso_clock_name[clk_id]); @@ -126,6 +145,9 @@ static void vdso_test_clock_gettime(clockid_t clk_id) (long long)ts.tv_sec, (long long)ts.tv_nsec); ksft_test_result_pass("%s %s\n", name[1], vdso_clock_name[clk_id]); + } else if (ret == -ENODEV) { + ksft_test_result_skip("%s %s\n", name[1], + vdso_clock_name[clk_id]); } else { ksft_test_result_fail("%s %s\n", name[1], vdso_clock_name[clk_id]); @@ -261,7 +283,8 @@ static inline void vdso_test_clock(clockid_t clock_id) vdso_test_clock_getres_time64(clock_id); } -#define VDSO_TEST_PLAN 38 +#define NUM_AUX_TESTS (4 * (CLOCK_AUX_LAST - CLOCK_AUX + 1)) +#define VDSO_TEST_PLAN (38 + NUM_AUX_TESTS) int main(int argc, char **argv) { @@ -293,6 +316,9 @@ int main(int argc, char **argv) vdso_test_clock(CLOCK_PROCESS_CPUTIME_ID); vdso_test_clock(CLOCK_THREAD_CPUTIME_ID); + for (clockid_t aux_clock = CLOCK_AUX; aux_clock < CLOCK_AUX + 8; aux_clock++) + vdso_test_clock(aux_clock); + vdso_test_time(); ksft_finished(); -- 2.55.0

