unl0kr: add pmtest (MR 4420)

Add a test for CI that:
* ensures unl0kr runs for 10 seconds without crashing
* ensures that it doesn't print any errors

This sure isn't an "ideal" test, but it at least validates that the
framebuffer interface doesn't die horribly...

With a little more effort we should be able to run unl0kr and then pull
the framebuffer and check it against some known good unl0kr screenshot.

Signed-off-by: Caleb Connolly <caleb@connolly.tech>
This commit is contained in:
Caleb Connolly 2023-09-28 00:12:27 +01:00
parent 6fcc759991
commit c99a360a6e
No known key found for this signature in database
GPG key ID: 7930459FB9303217
2 changed files with 45 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,7 +1,7 @@
# Maintainer: Johannes Marbach <n0-0ne+gitlab@mailbox.org>
pkgname=unl0kr
pkgver=2.0.2
pkgrel=0
pkgrel=1
_commit_lvgl=2f294aa76c8fece98a4fa72304bc6f267ed2a228
_commit_lv_drivers=7e3135bcae37cbd03c2f003fcc96278671bd8632
_commit_squeek2lvgl=b67685dfede0771d2a237e1d8d4e784fcf406a70
@ -33,11 +33,12 @@ source="
unl0kr.conf
unl0kr.files
unlock.sh
30-unl0kr-test.sh
"
options="!check" # No tests
provides="postmarketos-fde-unlocker"
provider_priority=1000
subpackages="$pkgname-doc"
subpackages="$pkgname-doc $pkgname-pmtest"
prepare() {
default_prepare
@ -74,6 +75,17 @@ package() {
"$pkgdir"/usr/share/mkinitfs/files-extra/30-unl0kr.files
}
pmtest() {
install_if="$pkgname=$pkgver-r$pkgrel postmarketos-mkinitfs-hook-ci"
install -Dm755 "$srcdir"/30-unl0kr-test.sh \
"$subpkgdir"/usr/libexec/pmos-tests-initramfs/30-unl0kr-test.sh
# We need the files in the core initramfs for this, no -extra in CI
install -Dm644 "$srcdir"/unl0kr.files \
"$subpkgdir"/usr/share/mkinitfs/files/30-unl0kr.files
}
sha512sums="
ce85363b7c388921f89ee198f78861247ffe115a2b5747d5c9ad25e6fb2d5de1c592cc665405c9a2af3e5e90771ac78bfa55779bab96b89b99264175b7b6a152 unl0kr-2.0.2.tar.gz
fbc71bb804d5b766cd515533afd4f44092ffa023b248ac447b743618fa700a95bca8f9aa2ff20b033545f1ad745b31673e4a8b75e0991e8b6978327dfd65bf14 lvgl-2f294aa76c8fece98a4fa72304bc6f267ed2a228.tar.gz
@ -82,4 +94,5 @@ fbc71bb804d5b766cd515533afd4f44092ffa023b248ac447b743618fa700a95bca8f9aa2ff20b03
7155c2f95dcf3716c0f392cf5717e96f1414c383a1f7c2ed30a1f8518dfe0b17c3c0e0e93f6476a342504aa855404099e2f5444eeb099023491c9a9a26fa3d90 unl0kr.conf
521379c06843d31304c7317d083472bb0105da7e9360d7a303cb98c84112919278fa8b50c3781d9cf43bb057b7eb7d52a4f4d900be69a0c0d70f97f2e9843140 unl0kr.files
5386f434cd4f1fb9e0d561a8689e5e85d6a8b3c562823122c082d4932d2fb0ad4edcd635f14f0c61e5c8b5e53648c9937b042409c21683007700faea8894c750 unlock.sh
407180b49c1a05f12bd6ee6e59dca0a6e74fe7b01f195087dcf2865598c47827d0bb569afdba55defa2f9a16437230fa62aa64f35111508b906bcbf9537acba4 30-unl0kr-test.sh
"