]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
test: execute test-init.sh at the end of each test case boot
authorLaszlo Gombos <laszlo.gombos@gmail.com>
Fri, 3 May 2024 13:29:59 +0000 (09:29 -0400)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Sat, 4 May 2024 02:34:43 +0000 (22:34 -0400)
16 files changed:
modules.d/80test-root/module-setup.sh
modules.d/80test-root/test-init.sh [new file with mode: 0755]
test/TEST-01-BASIC/test-init.sh
test/TEST-02-SYSTEMD/test-init.sh
test/TEST-03-USR-MOUNT/test-init.sh
test/TEST-04-FULL-SYSTEMD/test-init.sh
test/TEST-04-FULL-SYSTEMD/test.sh
test/TEST-10-RAID/test-init.sh
test/TEST-11-LVM/test-init.sh
test/TEST-12-RAID-DEG/test-init.sh
test/TEST-13-ENC-RAID-LVM/test-init.sh
test/TEST-14-IMSM/test-init.sh
test/TEST-15-BTRFSRAID/test-init.sh
test/TEST-16-DMSQUASH/test-init.sh
test/TEST-17-LVM-THIN/test-init.sh
test/TEST-18-UEFI/test-init.sh

index 088113596eafda0c9b1f8c5eaeea16acafb0ae45..cec28ee922c905f0cc5ef105f90a8d48ecf1f419 100755 (executable)
@@ -26,5 +26,7 @@ install() {
     inst_script "${dracutbasedir}/modules.d/99base/dracut-lib.sh" "/lib/dracut-lib.sh"
     inst_script "${dracutbasedir}/modules.d/99base/dracut-dev-lib.sh" "/lib/dracut-dev-lib.sh"
 
+    inst_script "$moddir/test-init.sh" "/test-init.sh"
+
     inst_multiple -o plymouth
 }
