diff --git a/main/postmarketos-test/30-unl0kr-test.sh b/main/postmarketos-test/30-unl0kr-test.sh new file mode 100644 index 000000000..b47ce096d --- /dev/null +++ b/main/postmarketos-test/30-unl0kr-test.sh @@ -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 diff --git a/main/postmarketos-test/APKBUILD b/main/postmarketos-test/APKBUILD index 8068295b5..f4865daf3 100644 --- a/main/postmarketos-test/APKBUILD +++ b/main/postmarketos-test/APKBUILD @@ -1,13 +1,14 @@ # Maintainer: Casey Connolly 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 "