From: Wake Liu <wakel@google.com>
To: Anna-Maria Behnsen <anna-maria@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>,
Thomas Gleixner <tglx@kernel.org>,
John Stultz <jstultz@google.com>, Shuah Khan <shuah@kernel.org>
Cc: Stephen Boyd <sboyd@kernel.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
Wake Liu <wakel@google.com>
Subject: [PATCH v2] selftests: timers: Make sleep time in raw_skew configurable
Date: Mon, 13 Jul 2026 02:00:53 +0000 [thread overview]
Message-ID: <20260713020053.3897259-1-wakel@google.com> (raw)
In-Reply-To: <20260710025144.2000000-1-wakel@google.com>
The raw_skew test currently sleeps for 120 seconds to estimate clock
drift. This is a very long time for a single test, and can cause
timeouts in automated test suites or CI systems.
Allow overriding the sleep time via a command line argument,
so it can be adjusted if needed in different environments, while
keeping the default at 120 seconds to preserve original behavior.
Also add -h/--help support to document this option.
Signed-off-by: Wake Liu <wakel@google.com>
---
tools/testing/selftests/timers/raw_skew.c | 24 +++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/timers/raw_skew.c b/tools/testing/selftests/timers/raw_skew.c
index a7bae7d80916..5fff3eaf1307 100644
--- a/tools/testing/selftests/timers/raw_skew.c
+++ b/tools/testing/selftests/timers/raw_skew.c
@@ -27,6 +27,7 @@
#include <time.h>
#include <include/vdso/time64.h>
#include "kselftest.h"
+#include <string.h>
#define shift_right(x, s) ({ \
__typeof__(x) __x = (x); \
@@ -87,11 +88,30 @@ void get_monotonic_and_raw(struct timespec *mon, struct timespec *raw)
}
}
+static void usage(char *argv0)
+{
+ printf("Usage: %s [sleep_secs]\n", argv0);
+ printf(" sleep_secs: time to sleep in seconds to estimate clock drift (default: 120s)\n");
+}
+
int main(int argc, char **argv)
{
struct timespec mon, raw, start, end;
long long delta1, delta2, interval, eppm, ppm;
struct timex tx1, tx2;
+ int sleep_sec = 120;
+
+ if (argc > 1) {
+ if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
+ usage(argv[0]);
+ ksft_exit_pass();
+ }
+ sleep_sec = atoi(argv[1]);
+ if (sleep_sec <= 0) {
+ printf("Invalid sleep time, using default 120s\n");
+ sleep_sec = 120;
+ }
+ }
setbuf(stdout, NULL);
@@ -109,9 +129,9 @@ int main(int argc, char **argv)
if (tx1.offset)
printf("WARNING: ADJ_OFFSET in progress, this will cause inaccurate results\n");
- printf("Estimating clock drift: ");
+ printf("Estimating clock drift (%ds): ", sleep_sec);
fflush(stdout);
- sleep(120);
+ sleep(sleep_sec);
get_monotonic_and_raw(&mon, &raw);
end = mon;
--
2.55.0.795.g602f6c329a-goog
prev parent reply other threads:[~2026-07-13 2:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 2:51 [PATCH] selftests: timers: Make sleep time in raw_skew configurable Wake Liu
2026-07-10 3:04 ` John Stultz
2026-07-13 2:06 ` Wake Liu
2026-07-13 2:00 ` Wake Liu [this message]
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=20260713020053.3897259-1-wakel@google.com \
--to=wakel@google.com \
--cc=anna-maria@linutronix.de \
--cc=frederic@kernel.org \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=shuah@kernel.org \
--cc=tglx@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