main/postmarketos-test: add generic unl0kr test

This will be removed from unl0kr in the following commits, since at
some point it might be that unl0kr is not packaged in postmarketOS,
and this is a completely device-agnostic test, which is what this
package is for.

Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/7553>
This commit is contained in:
Pablo Correa Gómez 2025-12-04 18:38:06 +01:00 committed by The Friendly Merge Bot
parent 8733e062ac
commit 2cefeddf7e
No known key found for this signature in database
2 changed files with 42 additions and 2 deletions

View file

@ -0,0 +1,30 @@
#!/bin/sh
# Checks that unl0kr starts properly and doesn't crash or exit
# immediately.
echo "Checking that unl0kr starts properly"
SECS=5
unl0kr -V
TIME=$(date +%s)
timeout $SECS unl0kr -v 2>&1 | tee /tmp/unl0kr.log
CODE=$?
EXIT_TIME=$(date +%s)
ELAPSED=$(($EXIT_TIME - $TIME))
if grep -i "error" /tmp/unl0kr.log; then
echo "unl0kr reported an error!"
exit 1
fi
if [ $CODE -eq 0 ] && [ $ELAPSED -eq $SECS ]; then
echo "PASS: unl0kr ran for $SECS without exiting!"
exit 0
fi
ELAPSED=$(($EXIT_TIME - $TIME))
echo "unl0kr exited with code $? after $ELAPSED seconds (expected timeout after $SECS)"
echo "SKIP: broken test"
exit 0

View file

@ -1,13 +1,14 @@
# Maintainer: Casey Connolly <kcxt@postmarketos.org>
pkgname=postmarketos-test
pkgver=0.1.0
pkgrel=1
pkgver=1.0.0
pkgrel=0
pkgdesc="Common test utilities for postmarketOS"
url="https://postmarketos.org"
arch="noarch"
license="GPL2"
depends="devicepkg-utils"
source="
30-unl0kr-test.sh
initramfs-test-suspend.sh
"
options="!check"
@ -18,6 +19,7 @@ options="!check"
subpackages="
$pkgname-suspend:_test
$pkgname-shell
$pkgname-unl0kr
"
package() {
@ -48,6 +50,14 @@ shell() {
chmod +x "$subpkgdir"/usr/libexec/pmos-tests-initramfs/99-sh
}
unl0kr() {
depends="unl0kr"
install -Dm755 "$srcdir"/30-unl0kr-test.sh \
-t "$subpkgdir"/usr/libexec/pmos-tests-initramfs/
}
sha512sums="
407180b49c1a05f12bd6ee6e59dca0a6e74fe7b01f195087dcf2865598c47827d0bb569afdba55defa2f9a16437230fa62aa64f35111508b906bcbf9537acba4 30-unl0kr-test.sh
73d75e067f6bb99dab219e0154514841462dc171644756dcdfcb2daa039bd3052d61f35996608499fb0958042cc817ba0ac8196410c68e9133c2670d4cf36529 initramfs-test-suspend.sh
"