pmaports/main/postmarketos-mkinitfs-hook-ci/05-ci.sh
Caleb Connolly e22f6f684f
postmarketos-mkinitfs-hook-ci: new aport (MR 4420)
Add a new initramfs hook for running tests in a CI environment.

This hook automatically runs any scripts from /usr/libexec/ci-tests.
Tests should be installed as a subpackage of some other package (e.g.
qrtr) with an install_if clause to install them when this hook is
installed.

This allows platform specific packages like device packages to define
tests that will automatically be installed and executed when building
the initramfs for that device. See
device/community/device-oneplus-enchilada for an example.

Signed-off-by: Caleb Connolly <caleb@connolly.tech>
2023-10-31 19:53:21 +00:00

38 lines
729 B
Bash

#!/bin/sh
# shellcheck disable=SC1091
. ./init_functions.sh
. /usr/share/misc/source_deviceinfo
TEST=""
DID_FAIL=0
echo "==> Running postmarketos-mkinitfs-hook-ci"
echo "==> disabling dmesg on console"
dmesg -n 2
for f in /usr/libexec/pmos-tests-initramfs/*; do
echo -e "\n==> Running test $f\n\n"
$f
if [ $? -ne 0 ]; then
echo "==> FAIL: $f"
DID_FAIL=1
else
echo "==> OK: $f"
fi
done
dmesg -n 8
if [ $DID_FAIL -ne 0 ]; then
echo "==> PMOS-CI-FAIL"
else
echo "==> PMOS-CI-OK"
fi
# We're done, kill it
# CDBA will exit if it sees 20 '~' characters
# in a row, send a whole bunch just to be sure
# In the worst case it will timeout.
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"