]> git.ipfire.org Git - thirdparty/linux.git/commit
selftests: breakpoints: use suspend_stats to reliably check suspend success
authorMoon Hee Lee <moonhee.lee.ca@gmail.com>
Thu, 26 Jun 2025 19:16:26 +0000 (12:16 -0700)
committerShuah Khan <skhan@linuxfoundation.org>
Thu, 10 Jul 2025 20:21:30 +0000 (14:21 -0600)
commit07b7c2b4eca3f83ce9cd5ee3fa1c7c001d721c69
tree4cd13ab2e117c12b9db622a4f07f6d4c093462b9
parenta089bb2822a49b0c5777a8936f82c1f8629231fb
selftests: breakpoints: use suspend_stats to reliably check suspend success

The step_after_suspend_test verifies that the system successfully
suspended and resumed by setting a timerfd and checking whether the
timer fully expired. However, this method is unreliable due to timing
races.

In practice, the system may take time to enter suspend, during which the
timer may expire just before or during the transition. As a result,
the remaining time after resume may show non-zero nanoseconds, even if
suspend/resume completed successfully. This leads to false test failures.

Replace the timer-based check with a read from
/sys/power/suspend_stats/success. This counter is incremented only
after a full suspend/resume cycle, providing a reliable and race-free
indicator.

Also remove the unused file descriptor for /sys/power/state, which
remained after switching to a system() call to trigger suspend [1].

[1] https://lore.kernel.org/all/20240930224025.2858767-1-yifei.l.liu@oracle.com/

Link: https://lore.kernel.org/r/20250626191626.36794-1-moonhee.lee.ca@gmail.com
Fixes: c66be905cda2 ("selftests: breakpoints: use remaining time to check if suspend succeed")
Signed-off-by: Moon Hee Lee <moonhee.lee.ca@gmail.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/breakpoints/step_after_suspend_test.c