summaryrefslogtreecommitdiff
path: root/tools/testing
diff options
context:
space:
mode:
authorThomas Weißschuh (Schneider Electric) <thomas.weissschuh@linutronix.de>2026-08-03 12:04:41 +0200
committerThomas Gleixner <tglx@kernel.org>2026-08-11 18:11:20 +0200
commitbfe5bf0c5fab93f90d851688fe2d65590339ecec (patch)
tree3bc8af66e6cb15851b6db6c98d7cbcafb6e3a2ec /tools/testing
parent2999620932be363a97c1028f5636deefe08adb06 (diff)
downloadlinux-bfe5bf0c5fab93f90d851688fe2d65590339ecec.tar.gz
linux-bfe5bf0c5fab93f90d851688fe2d65590339ecec.zip
selftests: timers: nanosleep: Reuse kselftest error numbers
The test currently defines its own custom error numbers. These mirror the semantics from the standard KFST_* constants. To make the code easier to read, use the standard result constants. 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-10-910cbd485390@linutronix.de
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/timers/nanosleep.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/tools/testing/selftests/timers/nanosleep.c b/tools/testing/selftests/timers/nanosleep.c
index 9dd662226261..0a2ca1791f27 100644
--- a/tools/testing/selftests/timers/nanosleep.c
+++ b/tools/testing/selftests/timers/nanosleep.c
@@ -30,8 +30,6 @@
#include "clock-helpers.h"
#include "kselftest.h"
-#define UNSUPPORTED 0xf00f
-
/* returns 1 if a <= b, 0 otherwise */
static inline int in_order(struct timespec a, struct timespec b)
{
@@ -60,15 +58,15 @@ int nanosleep_test(int clockid, long long ns)
/* First check abs time */
if (clock_gettime(clockid, &now))
- return UNSUPPORTED;
+ return KSFT_SKIP;
target = timespec_add(now, ns);
if (clock_nanosleep(clockid, TIMER_ABSTIME, &target, NULL))
- return UNSUPPORTED;
+ return KSFT_SKIP;
clock_gettime(clockid, &now);
if (!in_order(target, now))
- return -1;
+ return KSFT_FAIL;
/* Second check reltime */
clock_gettime(clockid, &now);
@@ -80,8 +78,8 @@ int nanosleep_test(int clockid, long long ns)
clock_gettime(clockid, &now);
if (!in_order(target, now))
- return -1;
- return 0;
+ return KSFT_FAIL;
+ return KSFT_PASS;
}
static void dummy_event_handler(int val)
@@ -100,38 +98,38 @@ static int nanosleep_test_remaining(int clockid)
sa.sa_handler = dummy_event_handler;
ret = sigaction(SIGALRM, &sa, NULL);
if (ret)
- return -1;
+ return KSFT_FAIL;
ret = timer_create(clockid, NULL, &timer);
if (ret)
- return -1;
+ return KSFT_FAIL;
itimer.it_value.tv_nsec = NSEC_PER_SEC / 4;
ret = timer_settime(timer, 0, &itimer, NULL);
if (ret)
- return -1;
+ return KSFT_FAIL;
rqtp.tv_nsec = NSEC_PER_SEC / 2;
ret = clock_nanosleep(clockid, 0, &rqtp, &rmtp);
if (ret != EINTR)
- return -1;
+ return KSFT_FAIL;
ret = timer_delete(timer);
if (ret)
- return -1;
+ return KSFT_FAIL;
sa.sa_handler = SIG_DFL;
ret = sigaction(SIGALRM, &sa, NULL);
if (ret)
- return -1;
+ return KSFT_FAIL;
if (!in_order((struct timespec) {}, rmtp))
- return -1;
+ return KSFT_FAIL;
if (!in_order(rmtp, rqtp))
- return -1;
+ return KSFT_FAIL;
- return 0;
+ return KSFT_PASS;
}
int main(int argc, char **argv)
@@ -159,18 +157,18 @@ int main(int argc, char **argv)
length = 10;
while (length <= (NSEC_PER_SEC * 10)) {
ret = nanosleep_test(clockid, length);
- if (ret == UNSUPPORTED) {
+ if (ret == KSFT_SKIP) {
ksft_test_result_skip("%s\n", clock_name(clockid));
goto next;
}
- if (ret < 0) {
+ if (ret == KSFT_FAIL) {
ksft_test_result_fail("%s\n", clock_name(clockid));
ksft_exit_fail();
}
length *= 100;
}
ret = nanosleep_test_remaining(clockid);
- if (ret < 0) {
+ if (ret == KSFT_FAIL) {
ksft_test_result_fail("%s\n", clock_name(clockid));
ksft_exit_fail();
}