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>
This commit is contained in:
Anirudh Srinivasan 2026-10-02 16:54:46 -05:00 committed by Shuah Khan
parent 39261b797f
commit 368e5d4d12

View File

@ -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");