define TST_MAX_CLOCKS to account MAX_AUX_CLOCKS also
PATCH 1/1 define TST_MAX_CLOCKS to account MAX_AUX_CLOCKS also
Starting kernel v6.17, syscall tests clock_adjtime02, clock_gettime02, clock_settime02 and timer_create02 fails in verifying expected errno for invalid clock IDs, returning ENODEV instead of expected EINVAL.
clock_gettime02.c:133: TFAIL: clock_gettime(2): clock INVALID/UNKNOWN CLOCK failed unexpectedly: ENODEV (19) clock_gettime02.c:133: TFAIL: clock_gettime(2): clock INVALID/UNKNOWN CLOCK failed unexpectedly: ENODEV (19)
This started as a result of these commits [1], [2] and [3], which introduced auxiliary POSIX clocks, so when kernel has POSIX_AUX_CLOCKS option enabled, invalid IDs being used in tests refer to AUX clock IDs.
To fix the tests, define TST_MAX_CLOCKS to also account MAX_AUX_CLOCKS when trying invalid clock IDs.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9094c72c3d81bf2416b7c79d12c8494ab8fbac20
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=606424bf4ffd9d27865c45b5707c1edac6b187ed
[3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=60ecc26ec5af567a55f362ad92c0cac8b894541c
Closes #1255
--- include/lapi/common_timers.h | 9 +++++++++ .../kernel/syscalls/clock_adjtime/clock_adjtime02.c | 4 ++-- .../kernel/syscalls/clock_gettime/clock_gettime02.c | 4 ++-- .../kernel/syscalls/clock_settime/clock_settime02.c | 4 ++-- testcases/kernel/syscalls/timer_create/timer_create02.c | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-)
include/lapi/common_timers.h +9 -0
@@ -7,6 +7,7 @@#ifndef LAPI_COMMON_TIMERS_H__ #define LAPI_COMMON_TIMERS_H__ +#include <linux/version.h> #include "config.h" #include "lapi/syscalls.h" #include "lapi/posix_clocks.h"
@@ -30,6 +31,14 @@ static const clock_t clock_list[] = {/* MAX_CLOCKS is the maximum number of clock sources supported by kernel */ #define MAX_CLOCKS 16 +#define MAX_AUX_CLOCKS 8 + +#if LINUX_VERSION_CODE >=KERNEL_VERSION (6 ,17 ,0 ) +#define TST_MAX_CLOCKS (MAX_CLOCKS + MAX_AUX_CLOCKS) +#else +#define TST_MAX_CLOCKS (MAX_CLOCKS) +#endif +#define CLOCK_TO_STR (def_name) \ case def_name: \ return #def_name;
testcases/kernel/syscalls/clock_adjtime/clock_adjtime02.c +2 -2
@@ -76,11 +76,11 @@ struct test_case {struct test_case tc[] = { { - .clktype =MAX_CLOCKS , + .clktype =TST_MAX_CLOCKS , .exp_err =EINVAL , }, { - .clktype =MAX_CLOCKS +1 , + .clktype =TST_MAX_CLOCKS +1 , .exp_err =EINVAL , }, {
testcases/kernel/syscalls/clock_gettime/clock_gettime02.c +2 -2
@@ -34,11 +34,11 @@ struct test_case {static struct test_case tc[] = { { - .clktype =MAX_CLOCKS , + .clktype =TST_MAX_CLOCKS , .exp_err =EINVAL , }, { - .clktype =MAX_CLOCKS +1 , + .clktype =TST_MAX_CLOCKS +1 , .exp_err =EINVAL , },/*
testcases/kernel/syscalls/clock_settime/clock_settime02.c +2 -2
@@ -59,11 +59,11 @@ struct test_case tc[] = { .exp_err = EINVAL, }, { /* case 06: MAXCLOCK */ - .type = MAX_CLOCKS, + .type = TST_MAX_CLOCKS, .exp_err = EINVAL, }, { /* case 07: MAXCLOCK+1 */ - .type = MAX_CLOCKS + 1, + .type = TST_MAX_CLOCKS + 1, .exp_err = EINVAL, }, /* Linux specific */
testcases/kernel/syscalls/timer_create/timer_create02.c +1 -1
@@ -52,7 +52,7 @@ static struct testcase { } tcases[] = { {CLOCK_REALTIME, NULL, &timer_id, EFAULT, "invalid sigevent struct"}, {CLOCK_REALTIME, &sig_ev, NULL, EFAULT, "invalid timer ID"}, - {MAX_CLOCKS, &sig_ev, &timer_id, EINVAL, "invalid clock"}, + {TST_MAX_CLOCKS, &sig_ev, &timer_id, EINVAL, "invalid clock"}, {CLOCK_REALTIME, &sig_ev_inv_not, &timer_id, EINVAL, "wrong sigev_notify"}, {CLOCK_REALTIME, &sig_ev_inv_sig, &timer_id, EINVAL, "wrong sigev_signo"}, };
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Avinesh,
Thanks for fixing this! Merged!
...
include/lapi/common_timers.h static const clock_t clock_list[] = { · line 36
Quoted 6 lines
/*
MAX_CLOCKSis the maximum number of clock sources supported by kernel */ #defineMAX_CLOCKS16include/lapi/common_timers.h +3
-0+#define MAX_AUX_CLOCKS 8 + +#if LINUX_VERSION_CODE >=KERNEL_VERSION (6 ,17 ,0 )
FYI it still fails on my openSUSE Tumbleweed 6.17-rc2 is due linux-glibc-devel package which has 6.16 even I have newer kernel from KOTD (the known problem with kernel headers from glibc vs. kernel mismatch). But once 6.17 is out it will work.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp