summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorThomas Weißschuh (Schneider Electric) <thomas.weissschuh@linutronix.de>2026-08-03 12:04:40 +0200
committerThomas Gleixner <tglx@kernel.org>2026-08-11 18:11:20 +0200
commit2999620932be363a97c1028f5636deefe08adb06 (patch)
treeb15bf3ad7bd45d5f5f220174c4c7d0e67aac957b /tools
parent142a2d312e7bb8e5ad524a4f2115523cf4904732 (diff)
selftests: timers: nanosleep: Explicitly list the tested clocks
The test relies on the numeric values of the clockids. As not all clocks are meant to be tested, this requires skipping some clocks unconditionally, cluttering the result. Use an equivalent, explicit list instead. In addition to CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID and CLOCK_HWSPECIFIC which were unconditionally skipped before, this also unconditionally skips CLOCK_MONOTONIC_RAW, CLOCK_MONOTONIC_COARSE and CLOCK_REALTIME_COARSE. clock_nanosleep() is not supported for those. Signed-off-by: Thomas Weißschuh (Schneider Electric) <thomas.weissschuh@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Acked-by: John Stultz <jstultz@google.com> Link: https://patch.msgid.link/20260803-auxclock-nanosleep-prep-v2-9-910cbd485390@linutronix.de
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/timers/nanosleep.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/tools/testing/selftests/timers/nanosleep.c b/tools/testing/selftests/timers/nanosleep.c
index 629e800135ad..9dd662226261 100644
--- a/tools/testing/selftests/timers/nanosleep.c
+++ b/tools/testing/selftests/timers/nanosleep.c
@@ -30,9 +30,6 @@
#include "clock-helpers.h"
#include "kselftest.h"
-/* CLOCK_HWSPECIFIC == CLOCK_SGI_CYCLE (Deprecated) */
-#define CLOCK_HWSPECIFIC 10
-
#define UNSUPPORTED 0xf00f
/* returns 1 if a <= b, 0 otherwise */
@@ -141,20 +138,21 @@ int main(int argc, char **argv)
{
long long length;
int clockid, ret;
- int max_clocks = CLOCK_TAI + 1;
- ksft_print_header();
- ksft_set_plan(max_clocks);
+ static const clockid_t tested_clocks[] = {
+ CLOCK_REALTIME,
+ CLOCK_MONOTONIC,
+ CLOCK_BOOTTIME,
+ CLOCK_BOOTTIME_ALARM,
+ CLOCK_REALTIME_ALARM,
+ CLOCK_TAI,
+ };
- for (clockid = CLOCK_REALTIME; clockid < max_clocks; clockid++) {
+ ksft_print_header();
+ ksft_set_plan(ARRAY_SIZE(tested_clocks));
- /* Skip cputime clockids since nanosleep won't increment cputime */
- if (clockid == CLOCK_PROCESS_CPUTIME_ID ||
- clockid == CLOCK_THREAD_CPUTIME_ID ||
- clockid == CLOCK_HWSPECIFIC) {
- ksft_test_result_skip("%s\n", clock_name(clockid));
- continue;
- }
+ for (size_t clock_index = 0; clock_index < ARRAY_SIZE(tested_clocks); clock_index++) {
+ clockid = tested_clocks[clock_index];
fflush(stdout);