Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: vDSO: vdso_test_abi: Add test for clock_getres_time64()

Some architectures will start to implement this function.
Make sure it works correctly.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20251223-vdso-compat-time32-v1-4-97ea7a06a543@linutronix.de

authored by

Thomas Weißschuh and committed by
Thomas Gleixner
4e6a2312 1dcd1273

+52 -1
+52 -1
tools/testing/selftests/vDSO/vdso_test_abi.c
··· 36 36 typedef long (*vdso_clock_gettime_t)(clockid_t clk_id, struct timespec *ts); 37 37 typedef long (*vdso_clock_gettime64_t)(clockid_t clk_id, struct vdso_timespec64 *ts); 38 38 typedef long (*vdso_clock_getres_t)(clockid_t clk_id, struct timespec *ts); 39 + typedef long (*vdso_clock_getres_time64_t)(clockid_t clk_id, struct vdso_timespec64 *ts); 39 40 typedef time_t (*vdso_time_t)(time_t *t); 40 41 41 42 static const char * const vdso_clock_name[] = { ··· 197 196 } 198 197 } 199 198 199 + #ifdef __NR_clock_getres_time64 200 + static void vdso_test_clock_getres_time64(clockid_t clk_id) 201 + { 202 + int clock_getres_fail = 0; 203 + 204 + /* Find clock_getres. */ 205 + vdso_clock_getres_time64_t vdso_clock_getres_time64 = 206 + (vdso_clock_getres_time64_t)vdso_sym(version, name[7]); 207 + 208 + if (!vdso_clock_getres_time64) { 209 + ksft_print_msg("Couldn't find %s\n", name[7]); 210 + ksft_test_result_skip("%s %s\n", name[7], 211 + vdso_clock_name[clk_id]); 212 + return; 213 + } 214 + 215 + struct vdso_timespec64 ts, sys_ts; 216 + long ret = VDSO_CALL(vdso_clock_getres_time64, 2, clk_id, &ts); 217 + 218 + if (ret == 0) { 219 + ksft_print_msg("The vdso resolution is %lld %lld\n", 220 + (long long)ts.tv_sec, (long long)ts.tv_nsec); 221 + } else { 222 + clock_getres_fail++; 223 + } 224 + 225 + ret = syscall(__NR_clock_getres_time64, clk_id, &sys_ts); 226 + 227 + ksft_print_msg("The syscall resolution is %lld %lld\n", 228 + (long long)sys_ts.tv_sec, (long long)sys_ts.tv_nsec); 229 + 230 + if ((sys_ts.tv_sec != ts.tv_sec) || (sys_ts.tv_nsec != ts.tv_nsec)) 231 + clock_getres_fail++; 232 + 233 + if (clock_getres_fail > 0) { 234 + ksft_test_result_fail("%s %s\n", name[7], 235 + vdso_clock_name[clk_id]); 236 + } else { 237 + ksft_test_result_pass("%s %s\n", name[7], 238 + vdso_clock_name[clk_id]); 239 + } 240 + } 241 + #else /* !__NR_clock_getres_time64 */ 242 + static void vdso_test_clock_getres_time64(clockid_t clk_id) 243 + { 244 + ksft_test_result_skip("%s %s\n", name[7], vdso_clock_name[clk_id]); 245 + } 246 + #endif /* __NR_clock_getres_time64 */ 247 + 200 248 /* 201 249 * This function calls vdso_test_clock_gettime and vdso_test_clock_getres 202 250 * with different values for clock_id. ··· 258 208 vdso_test_clock_gettime64(clock_id); 259 209 260 210 vdso_test_clock_getres(clock_id); 211 + vdso_test_clock_getres_time64(clock_id); 261 212 } 262 213 263 - #define VDSO_TEST_PLAN 29 214 + #define VDSO_TEST_PLAN 38 264 215 265 216 int main(int argc, char **argv) 266 217 {