From e22f6f684f115818ecc2ac9c624b357abffb2369 Mon Sep 17 00:00:00 2001 From: Caleb Connolly Date: Mon, 25 Sep 2023 15:31:48 +0100 Subject: [PATCH] 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 --- .../postmarketos-mkinitfs-hook-ci/05-ci.files | 8 ++++ main/postmarketos-mkinitfs-hook-ci/05-ci.sh | 38 +++++++++++++++++++ main/postmarketos-mkinitfs-hook-ci/APKBUILD | 25 ++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 main/postmarketos-mkinitfs-hook-ci/05-ci.files create mode 100644 main/postmarketos-mkinitfs-hook-ci/05-ci.sh create mode 100644 main/postmarketos-mkinitfs-hook-ci/APKBUILD diff --git a/main/postmarketos-mkinitfs-hook-ci/05-ci.files b/main/postmarketos-mkinitfs-hook-ci/05-ci.files new file mode 100644 index 000000000..91feb6c9b --- /dev/null +++ b/main/postmarketos-mkinitfs-hook-ci/05-ci.files @@ -0,0 +1,8 @@ +/usr/libexec/pmos-tests-initramfs +# We want all modules to be here so that we can validate +# that all the device drivers load properly +/lib/modules +/sbin/udevd +/bin/udevadm +/etc/udev/rules.d +/lib/udev/rules.d \ No newline at end of file diff --git a/main/postmarketos-mkinitfs-hook-ci/05-ci.sh b/main/postmarketos-mkinitfs-hook-ci/05-ci.sh new file mode 100644 index 000000000..d1c91268b --- /dev/null +++ b/main/postmarketos-mkinitfs-hook-ci/05-ci.sh @@ -0,0 +1,38 @@ +#!/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 "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" diff --git a/main/postmarketos-mkinitfs-hook-ci/APKBUILD b/main/postmarketos-mkinitfs-hook-ci/APKBUILD new file mode 100644 index 000000000..a6b7e883b --- /dev/null +++ b/main/postmarketos-mkinitfs-hook-ci/APKBUILD @@ -0,0 +1,25 @@ +# Maintainer: Caleb Connolly +pkgname=postmarketos-mkinitfs-hook-ci +pkgver=0.1.0 +pkgrel=0 +pkgdesc="Hook for doing automated CI tests in the initramfs" +url="https://postmarketos.org" +source=" + 05-ci.sh + 05-ci.files +" +arch="noarch" +license="GPL2" +options="!check" + +package() { + install -Dm755 "$srcdir"/05-ci.sh \ + "$pkgdir"/usr/share/mkinitfs/hooks/05-ci.sh + install -Dm644 "$srcdir"/05-ci.files \ + "$pkgdir"/usr/share/mkinitfs/files/05-ci.files +} + +sha512sums=" +43f9d9a35a57845eb36893a3f20d8ff5f20b93b1c22c7c6e3959b07a41b3c5fe2f9941612620cf006a0018b53edae5fdc7ed3006befc6908c19a5617f322dea3 05-ci.sh +35457ab221acd485ebde84fccac2187f36a074554c5f73828f2031f1e8e92ab7b3d46e654f0d7c62c0aa483c1d7f0dc901422fe0398ae0eae6995a2ae539a4af 05-ci.files +"