[tip: timers/core] selftests: timers: nsleep-lat: Reuse kselftest error numbers

tip-bot2 for Thomas Weißschuh (Schneider Electric) posted 1 patch 1 month, 2 weeks ago
tools/testing/selftests/timers/nsleep-lat.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
[tip: timers/core] selftests: timers: nsleep-lat: Reuse kselftest error numbers
Posted by tip-bot2 for Thomas Weißschuh (Schneider Electric) 1 month, 2 weeks ago
The following commit has been merged into the timers/core branch of tip:

Commit-ID:     0f474ee80c7ba1cab784c12a12232c53db5ad1fb
Gitweb:        https://git.kernel.org/tip/0f474ee80c7ba1cab784c12a12232c53db5ad1fb
Author:        Thomas Weißschuh (Schneider Electric) <thomas.weissschuh@linutronix.de>
AuthorDate:    Mon, 03 Aug 2026 12:04:47 +02:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Tue, 11 Aug 2026 18:11:21 +02:00

selftests: timers: nsleep-lat: 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-16-910cbd485390@linutronix.de
---
 tools/testing/selftests/timers/nsleep-lat.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/tools/testing/selftests/timers/nsleep-lat.c b/tools/testing/selftests/timers/nsleep-lat.c
index af47c28..266ca0c 100644
--- a/tools/testing/selftests/timers/nsleep-lat.c
+++ b/tools/testing/selftests/timers/nsleep-lat.c
@@ -29,8 +29,6 @@
 
 #define UNRESONABLE_LATENCY (40 * NSEC_PER_MSEC)
 
-#define UNSUPPORTED 0xf00f
-
 struct timespec timespec_add(struct timespec ts, unsigned long long ns)
 {
 	ts.tv_nsec += ns;
@@ -60,9 +58,9 @@ int nanosleep_lat_test(int clockid, long long ns)
 	target.tv_nsec = ns%NSEC_PER_SEC;
 
 	if (clock_gettime(clockid, &start))
-		return UNSUPPORTED;
+		return KSFT_SKIP;
 	if (clock_nanosleep(clockid, 0, &target, NULL))
-		return UNSUPPORTED;
+		return KSFT_SKIP;
 
 	count = 10;
 
@@ -74,7 +72,7 @@ int nanosleep_lat_test(int clockid, long long ns)
 
 	if (((timespec_sub(start, end)/count)-ns) > UNRESONABLE_LATENCY) {
 		ksft_print_msg("Large rel latency: %lld ns :", (timespec_sub(start, end)/count)-ns);
-		return -1;
+		return KSFT_FAIL;
 	}
 
 	/* Next check absolute latency */
@@ -88,10 +86,10 @@ int nanosleep_lat_test(int clockid, long long ns)
 
 	if (latency/count > UNRESONABLE_LATENCY) {
 		ksft_print_msg("Large abs latency: %lld ns :", latency/count);
-		return -1;
+		return KSFT_FAIL;
 	}
 
-	return 0;
+	return KSFT_PASS;
 }
 
 int main(int argc, char **argv)
@@ -123,12 +121,7 @@ int main(int argc, char **argv)
 
 		}
 
-		if (ret == UNSUPPORTED) {
-			ksft_test_result_skip("%s\n", clock_name(clockid));
-		} else {
-			ksft_test_result(ret >= 0, "%s\n",
-					 clock_name(clockid));
-		}
+		ksft_test_result_report(ret, "%s\n", clock_name(clockid));
 	}
 
 	ksft_finished();