diff --git a/modules.d/80test-root/test-init.sh b/modules.d/80test-root/test-init.sh
new file mode 100755 (executable)
index 0000000..0f2fedd
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+export PATH=/usr/sbin:/usr/bin:/sbin:/bin
+
+[ -e /proc/self/mounts ] \
+    || (mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc)
+
+grep -q '^sysfs /sys sysfs' /proc/self/mounts \
+    || (mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys)
+
+grep -q '^devtmpfs /dev devtmpfs' /proc/self/mounts \
+    || (mkdir -p /dev && mount -t devtmpfs -o mode=755,noexec,nosuid,strictatime devtmpfs /dev)
+
+grep -q '^tmpfs /run tmpfs' /proc/self/mounts \
+    || (mkdir -p /run && mount -t tmpfs -o mode=755,noexec,nosuid,strictatime tmpfs /run)
+
+: > /dev/watchdog
+
+exec > /dev/console 2>&1
+
+if [ -s /failed ]; then
+    echo "**************************FAILED**************************"
+    cat /failed
+    echo "**************************FAILED**************************"
+else
+    echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
+    echo "All OK"
+fi
+
+export TERM=linux
+export PS1='initramfs-test:\w\$ '
+[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
+[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
+stty sane
+echo "made it to the rootfs!"
+
+. /lib/dracut-lib.sh
+
+if getargbool 0 rd.shell; then
+    strstr "$(setsid --help)" "control" && CTTY="-c"
+    # shellcheck disable=SC2086
+    setsid $CTTY sh -i
+fi
+
+echo "Powering down."
+mount -n -o remount,ro /
+if [ -d /run/initramfs/etc ]; then
+    echo " rd.debug=0 " >> /run/initramfs/etc/cmdline
+fi
+poweroff -f
index ba42fc2d8a46b8480fe4746ff6f23abc135692ef..c418b8bce66c9029a078527daa5203d79217ca9a 100755 (executable)
@@ -1,24 +1,3 @@
 #!/bin/sh
-: > /dev/watchdog
 
-. /lib/dracut-lib.sh
-
-export PATH=/usr/sbin:/usr/bin:/sbin:/bin
-command -v plymouth > /dev/null 2>&1 && plymouth --quit
-exec > /dev/console 2>&1
-
-echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
-
-export TERM=linux
-export PS1='initramfs-test:\w\$ '
-[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
-[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
-stty sane
-echo "made it to the rootfs!"
-if getargbool 0 rd.shell; then
-    strstr "$(setsid --help)" "control" && CTTY="-c"
-    setsid $CTTY sh -i
-fi
-echo "Powering down."
-mount -n -o remount,ro /
-poweroff -f
+. /test-init.sh
index ba42fc2d8a46b8480fe4746ff6f23abc135692ef..c418b8bce66c9029a078527daa5203d79217ca9a 100755 (executable)
@@ -1,24 +1,3 @@
 #!/bin/sh
-: > /dev/watchdog
 
-. /lib/dracut-lib.sh
-
-export PATH=/usr/sbin:/usr/bin:/sbin:/bin
-command -v plymouth > /dev/null 2>&1 && plymouth --quit
-exec > /dev/console 2>&1
-
-echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
-
-export TERM=linux
-export PS1='initramfs-test:\w\$ '
-[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
-[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
-stty sane
-echo "made it to the rootfs!"
-if getargbool 0 rd.shell; then
-    strstr "$(setsid --help)" "control" && CTTY="-c"
-    setsid $CTTY sh -i
-fi
-echo "Powering down."
-mount -n -o remount,ro /
-poweroff -f
+. /test-init.sh
index ba42fc2d8a46b8480fe4746ff6f23abc135692ef..c418b8bce66c9029a078527daa5203d79217ca9a 100755 (executable)
@@ -1,24 +1,3 @@
 #!/bin/sh
-: > /dev/watchdog
 
-. /lib/dracut-lib.sh
-
-export PATH=/usr/sbin:/usr/bin:/sbin:/bin
-command -v plymouth > /dev/null 2>&1 && plymouth --quit
-exec > /dev/console 2>&1
-
-echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
-
-export TERM=linux
-export PS1='initramfs-test:\w\$ '
-[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
-[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
-stty sane
-echo "made it to the rootfs!"
-if getargbool 0 rd.shell; then
-    strstr "$(setsid --help)" "control" && CTTY="-c"
-    setsid $CTTY sh -i
-fi
-echo "Powering down."
-mount -n -o remount,ro /
-poweroff -f
+. /test-init.sh
index 19e466c4eda89461eddcb7400203db2fa6e56267..83508d8760575a795185ac2333b6fb8c13c50b9a 100755 (executable)
@@ -1,40 +1,21 @@
 #!/bin/sh
 : > /dev/watchdog
 
-. /lib/dracut-lib.sh
-
 export PATH=/usr/sbin:/usr/bin:/sbin:/bin
 command -v plymouth > /dev/null 2>&1 && plymouth --quit
 exec > /dev/console 2>&1
 
 systemctl --failed --no-legend --no-pager > /failed
 
+ismounted() {
+    findmnt "$1" > /dev/null 2>&1
+}
+
 if ! ismounted /usr; then
     echo "**************************FAILED**************************"
     echo "/usr not mounted!!"
-    cat /proc/mounts
+    cat /proc/mounts >> /failed
     echo "**************************FAILED**************************"
-else
-    if [ -s /failed ]; then
-        echo "**************************FAILED**************************"
-        cat /failed
-        echo "**************************FAILED**************************"
-
-    else
-        echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
-        echo "All OK"
-    fi
 fi
 
-export TERM=linux
-export PS1='initramfs-test:\w\$ '
-[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
-[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
-stty sane
-echo "made it to the rootfs!"
-if getargbool 0 rd.shell; then
-    strstr "$(setsid --help)" "control" && CTTY="-c"
-    setsid $CTTY sh -i
-fi
-echo "Powering down."
-poweroff -f
+. /test-init.sh
index e2302c03687b64ec4b3fa175e9079ea2c76c2fb6..9183937ea8af0729261bf8edb7ba298593f13de1 100755 (executable)
@@ -54,6 +54,7 @@ test_setup() {
     "$DRACUT" -l --keep --tmpdir "$TESTDIR" \
         -m "test-root systemd" \
         -i ./test-init.sh /sbin/test-init \
+        -I "findmnt" \
         -i ./fstab /etc/fstab \
         --no-hostonly --no-hostonly-cmdline --nomdadmconf --nohardlink \
         -f "$TESTDIR"/initramfs.root "$KVERSION" || return 1
index ba42fc2d8a46b8480fe4746ff6f23abc135692ef..c418b8bce66c9029a078527daa5203d79217ca9a 100755 (executable)
@@ -1,24 +1,3 @@
 #!/bin/sh
-: > /dev/watchdog
 
-. /lib/dracut-lib.sh
-
-export PATH=/usr/sbin:/usr/bin:/sbin:/bin
-command -v plymouth > /dev/null 2>&1 && plymouth --quit
-exec > /dev/console 2>&1
-
-echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
-
-export TERM=linux
-export PS1='initramfs-test:\w\$ '
-[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
-[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
-stty sane
-echo "made it to the rootfs!"
-if getargbool 0 rd.shell; then
-    strstr "$(setsid --help)" "control" && CTTY="-c"
-    setsid $CTTY sh -i
-fi
-echo "Powering down."
-mount -n -o remount,ro /
-poweroff -f
+. /test-init.sh
index ba42fc2d8a46b8480fe4746ff6f23abc135692ef..c418b8bce66c9029a078527daa5203d79217ca9a 100755 (executable)
@@ -1,24 +1,3 @@
 #!/bin/sh
-: > /dev/watchdog
 
-. /lib/dracut-lib.sh
-
-export PATH=/usr/sbin:/usr/bin:/sbin:/bin
-command -v plymouth > /dev/null 2>&1 && plymouth --quit
-exec > /dev/console 2>&1
-
-echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
-
-export TERM=linux
-export PS1='initramfs-test:\w\$ '
-[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
-[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
-stty sane
-echo "made it to the rootfs!"
-if getargbool 0 rd.shell; then
-    strstr "$(setsid --help)" "control" && CTTY="-c"
-    setsid $CTTY sh -i
-fi
-echo "Powering down."
-mount -n -o remount,ro /
-poweroff -f
+. /test-init.sh
index 71685fb1466ff471f3fe56474fa7ad6883f05be4..c418b8bce66c9029a078527daa5203d79217ca9a 100755 (executable)
@@ -1,27 +1,3 @@
 #!/bin/sh
-: > /dev/watchdog
 
-. /lib/dracut-lib.sh
-
-export PATH=/usr/sbin:/usr/bin:/sbin:/bin
-command -v plymouth > /dev/null 2>&1 && plymouth --quit
-exec > /dev/console 2>&1
-
-echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
-
-export TERM=linux
-export PS1='initramfs-test:\w\$ '
-[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
-[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
-stty sane
-echo "made it to the rootfs!"
-if getargbool 0 rd.shell; then
-    strstr "$(setsid --help)" "control" && CTTY="-c"
-    setsid $CTTY sh -i
-fi
-echo "Powering down."
-mount -n -o remount,ro /
-if [ -d /run/initramfs/etc ]; then
-    echo " rd.debug=0 " >> /run/initramfs/etc/cmdline
-fi
-poweroff -f
+. /test-init.sh
index 71685fb1466ff471f3fe56474fa7ad6883f05be4..c418b8bce66c9029a078527daa5203d79217ca9a 100755 (executable)
@@ -1,27 +1,3 @@
 #!/bin/sh
-: > /dev/watchdog
 
-. /lib/dracut-lib.sh
-
-export PATH=/usr/sbin:/usr/bin:/sbin:/bin
-command -v plymouth > /dev/null 2>&1 && plymouth --quit
-exec > /dev/console 2>&1
-
-echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
-
-export TERM=linux
-export PS1='initramfs-test:\w\$ '
-[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
-[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
-stty sane
-echo "made it to the rootfs!"
-if getargbool 0 rd.shell; then
-    strstr "$(setsid --help)" "control" && CTTY="-c"
-    setsid $CTTY sh -i
-fi
-echo "Powering down."
-mount -n -o remount,ro /
-if [ -d /run/initramfs/etc ]; then
-    echo " rd.debug=0 " >> /run/initramfs/etc/cmdline
-fi
-poweroff -f
+. /test-init.sh
index 71685fb1466ff471f3fe56474fa7ad6883f05be4..c418b8bce66c9029a078527daa5203d79217ca9a 100755 (executable)
@@ -1,27 +1,3 @@
 #!/bin/sh
-: > /dev/watchdog
 
-. /lib/dracut-lib.sh
-
-export PATH=/usr/sbin:/usr/bin:/sbin:/bin
-command -v plymouth > /dev/null 2>&1 && plymouth --quit
-exec > /dev/console 2>&1
-
-echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
-
-export TERM=linux
-export PS1='initramfs-test:\w\$ '
-[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
-[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
-stty sane
-echo "made it to the rootfs!"
-if getargbool 0 rd.shell; then
-    strstr "$(setsid --help)" "control" && CTTY="-c"
-    setsid $CTTY sh -i
-fi
-echo "Powering down."
-mount -n -o remount,ro /
-if [ -d /run/initramfs/etc ]; then
-    echo " rd.debug=0 " >> /run/initramfs/etc/cmdline
-fi
-poweroff -f
+. /test-init.sh
index 668b87120c3764245da541fc1788acdfc981d30c..c418b8bce66c9029a078527daa5203d79217ca9a 100755 (executable)
@@ -1,25 +1,3 @@
 #!/bin/sh
-: > /dev/watchdog
 
-. /lib/dracut-lib.sh
-
-export PATH=/usr/sbin:/usr/bin:/sbin:/bin
-command -v plymouth > /dev/null 2>&1 && plymouth --quit
-exec > /dev/console 2>&1
-
-echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
-
-export TERM=linux
-export PS1='initramfs-test:\w\$ '
-[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
-[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
-stty sane
-echo "made it to the rootfs!"
-if getargbool 0 rd.shell; then
-    strstr "$(setsid --help)" "control" && CTTY="-c"
-    setsid $CTTY sh -i
-fi
-echo "Powering down."
-mount -n -o remount,ro /
-
-poweroff -f
+. /test-init.sh
index d23fcef3e5793ceb2a388e4d4e4780ace56f5f3d..13c88aaf5a4e2c3757fd271d02b13ac257aa4ef8 100755 (executable)
@@ -1,13 +1,4 @@
 #!/bin/sh
-: > /dev/watchdog
-
-. /lib/dracut-lib.sh
-
-export PATH=/usr/sbin:/usr/bin:/sbin:/bin
-command -v plymouth > /dev/null 2>&1 && plymouth --quit
-exec > /dev/console 2>&1
-
-echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
 
 if grep -qF ' rd.live.overlay=LABEL=persist ' /proc/cmdline; then
     # Writing to a file in the root filesystem lets test_run() verify that the autooverlay module successfully created
@@ -15,17 +6,4 @@ if grep -qF ' rd.live.overlay=LABEL=persist ' /proc/cmdline; then
     echo "dracut-autooverlay-success" > /overlay-marker
 fi
 
-export TERM=linux
-export PS1='initramfs-test:\w\$ '
-[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
-[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
-stty sane
-echo "made it to the rootfs!"
-if getargbool 0 rd.shell; then
-    strstr "$(setsid --help)" "control" && CTTY="-c"
-    setsid $CTTY sh -i
-fi
-echo "Powering down."
-mount -n -o remount,ro /
-
-poweroff -f
+. /test-init.sh
index ba42fc2d8a46b8480fe4746ff6f23abc135692ef..c418b8bce66c9029a078527daa5203d79217ca9a 100755 (executable)
@@ -1,24 +1,3 @@
 #!/bin/sh
-: > /dev/watchdog
 
-. /lib/dracut-lib.sh
-
-export PATH=/usr/sbin:/usr/bin:/sbin:/bin
-command -v plymouth > /dev/null 2>&1 && plymouth --quit
-exec > /dev/console 2>&1
-
-echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
-
-export TERM=linux
-export PS1='initramfs-test:\w\$ '
-[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
-[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
-stty sane
-echo "made it to the rootfs!"
-if getargbool 0 rd.shell; then
-    strstr "$(setsid --help)" "control" && CTTY="-c"
-    setsid $CTTY sh -i
-fi
-echo "Powering down."
-mount -n -o remount,ro /
-poweroff -f
+. /test-init.sh
index 0000e15df72c68bec265d4b77060fd159aef5f5d..c418b8bce66c9029a078527daa5203d79217ca9a 100755 (executable)
@@ -1,23 +1,3 @@
 #!/bin/sh
 
-export PATH=/usr/sbin:/usr/bin:/sbin:/bin
-
-[ -e /proc/self/mounts ] \
-    || (mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc)
-
-grep -q '^sysfs /sys sysfs' /proc/self/mounts \
-    || (mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys)
-
-grep -q '^devtmpfs /dev devtmpfs' /proc/self/mounts \
-    || (mkdir -p /dev && mount -t devtmpfs -o mode=755,noexec,nosuid,strictatime devtmpfs /dev)
-
-grep -q '^tmpfs /run tmpfs' /proc/self/mounts \
-    || (mkdir -p /run && mount -t tmpfs -o mode=755,noexec,nosuid,strictatime tmpfs /run)
-
-: > /dev/watchdog
-
-exec > /dev/console 2>&1
-
-echo "made it to the rootfs! Powering down."
-echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
-poweroff -f
+. /test-init.sh