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]
This commit is contained in:
parent
e22f6f684f
commit
161711dea3
2 changed files with 78 additions and 0 deletions
56
main/postmarketos-test/APKBUILD
Normal file
56
main/postmarketos-test/APKBUILD
Normal file
|
@ -0,0 +1,56 @@
|
|||
# Maintainer: Caleb Connolly <caleb@connolly.tech>
|
||||
pkgname=postmarketos-test
|
||||
pkgver=0.1.0
|
||||
pkgrel=0
|
||||
pkgdesc="Common test utilities for postmarketOS"
|
||||
url="https://postmarketos.org"
|
||||
arch="noarch"
|
||||
license="GPL2"
|
||||
depends="devicepkg-utils"
|
||||
source="
|
||||
initramfs-test-suspend.sh
|
||||
"
|
||||
options="!check"
|
||||
|
||||
# Tests that are common to all devices
|
||||
# TODO: more tests
|
||||
# maybe test cpu frequency scaling, thermals under load, etc.
|
||||
subpackages="
|
||||
$pkgname-suspend:_test
|
||||
$pkgname-shell
|
||||
"
|
||||
|
||||
package() {
|
||||
mkdir -p $pkgdir
|
||||
}
|
||||
|
||||
_test() {
|
||||
# no install_if here, these tests are generic but should be enabled
|
||||
# on a per-device basis. Depend on the relevant test in your devices
|
||||
# pmtest subpackage
|
||||
depends="postmarketos-mkinitfs-hook-ci"
|
||||
|
||||
_testname=${subpkgname#postmarketos-test-}
|
||||
|
||||
# Install the test script for both initramfs and rootfs
|
||||
for _type in initramfs rootfs; do
|
||||
_script="$srcdir/$_type-test-$_testname.sh"
|
||||
|
||||
if [ -f "$_script" ]; then
|
||||
install -Dm755 "$_script" \
|
||||
"$subpkgdir"/usr/libexec/pmos-tests-"$_type"/90-"$_testname".sh
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Installs a "test" which just runs a shell on the console for debugging
|
||||
shell() {
|
||||
depends="postmarketos-mkinitfs-hook-ci"
|
||||
mkdir -p "$subpkgdir"/usr/libexec/pmos-tests-initramfs
|
||||
echo -e "#!/bin/sh\n\nexec sh" > "$subpkgdir"/usr/libexec/pmos-tests-initramfs/99-sh
|
||||
chmod +x "$subpkgdir"/usr/libexec/pmos-tests-initramfs/99-sh
|
||||
}
|
||||
|
||||
sha512sums="
|
||||
73d75e067f6bb99dab219e0154514841462dc171644756dcdfcb2daa039bd3052d61f35996608499fb0958042cc817ba0ac8196410c68e9133c2670d4cf36529 initramfs-test-suspend.sh
|
||||
"
|
22
main/postmarketos-test/initramfs-test-suspend.sh
Normal file
22
main/postmarketos-test/initramfs-test-suspend.sh
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/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...
|
Loading…
Reference in a new issue