diff options
| author | Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com> | 2026-10-02 16:54:46 -0500 |
|---|---|---|
| committer | Shuah Khan <skhan@linuxfoundation.org> | 2026-10-19 18:05:00 -0600 |
| commit | 368e5d4d12a802ee3708800319cd13904721286f (patch) | |
| tree | 45a0adafd6e02998243460f46d5649e07bd4b46e | |
| parent | 39261b797f40e5ac29d1bb85a676f74cbfd55e9e (diff) | |
selftests: breakpoints: Skip step_after_suspend_test on systems without a wakeup capable RTC
This test puts a system into suspend state and uses CLOCK_BOOTTIME_ALARM
to wake the system up. This alarm can only wake up systems that have a
wakeup capable RTC source. On systems without such an RTC (for example,
most RISC-V boards), this test puts the system into suspend and just
hangs, requiring power cycling.
clock_getres(CLOCK_BOOTTIME_ALARM) fails with EINVAL on such systems,
so add a check based on that to skip this test on systems without a
wakeup capable RTC source.
Link: https://lore.kernel.org/r/20261002-breakpoints_rtc-v1-1-a3b6542a0fdf@oss.tenstorrent.com
Signed-off-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
| -rw-r--r-- | tools/testing/selftests/breakpoints/step_after_suspend_test.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c b/tools/testing/selftests/breakpoints/step_after_suspend_test.c index ca2aaab9e4ca..727790259429 100644 --- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c +++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c @@ -18,6 +18,7 @@ #include <sys/timerfd.h> #include <sys/types.h> #include <sys/wait.h> +#include <time.h> #include "kselftest.h" @@ -158,11 +159,21 @@ void suspend(void) int err; int count_before; int count_after; + struct timespec res; struct itimerspec spec = {}; if (getuid() != 0) ksft_exit_skip("Please run the test as root - Exiting.\n"); + /* + * CLOCK_BOOTTIME_ALARM cannot wake up systems that don't have a + * wakeup capable RTC from suspend. Check if we have a wakeup-capable + * RTC to prevent this test from causing the system to hang after + * it suspends. + */ + if (clock_getres(CLOCK_BOOTTIME_ALARM, &res) != 0) + ksft_exit_skip("No wakeup-capable RTC for CLOCK_BOOTTIME_ALARM\n"); + timerfd = timerfd_create(CLOCK_BOOTTIME_ALARM, 0); if (timerfd < 0) ksft_exit_fail_msg("timerfd_create() failed\n"); |
