]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
refactor(test): move check_qemu_log to test-functions
authorBenjamin Drung <benjamin.drung@canonical.com>
Fri, 23 Jan 2026 17:17:53 +0000 (18:17 +0100)
committerLaszlo <laszlo.gombos@gmail.com>
Fri, 23 Jan 2026 21:08:53 +0000 (16:08 -0500)
Move `check_log` to `test/test-functions`, name it `check_qemu_log`, and
do not require to specify the success message (which will be the same
for all tests).

test/TEST-31-LIVENET/test.sh
test/test-functions

index 739bc19beeb3f3aaf9e7bc435a24890dbc60912c..886c5b0dbd205ea8a4026c7de0756f0b4e3d8f35 100755 (executable)
@@ -37,16 +37,6 @@ start_webserver() {
     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"
@@ -57,7 +47,7 @@ client_run() {
         -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"
+    check_qemu_log "$TESTDIR/qemu.log"
     client_test_end
 }
 
index ff453e3156bf889b123ed9da1cd6bb01dee9013a..34481c4670314c74b71b7d4059111d1f15bf5a9f 100644 (file)
@@ -84,6 +84,16 @@ call_dracut() {
     "$DRACUT" "$@"
 }
 
+# Check QEMU logs for success marker
+check_qemu_log() {
+    local logfile="$1"
+
+    if ! grep -q "^All OK" "${logfile}"; then
+        echo >&2 "E: Message 'All OK' not found in QEMU log output '${logfile}'."
+        return 1
+    fi
+}
+
 # Log the start of a client test.
 client_test_start() {
     local test_name="$1"