Blame 0009-TEST-10-RAID-extend-test-case-to-shutdown.patch

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