diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0fbd0d..d70d6a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -151,6 +151,8 @@ jobs: run: bash qemu/tests/run-sh-args-test.sh - name: rig init honours reboot/poweroff/halt (#5) run: bash qemu/tests/init-power-signals-test.sh + - name: rig init daemon order matches the panel (flare-edge#348) + run: bash qemu/tests/init-daemon-order-test.sh - name: mkimage.sh SEED_DIR regression test # Only ui-drive.sh --seed (a real VM boot) exercises this hook # otherwise; this builds the same unprivileged mkfs.ext4 image and diff --git a/qemu/rootfs/sbin/init b/qemu/rootfs/sbin/init index b639aec..37fee35 100755 --- a/qemu/rootfs/sbin/init +++ b/qemu/rootfs/sbin/init @@ -105,14 +105,14 @@ if grep -qw warden.fwapply /proc/cmdline; then echo "init: OTA APPLY ENABLED (warden.fwapply)" fi # The same daemons the panel's SysV scripts start, in their S-number order -# (S92 ai, S93 automation, S94 modbus, S95 mikrotik, S96 asic/starlink/ -# stratum, S97 flared), each with no arguments and no environment, exactly -# as start-stop-daemon runs them there. A daemon that cannot live on -M virt +# (S21 modbus, S22 automation, S92 ai, S95 mikrotik, S96 asic/starlink/ +# stratum, S97 flared; flare-edge#348), each with no arguments and no +# environment, exactly as start-stop-daemon runs them there. A daemon that cannot live on -M virt # (warden-ai wants the NPU) exits into its log and the UI shows the same # "not running" it would show on a panel whose daemon died; that is the # panel's behaviour, not a rig substitute for it. warden-watchdog stays out: # it and a payload flared do not mix (README). -for d in /usr/bin/warden-ai /usr/bin/warden-automation /usr/bin/warden-modbus \ +for d in /usr/bin/warden-modbus /usr/bin/warden-automation /usr/bin/warden-ai \ /usr/bin/warden-mikrotik /usr/bin/warden-asic /usr/bin/warden-starlink \ /usr/bin/warden-stratum /usr/bin/warden-flared; do if [ -x "$d" ]; then diff --git a/qemu/tests/init-daemon-order-test.sh b/qemu/tests/init-daemon-order-test.sh new file mode 100755 index 0000000..ead9944 --- /dev/null +++ b/qemu/tests/init-daemon-order-test.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# The rig's /sbin/init starts the Warden daemons in the panel's S-number +# order (flare-edge#348): warden-modbus (S21modbus) before warden-automation +# (S22automation), since an automation's device command goes through +# warden-modbus, and both before the other app backends and flared. Reads +# the daemon list from the init script's own start loop. +set -uo pipefail + +HERE="$(cd "$(dirname "$0")" && pwd)" +INIT="$HERE/../rootfs/sbin/init" +FAIL=0 + +order=$(awk ' + /^for d in \/usr\/bin\/warden-/ { on = 1 } + on { + last = ($0 ~ /; do$/) + for (i = 1; i <= NF; i++) if ($i ~ /^\/usr\/bin\/warden-/) { w = $i; sub(/;$/, "", w); print w } + if (last) exit + }' "$INIT") + +want="/usr/bin/warden-modbus +/usr/bin/warden-automation +/usr/bin/warden-ai +/usr/bin/warden-mikrotik +/usr/bin/warden-asic +/usr/bin/warden-starlink +/usr/bin/warden-stratum +/usr/bin/warden-flared" + +if [ "$order" = "$want" ]; then + echo "PASS: rig init starts the daemons in the panel's S-number order" +else + echo "FAIL: rig init daemon order differs from the panel's S-number order" + diff <(printf '%s\n' "$want") <(printf '%s\n' "$order") + FAIL=1 +fi +exit "$FAIL"