]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
test: log dracut calls if V=1 or V=2 is set
authorBenjamin Drung <benjamin.drung@canonical.com>
Fri, 31 Oct 2025 12:35:43 +0000 (13:35 +0100)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Fri, 31 Oct 2025 13:28:01 +0000 (09:28 -0400)
Logging the qemu calls (in `run-qemu`) helps a lot in debugging. So log
dracut calls as well if V=1 or V=2 is set.

17 files changed:
test/TEST-10-BASIC/test.sh
test/TEST-11-USR-MOUNT/test.sh
test/TEST-12-UEFI/test.sh
test/TEST-13-SYSROOT/test.sh
test/TEST-20-STORAGE/test.sh
test/TEST-26-ENC-RAID-LVM/test.sh
test/TEST-30-DMSQUASH/test.sh
test/TEST-40-SYSTEMD/test.sh
test/TEST-41-FULL-SYSTEMD/test.sh
test/TEST-42-SYSTEMD-INITRD/test.sh
test/TEST-43-KERNEL-INSTALL/test.sh
test/TEST-50-NETWORK/test.sh
test/TEST-60-NFS/test.sh
test/TEST-70-ISCSI/test.sh
test/TEST-71-ISCSI-MULTI/test.sh
test/TEST-72-NBD/test.sh
test/test-functions

