mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Thomas Weißschuh (Schneider Electric)" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: thomas.weissschuh@linutronix.de,
	Thomas Gleixner <tglx@kernel.org>,
	John Stultz <jstultz@google.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: timers/core] selftests: timers: nanosleep: Reuse kselftest error numbers
Date: Tue, 11 Aug 2026 16:14:09 -0000	[thread overview]
Message-ID: <178646484926.442315.12694355977275032537.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-10-910cbd485390@linutronix.de>

The following commit has been merged into the timers/core branch of tip:

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

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
---
 tools/testing/selftests/timers/nanosleep.c | 36 +++++++++------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/tools/testing/selftests/timers/nanosleep.c b/tools/testing/selftests/timers/nanosleep.c
index 9dd6622..0a2ca17 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();
 		}

  reply	other threads:[~2026-08-11 16:14 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 10:04 [PATCH v2 00/17] timekeeping, hrtimer: Assorted cleanups Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 01/17] timekeeping: Rename clockid_aux_valid() to clockid_is_aux_clock() Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 02/17] timekeeping: Use u32 for clock_was_set_seq Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 03/17] hrtimer: Add a lockdep assertion to hrtimer_update_base() Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 04/17] timer_list: Use standard 'long long' format placeholders Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 05/17] timer_list: Use ktime_t over nanoseconds Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 06/17] selftests: add clock-helpers.h Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] selftests: Add clock-helpers.h tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 07/17] selftests: timers: Use clock_name() and constants from clock-helpers.h Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 08/17] selftests: timers: nanosleep: Drop output alignment Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 09/17] selftests: timers: nanosleep: Explicitly list the tested clocks Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 10/17] selftests: timers: nanosleep: Reuse kselftest error numbers Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` tip-bot2 for Thomas Weißschuh (Schneider Electric) [this message]
2026-08-03 10:04 ` [PATCH v2 11/17] selftests: timers: nanosleep: Move all single clock tests out of the loop in main() Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 12/17] selftests: timers: nanosleep: Explicitly handle timer_delete() failure Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 13/17] selftests: timers: nanosleep: Report each test separately Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 14/17] selftests: timers: nsleep-lat: Use NSEC_PER_MSEC define for unreasonable latency Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 15/17] selftests: timers: nsleep-lat: Explicitly list the tested clocks Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 16/17] selftests: timers: nsleep-lat: Reuse kselftest error numbers Thomas Weißschuh (Schneider Electric)
2026-08-11 16:14   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-08-03 10:04 ` [PATCH v2 17/17] selftests: timers: nsleep-lat: Check all calls to clock_nanosleep() and clock_gettime() Thomas Weißschuh (Schneider Electric)
2026-08-11 16:13   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178646484926.442315.12694355977275032537.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=thomas.weissschuh@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®