]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
test: add test case for booting root=live:<URL>
authorBenjamin Drung <benjamin.drung@canonical.com>
Mon, 19 Jan 2026 18:36:42 +0000 (19:36 +0100)
committerLaszlo <laszlo.gombos@gmail.com>
Tue, 20 Jan 2026 12:57:38 +0000 (07:57 -0500)
Add a test case for booting `root=live:<URL>` before adding new features
to the `livenet` Dracut module. Numbering the test is tricky, because it
uses live boot (range 30-39) and basic networking (range 60-69).

.github/workflows/daily-network.yml
.github/workflows/daily-omitsystemd.yml
.github/workflows/integration.yml
test/TEST-31-LIVENET/Makefile [new file with mode: 0644]
test/TEST-31-LIVENET/test.sh [new file with mode: 0755]

index afaf6df3b141e8041bb5bb417eff6c3f72cac171..d23790b1cc2da8d4fd6e4f026557baade47f77e6 100644 (file)
@@ -36,6 +36,7 @@ jobs:
                     - ubuntu:devel
                     - ubuntu:rolling
                 test:
+                    - "31"
                     - "60"
                     - "72"
                 exclude:
index 06e482e617dac144e7eeb09c1270b35a1168aa3d..68c5d34a7a42293336b9c6ee1ff8e4ea37c3fc25 100644 (file)
@@ -34,6 +34,7 @@ jobs:
                     - "20"
                     - "26"
                     - "30"
+                    - "31"
         container:
             image: ghcr.io/dracut-ng/${{ matrix.container }}-${{ matrix.architecture.tag }}
             options: '--device=/dev/kvm --privileged'
index 5f7bbcaba4d0a6c15b6c6d43a18f70fbb4fb733a..7f37a465cf3de769a7fcd970166629337eea7bf4 100644 (file)
@@ -178,6 +178,7 @@ jobs:
                     - opensuse:latest
                     - ubuntu:devel
                 test:
+                    - "31"
                     - "60"
         container:
             image: ghcr.io/dracut-ng/${{ matrix.container }}-amd
diff --git a/test/TEST-31-LIVENET/Makefile b/test/TEST-31-LIVENET/Makefile
new file mode 100644 (file)
index 0000000..2dcab81
--- /dev/null
@@ -0,0 +1 @@
+-include ../Makefile.testdir
diff --git a/test/TEST-31-LIVENET/test.sh b/test/TEST-31-LIVENET/test.sh
new file mode 100755 (executable)
index 0000000..dc8f785
--- /dev/null
@@ -0,0 +1,91 @@
+#!/usr/bin/env bash
+set -eu
+
+# shellcheck disable=SC2034
+TEST_DESCRIPTION="live root provided over network"
+
+# Uncomment these to debug failures
+#DEBUGFAIL="rd.shell rd.debug rd.live.debug loglevel=7"
+
+test_check() {
+    if ! type -p mksquashfs &> /dev/null; then
+        echo "Test needs mksquashfs... Skipping"
+        return 1
+    fi
+
+    if ! type -p python3 &> /dev/null; then
+        echo "Test needs python3 as HTTP server... Skipping"
+        return 1
+    fi
+}
+
+start_webserver() {
+    local pid port
+
+    echo "Starting HTTP server..." >&2
+    python3 -u -m http.server -d "$TESTDIR" 0 > "$TESTDIR/webserver.log" 2>&1 &
+    pid=$!
+    echo "$pid" > "$TESTDIR/webserver.pid"
+
+    while ! grep -q 'Serving HTTP on' "$TESTDIR/webserver.log"; do
+        echo "sleeping..." >&2
+        sleep 0.05
+    done
+
+    port=$(sed -n 's/.*port \([0-9]\+\).*/\1/p' "$TESTDIR/webserver.log")
+    echo "HTTP server running on port $port (pid $pid)" >&2
+    echo "$port"
+}
+
+check_log() {
+    local msg="$1"
+    local logfile="$2"
+
+    if ! grep -q "${msg}" "${logfile}"; then
+        echo >&2 "E: Message '${msg}' not found in QEMU log output '${logfile}'."
+        return 1
+    fi
+}
+
+client_run() {
+    local test_name="$1"
+    local append="$2"
+
+    client_test_start "$test_name"
+    "$testdir"/run-qemu \
+        -device "virtio-net-pci,netdev=lan0" \
+        -netdev "user,id=lan0,net=10.0.2.0/24,dhcpstart=10.0.2.15" \
+        -append "$append $TEST_KERNEL_CMDLINE" \
+        -initrd "$TESTDIR/initramfs.testing" | tee "$TESTDIR/qemu.log"
+    check_log '^All OK' "$TESTDIR/qemu.log"
+    client_test_end
+}
+
+test_run() {
+    port=$(start_webserver)
+
+    client_run "root=live:http://server/root.squashfs" "root=live:http://10.0.2.2:$port/root.squashfs"
+}
+
+test_setup() {
+    # create root filesystem
+    call_dracut --tmpdir "$TESTDIR" \
+        --add-confdir test-root \
+        -f "$TESTDIR"/initramfs.root
+
+    mksquashfs "$TESTDIR"/dracut.*/initramfs/ "$TESTDIR/root.squashfs" -quiet
+
+    test_dracut -a "livenet" --no-hostonly
+}
+
+test_cleanup() {
+    if [[ -s "$TESTDIR/webserver.pid" ]]; then
+        pid=$(cat "$TESTDIR/webserver.pid")
+        echo "Stopping HTTP server (pid $pid)..." >&2
+        kill "$pid"
+        rm "$TESTDIR/webserver.pid"
+    fi
+}
+
+# shellcheck disable=SC1090
+. "$testdir"/test-functions