pmaports/main/postmarketos-test/initramfs-test-suspend.sh
Caleb Connolly 161711dea3
main/postmarketos-test: new aport (MR 4420)
This package provides a helper for writing a pmtest subpackage, as well
as being a place to write generic tests that aren't specific to a device
(e.g. a suspend test).

Signed-off-by: Caleb Connolly <caleb@connolly.tech>

[ci:ignore-count]
2023-10-31 19:53:22 +00:00

22 lines
570 B
Bash

#!/bin/sh
# Validate suspend/resume cycle
echo "Checking that suspend works"
SLEEP_TIME=6
if [ ! -e /sys/class/rtc/rtc0 ]; then
echo "SKIP: No RTC found"
exit 0
fi
time=$(($(cat /sys/class/rtc/rtc0/since_epoch) + $SLEEP_TIME))
echo $time | tee /sys/class/rtc/rtc0/wakealarm
echo mem | tee /sys/power/state
sleep 3 # wait for the system to suspend
if [ $(cat /sys/class/rtc/rtc0/since_epoch) -lt $time ]; then
echo "FAIL: System did not suspend"
exit 1
fi
echo "PASS: System suspended and woke up again"
# The other failure mode is that we don't wake up again...