dracut/0009-TEST-10-RAID-extend-te...

100 lines
3.7 KiB
Diff

From ceaf49d735b2395897253ae05f6a3b55e09eb252 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Wed, 20 Jul 2011 19:08:25 +0200
Subject: [PATCH] TEST-10-RAID: extend test case to shutdown
---
test/TEST-10-RAID/test-init | 13 +++++++++++--
test/TEST-10-RAID/test.sh | 17 +++++++++--------
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/test/TEST-10-RAID/test-init b/test/TEST-10-RAID/test-init
index 8f7cdf3..029084a 100755
--- a/test/TEST-10-RAID/test-init
+++ b/test/TEST-10-RAID/test-init
@@ -1,11 +1,20 @@
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+strstr() { [ "${1#*$2*}" != "$1" ]; }
+CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
+plymouth --quit
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda1
export TERM=linux
export PS1='initramfs-test:\w\$ '
-[ -f /etc/fstab ] || ln -s /proc/mounts /etc/fstab
+[ -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! Powering down."
+echo "made it to the rootfs!"
+strstr "$CMDLINE" "rd.shell" && sh -i
+echo "Powering down."
mount -n -o remount,ro /
+if [ -e /lib/systemd/systemd-shutdown ]; then
+ exec /lib/systemd/systemd-shutdown poweroff
+fi
poweroff -f
diff --git a/test/TEST-10-RAID/test.sh b/test/TEST-10-RAID/test.sh
index 0b3fc0c..fe95437 100755
--- a/test/TEST-10-RAID/test.sh
+++ b/test/TEST-10-RAID/test.sh
@@ -5,18 +5,18 @@ KVERSION=${KVERSION-$(uname -r)}
# Uncomment this to debug failures
#DEBUGFAIL="rd.shell"
-
+DISKIMAGE=/var/tmp/TEST-10-RAID-root.img
test_run() {
- $testdir/run-qemu -hda root.ext2 -m 256M -nographic \
+ $testdir/run-qemu -hda $DISKIMAGE -m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-initrd initramfs.testing
- grep -m 1 -q dracut-root-block-success root.ext2 || return 1
+ grep -m 1 -q dracut-root-block-success $DISKIMAGE || return 1
}
test_setup() {
# Create the blank file to use as a root filesystem
- dd if=/dev/zero of=root.ext2 bs=1M count=40
+ dd if=/dev/null of=$DISKIMAGE bs=1M seek=40
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
@@ -28,9 +28,10 @@ test_setup() {
inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
dracut_install grep
+ dracut_install /lib/systemd/systemd-shutdown
inst ./test-init /sbin/init
find_binary plymouth >/dev/null && dracut_install plymouth
- (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
+ (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp run)
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
)
@@ -54,11 +55,11 @@ test_setup() {
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
- $testdir/run-qemu -hda root.ext2 -m 256M -nographic -net none \
+ $testdir/run-qemu -hda $DISKIMAGE -m 256M -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd initramfs.makeroot || return 1
- grep -m 1 -q dracut-root-block-created root.ext2 || return 1
+ grep -m 1 -q dracut-root-block-created $DISKIMAGE || return 1
(
initdir=overlay
. $basedir/dracut-functions
@@ -76,7 +77,7 @@ test_setup() {
test_cleanup() {
rm -fr overlay mnt
- rm -f root.ext2 initramfs.makeroot initramfs.testing
+ rm -f $DISKIMAGE initramfs.makeroot initramfs.testing
}
. $testdir/test-functions