index a5d2a0a641e72ae947d991a3b3f5a5ab2ccf100a..586697955134609aa1ef8e196cb41efdfa9dba85 100755 (executable)
@@ -22,7 +22,7 @@ test_run() {
 
 test_setup() {
     # create root filesystem
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -f "$TESTDIR"/initramfs.root
 
index c40034e0728f2b616d5800c7b0eed1125ee1fab9..5392bde010a6d5b3654c5952be49ba16ad379142 100755 (executable)
@@ -49,7 +49,7 @@ test_run() {
 
 test_setup() {
     # Create what will eventually be our root filesystem onto an overlay
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         --mount "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root /usr btrfs subvol=usr,rw" \
         -f "$TESTDIR"/initramfs.root
@@ -60,7 +60,7 @@ test_setup() {
     # create an initramfs that will create the target root filesystem.
     # We do it this way so that we do not risk trashing the host mdraid
     # devices, volume groups, encrypted partitions, etc.
-    "$DRACUT" -i "$TESTDIR"/overlay / \
+    call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir test-makeroot \
         -I "mkfs.btrfs" \
         -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \
index 9f62c5cbb9f726e95a035eb96d1e15648e494924..7107dee975086eb0ee4ba0079ab45b7302cb9208 100755 (executable)
@@ -46,7 +46,7 @@ test_run() {
 
 test_setup() {
     # Create what will eventually be our root filesystem
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         "$TESTDIR"/tmp-initramfs.root
 
index 3a069fc834b64752cfe0ecc18fb6f6ac4b0afa8e..627ca741f9483189d143b18d00f7822d81813474 100755 (executable)
@@ -22,7 +22,7 @@ test_run() {
 
 test_setup() {
     # create root filesystem
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -f "$TESTDIR"/initramfs.root
 
index 8d47eab051dc1eeb3289f02b7478730dd759a157..990d5549071bd932983621fcead07022f4560f7e 100755 (executable)
@@ -114,7 +114,7 @@ test_makeroot() {
 
 test_setup() {
     # Create what will eventually be our root filesystem onto an overlay
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -f "$TESTDIR"/initramfs.root
     mkdir -p "$TESTDIR"/overlay/source
@@ -129,7 +129,7 @@ test_setup() {
     # devices, volume groups, encrypted partitions, etc.
 
     # shellcheck disable=SC2046
-    "$DRACUT" -i "$TESTDIR"/overlay / \
+    call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir test-makeroot \
         -a "lvm" \
         -I "grep" \
index a233843430fa0d2a8b52fc7cf7cc0d5681f4a298..14563d831c6618ecc36f2b0a7d9314c42dd95d87 100755 (executable)
@@ -54,7 +54,7 @@ test_run() {
 
 test_setup() {
     # Create what will eventually be our root filesystem onto an overlay
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -f "$TESTDIR"/initramfs.root
     mkdir -p "$TESTDIR"/overlay/source
@@ -64,7 +64,7 @@ test_setup() {
     # create an initramfs that will create the target root filesystem.
     # We do it this way so that we do not risk trashing the host mdraid
     # devices, volume groups, encrypted partitions, etc.
-    "$DRACUT" -i "$TESTDIR"/overlay / \
+    call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir test-makeroot \
         -a "bash crypt lvm mdraid" \
         -I "grep cryptsetup" \
index 1132f89e336899599ef825b83097f890e0dbd91f..323634bb25486c94e9cffb19080db03a810c95c3 100755 (executable)
@@ -82,7 +82,7 @@ test_run() {
 
 test_setup() {
     # Create what will eventually be our root filesystem onto an overlay
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -i ./test-init.sh /sbin/init-persist \
         -f "$TESTDIR"/initramfs.root
index b281c33445e5aff98a22d2530820bea93a70d0c9..f62f4f9913bd3d9e88893091579e5f5963b1ef53 100755 (executable)
@@ -26,7 +26,7 @@ test_run() {
 
 test_setup() {
     # Create what will eventually be our root filesystem onto an overlay
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -f "$TESTDIR"/initramfs.root
     mkdir -p "$TESTDIR"/overlay/source
@@ -36,7 +36,7 @@ test_setup() {
     # create an initramfs that will create the target root filesystem.
     # We do it this way so that we do not risk trashing the host mdraid
     # devices, volume groups, encrypted partitions, etc.
-    "$DRACUT" -i "$TESTDIR"/overlay / \
+    call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir "test-makeroot" \
         -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \
         -f "$TESTDIR"/initramfs.makeroot
index 7845e6c781a8b52fcc7b0da2c03cd2d5c6ad7b88..517045552c7cbc469f1e1b15fb1fb64780d50211 100755 (executable)
@@ -91,7 +91,7 @@ test_setup() {
     fi
 
     # Create what will eventually be our root filesystem onto an overlay
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -a "$dracut_modules" \
         -f "$TESTDIR"/initramfs.root
@@ -105,7 +105,7 @@ test_setup() {
     # create an initramfs that will create the target root filesystem.
     # We do it this way so that we do not risk trashing the host mdraid
     # devices, volume groups, encrypted partitions, etc.
-    "$DRACUT" -i "$TESTDIR"/overlay / \
+    call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir test-makeroot \
         -a "btrfs crypt" \
         -I "mkfs.btrfs cryptsetup" \
index 226b9d6c8b19bd16824fec6a6b5cea832f8ab672..b511c60b305ec24c2ddb5862cd87cb321e12d1e0 100755 (executable)
@@ -42,7 +42,7 @@ test_run() {
 
 test_setup() {
     # Create what will eventually be our root filesystem onto an overlay
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -f "$TESTDIR"/initramfs.root
     mkdir -p "$TESTDIR"/overlay/source
@@ -52,7 +52,7 @@ test_setup() {
     # create an initramfs that will create the target root filesystem.
     # We do it this way so that we do not risk trashing the host mdraid
     # devices, volume groups, encrypted partitions, etc.
-    "$DRACUT" -i "$TESTDIR"/overlay / \
+    call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir test-makeroot \
         -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \
         -f "$TESTDIR"/initramfs.makeroot
@@ -73,7 +73,7 @@ test_setup() {
 
     # initrd for required kernel modules
     # Improve boot time by generating two initrds. Do not re-compress kernel modules
-    "$DRACUT" \
+    call_dracut \
         --no-compress \
         --kernel-only \
         -m "kernel-modules qemu" \
index 345e3367a0b6014454be6eb48147b7e6cc3b45e1..480c78693ec86dc7566db50066dfac0cbf97cf80 100755 (executable)
@@ -40,7 +40,7 @@ test_run() {
 test_setup() {
     # create root filesystem
     # shellcheck disable=SC2153
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -f "$TESTDIR"/initramfs.root
 
index e366bed864a887df450cd8a2c1e9e2eb7836bb80..fce207d47913abc4cbd0c5b2c2556b07834bc808 100755 (executable)
@@ -27,7 +27,7 @@ test_run() {
 
 test_setup() {
     # create root filesystem
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         -I "ip" \
         -i "./assertion.sh" "/assertion.sh" \
         --add-confdir test-root \
index 7da3625304467dbd25a8542fc7ae4a32b3324994..cb350dd6b2fc0abe771afec8d62fb3b3cab2ae75 100755 (executable)
@@ -221,7 +221,7 @@ test_run() {
 }
 
 test_setup() {
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -a "$USE_NETWORK url-lib nfs" \
         -I "ip grep setsid" \
@@ -230,7 +230,7 @@ test_setup() {
     mkdir -p "$TESTDIR"/server/overlay
 
     # Create what will eventually be the server root filesystem onto an overlay
-    "$DRACUT" --tmpdir "$TESTDIR"/server/overlay \
+    call_dracut --tmpdir "$TESTDIR"/server/overlay \
         --add-confdir test-root \
         -a "bash $USE_NETWORK nfs" \
         --add-drivers "nfsd sunrpc lockd" \
@@ -262,7 +262,7 @@ test_setup() {
     # create an initramfs that will create the target root filesystem.
     # We do it this way so that we do not risk trashing the host mdraid
     # devices, volume groups, encrypted partitions, etc.
-    "$DRACUT" -i "$TESTDIR"/server/overlay / \
+    call_dracut -i "$TESTDIR"/server/overlay / \
         --add-confdir test-makeroot \
         -a "bash" \
         -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \
@@ -289,7 +289,7 @@ test_setup() {
         -a "watchdog dmsquash-live qemu-net ${USE_NETWORK}"
 
     # Make server's dracut image
-    "$DRACUT" \
+    call_dracut \
         -a "bash qemu-net $USE_NETWORK ${SERVER_DEBUG:+debug}" \
         --include ./server.link /etc/systemd/network/01-server.link \
         --include ./wait-if-server.sh /lib/dracut/hooks/pre-mount/99-wait-if-server.sh \
index 54a6ef3845331961c55e2d3d54c9e5fe03825216..9bc58c0d619373a3beab5acc81b017a5d812e11b 100755 (executable)
@@ -130,7 +130,7 @@ test_check() {
 
 test_setup() {
     # Create what will eventually be the client root filesystem onto an overlay
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -I "ip grep setsid" \
         -f "$TESTDIR"/initramfs.root
@@ -144,7 +144,7 @@ test_setup() {
     # create an initramfs that will create the target root filesystem.
     # We do it this way so that we do not risk trashing the host mdraid
     # devices, volume groups, encrypted partitions, etc.
-    "$DRACUT" -i "$TESTDIR"/overlay / \
+    call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir test-makeroot \
         -a "crypt lvm mdraid" \
         -I "setsid blockdev" \
@@ -168,7 +168,7 @@ test_setup() {
     rm -- "$TESTDIR"/marker.img
 
     # Create what will eventually be the server root filesystem onto an overlay
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -a "$USE_NETWORK" \
         -d "iscsi_tcp crc32c ipv6" \
@@ -186,7 +186,7 @@ test_setup() {
     # create an initramfs that will create the target root filesystem.
     # We do it this way so that we do not risk trashing the host mdraid
     # devices, volume groups, encrypted partitions, etc.
-    "$DRACUT" -i "$TESTDIR"/overlay / \
+    call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir test-makeroot \
         -i ./create-server-root.sh /lib/dracut/hooks/initqueue/01-create-server-root.sh \
         -f "$TESTDIR"/initramfs.makeroot
@@ -207,7 +207,7 @@ test_setup() {
     rm -- "$TESTDIR"/marker.img
 
     # Make server's dracut image
-    "$DRACUT" \
+    call_dracut \
         -a "qemu-net $USE_NETWORK" \
         --add-confdir test \
         -i "./server.link" "/etc/systemd/network/01-server.link" \
index ff7b85659961fe04b1535a30db9ea0426ed34426..983cb4ee7bab6a7d4a1f1971bf1c616e29113043 100755 (executable)
@@ -138,7 +138,7 @@ test_check() {
 test_setup() {
     # Create what will eventually be our root filesystem onto an overlay
     rm -rf -- "$TESTDIR"/overlay
-    "$DRACUT" --keep --tmpdir "$TESTDIR" \
+    call_dracut --keep --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -I "ip grep setsid" \
         --no-hostonly \
@@ -152,7 +152,7 @@ test_setup() {
     # create an initramfs that will create the target root filesystem.
     # We do it this way so that we do not risk trashing the host mdraid
     # devices, volume groups, encrypted partitions, etc.
-    "$DRACUT" -i "$TESTDIR"/overlay / \
+    call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir test-makeroot \
         -a "crypt lvm mdraid" \
         -I "setsid blockdev" \
@@ -176,7 +176,7 @@ test_setup() {
     rm -- "$TESTDIR"/marker.img
 
     rm -rf -- "$TESTDIR"/overlay
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -a "$USE_NETWORK iscsi" \
         -d "iscsi_tcp crc32c ipv6 af_packet" \
@@ -195,7 +195,7 @@ test_setup() {
     # create an initramfs that will create the target root filesystem.
     # We do it this way so that we do not risk trashing the host mdraid
     # devices, volume groups, encrypted partitions, etc.
-    "$DRACUT" -i "$TESTDIR"/overlay / \
+    call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir test-makeroot \
         -i ./create-server-root.sh /lib/dracut/hooks/initqueue/01-create-server-root.sh \
         -f "$TESTDIR"/initramfs.makeroot
@@ -223,7 +223,7 @@ test_setup() {
         -i ./client-persistent-lan1.link /etc/systemd/network/01-persistent-lan1.link
 
     # Make server's dracut image
-    "$DRACUT" -i "$TESTDIR"/overlay / \
+    call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir test \
         -a "qemu-net $USE_NETWORK ${SERVER_DEBUG:+debug}" \
         -i "./server.link" "/etc/systemd/network/01-server.link" \
index a5694a45267b6a79747699fb61b797a058f7fb25..8a77663416027aad988095825979623f911ad80a 100755 (executable)
@@ -177,7 +177,7 @@ client_run() {
 make_encrypted_root() {
     rm -fr "$TESTDIR"/overlay
     # Create what will eventually be our root filesystem onto an overlay
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -I "ip grep" \
         --no-hostonly \
@@ -190,7 +190,7 @@ make_encrypted_root() {
     # create an initramfs that will create the target root filesystem.
     # We do it this way so that we do not risk trashing the host mdraid
     # devices, volume groups, encrypted partitions, etc.
-    "$DRACUT" -i "$TESTDIR"/overlay / \
+    call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir test-makeroot \
         -a "crypt lvm mdraid" \
         -I "cryptsetup" \
@@ -214,7 +214,7 @@ make_encrypted_root() {
 
 make_client_root() {
     rm -fr "$TESTDIR"/overlay
-    "$DRACUT" --tmpdir "$TESTDIR" \
+    call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -I "ip" \
         --no-hostonly \
@@ -227,7 +227,7 @@ make_client_root() {
     # create an initramfs that will create the target root filesystem.
     # We do it this way so that we do not risk trashing the host mdraid
     # devices, volume groups, encrypted partitions, etc.
-    "$DRACUT" -i "$TESTDIR"/overlay / \
+    call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir test-makeroot \
         -i ./create-client-root.sh /lib/dracut/hooks/initqueue/01-create-client-root.sh \
         -f "$TESTDIR"/initramfs.makeroot
@@ -261,7 +261,7 @@ port = 2001
 bs = 4096
 EOF
 
-    "$DRACUT" --keep --tmpdir "$TESTDIR" \
+    call_dracut --keep --tmpdir "$TESTDIR" \
         --add-confdir test-root \
         -a "$USE_NETWORK" \
         -I "ip grep sleep nbd-server chmod modprobe pidof" \
@@ -280,7 +280,7 @@ EOF
     # create an initramfs that will create the target root filesystem.
     # We do it this way so that we do not risk trashing the host mdraid
     # devices, volume groups, encrypted partitions, etc.
-    "$DRACUT" -i "$TESTDIR"/overlay / \
+    call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir test-makeroot \
         -i ./create-server-root.sh /lib/dracut/hooks/initqueue/01-create-server-root.sh \
         -f "$TESTDIR"/initramfs.makeroot
@@ -321,7 +321,7 @@ test_setup() {
         -i "/tmp/crypttab" "/etc/crypttab" \
         -i "/tmp/key" "/etc/key"
 
-    "$DRACUT" -N -i "$TESTDIR"/overlay / \
+    call_dracut -N -i "$TESTDIR"/overlay / \
         --add-confdir test \
         -a "qemu-net $USE_NETWORK ${SERVER_DEBUG:+debug}" \
         -i "./server.link" "/etc/systemd/network/01-server.link" \
index 8ad6f7d373b30ac2fb69b8755213384626e9508a..1b233d877d36e78f58ab3f77f9db7982fa90d20f 100644 (file)
@@ -59,11 +59,33 @@ test_dracut() {
     # shellcheck disable=SC2162
     IFS=' ' read -a TEST_DRACUT_ARGS_ARRAY <<< "$TEST_DRACUT_ARGS"
 
-    "$DRACUT" \
+    call_dracut \
         "${TEST_DRACUT_ARGS_ARRAY[@]}" \
         "$@" "$TESTDIR"/initramfs.testing || return 1
 }
 
+quote_args() {
+    local arg args=()
+    for arg in "$@"; do
+        if [[ -z $arg || $arg =~ [[:space:]\'] ]]; then
+            args+=("'${arg//\'/\'\\\'\'}'")
+        else
+            args+=("$arg")
+        fi
+    done
+    echo "${args[*]}"
+}
+
+# Call dracut and log its call in verbose mode
+call_dracut() {
+    # Uncomment this to debug failures
+    #set -- --stdlog 4 "$@"
+    if [[ ${V-} == "1" || ${V-} == "2" ]]; then
+        echo "Calling $DRACUT $(quote_args "$@")"
+    fi
+    "$DRACUT" "$@"
+}
+
 # Wait for the server QEMU has been started up.
 # It should print "Serving" in the server.log in that case.
 wait_for_server_startup() {