|
Harald Hoyer |
f3160a |
From 54703a719f49b3c4aafb60d49b265e2cde9bb16f Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
f3160a |
From: Harald Hoyer <harald@redhat.com>
|
|
Harald Hoyer |
f3160a |
Date: Wed, 20 Jul 2011 14:10:30 +0200
|
|
Harald Hoyer |
f3160a |
Subject: [PATCH] add TEST-15-BTRFSRAID
|
|
Harald Hoyer |
f3160a |
|
|
Harald Hoyer |
f3160a |
---
|
|
Harald Hoyer |
f3160a |
test/TEST-15-BTRFSRAID/99-idesymlinks.rules | 8 +++
|
|
Harald Hoyer |
f3160a |
test/TEST-15-BTRFSRAID/Makefile | 10 +++
|
|
Harald Hoyer |
f3160a |
test/TEST-15-BTRFSRAID/create-root.sh | 22 +++++++
|
|
Harald Hoyer |
f3160a |
test/TEST-15-BTRFSRAID/hard-off.sh | 3 +
|
|
Harald Hoyer |
f3160a |
test/TEST-15-BTRFSRAID/test-init | 11 ++++
|
|
Harald Hoyer |
f3160a |
test/TEST-15-BTRFSRAID/test.sh | 82 +++++++++++++++++++++++++++
|
|
Harald Hoyer |
f3160a |
6 files changed, 136 insertions(+), 0 deletions(-)
|
|
Harald Hoyer |
f3160a |
create mode 100644 test/TEST-15-BTRFSRAID/99-idesymlinks.rules
|
|
Harald Hoyer |
f3160a |
create mode 100644 test/TEST-15-BTRFSRAID/Makefile
|
|
Harald Hoyer |
f3160a |
create mode 100755 test/TEST-15-BTRFSRAID/create-root.sh
|
|
Harald Hoyer |
f3160a |
create mode 100755 test/TEST-15-BTRFSRAID/hard-off.sh
|
|
Harald Hoyer |
f3160a |
create mode 100755 test/TEST-15-BTRFSRAID/test-init
|
|
Harald Hoyer |
f3160a |
create mode 100755 test/TEST-15-BTRFSRAID/test.sh
|
|
Harald Hoyer |
f3160a |
|
|
Harald Hoyer |
f3160a |
diff --git a/test/TEST-15-BTRFSRAID/99-idesymlinks.rules b/test/TEST-15-BTRFSRAID/99-idesymlinks.rules
|
|
Harald Hoyer |
f3160a |
new file mode 100644
|
|
Harald Hoyer |
f3160a |
index 0000000..d557790
|
|
Harald Hoyer |
f3160a |
--- /dev/null
|
|
Harald Hoyer |
f3160a |
+++ b/test/TEST-15-BTRFSRAID/99-idesymlinks.rules
|
|
Harald Hoyer |
f3160a |
@@ -0,0 +1,8 @@
|
|
Harald Hoyer |
f3160a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hda", SYMLINK+="sda"
|
|
Harald Hoyer |
f3160a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hda*", SYMLINK+="sda$env{MINOR}"
|
|
Harald Hoyer |
f3160a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdb", SYMLINK+="sdb"
|
|
Harald Hoyer |
f3160a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdb*", SYMLINK+="sdb$env{MINOR}"
|
|
Harald Hoyer |
f3160a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdc", SYMLINK+="sdc"
|
|
Harald Hoyer |
f3160a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdc*", SYMLINK+="sdc$env{MINOR}"
|
|
Harald Hoyer |
f3160a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdd", SYMLINK+="sdd"
|
|
Harald Hoyer |
f3160a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdd*", SYMLINK+="sdd$env{MINOR}"
|
|
Harald Hoyer |
f3160a |
diff --git a/test/TEST-15-BTRFSRAID/Makefile b/test/TEST-15-BTRFSRAID/Makefile
|
|
Harald Hoyer |
f3160a |
new file mode 100644
|
|
Harald Hoyer |
f3160a |
index 0000000..bc0ddb6
|
|
Harald Hoyer |
f3160a |
--- /dev/null
|
|
Harald Hoyer |
f3160a |
+++ b/test/TEST-15-BTRFSRAID/Makefile
|
|
Harald Hoyer |
f3160a |
@@ -0,0 +1,10 @@
|
|
Harald Hoyer |
f3160a |
+all:
|
|
Harald Hoyer |
f3160a |
+ @make -s --no-print-directory -C ../.. all
|
|
Harald Hoyer |
f3160a |
+ @basedir=../.. testdir=../ ./test.sh --all
|
|
Harald Hoyer |
f3160a |
+setup:
|
|
Harald Hoyer |
f3160a |
+ @make --no-print-directory -C ../.. all
|
|
Harald Hoyer |
f3160a |
+ @basedir=../.. testdir=../ ./test.sh --setup
|
|
Harald Hoyer |
f3160a |
+clean:
|
|
Harald Hoyer |
f3160a |
+ @basedir=../.. testdir=../ ./test.sh --clean
|
|
Harald Hoyer |
f3160a |
+run:
|
|
Harald Hoyer |
f3160a |
+ @basedir=../.. testdir=../ ./test.sh --run
|
|
Harald Hoyer |
f3160a |
diff --git a/test/TEST-15-BTRFSRAID/create-root.sh b/test/TEST-15-BTRFSRAID/create-root.sh
|
|
Harald Hoyer |
f3160a |
new file mode 100755
|
|
Harald Hoyer |
f3160a |
index 0000000..60dd319
|
|
Harald Hoyer |
f3160a |
--- /dev/null
|
|
Harald Hoyer |
f3160a |
+++ b/test/TEST-15-BTRFSRAID/create-root.sh
|
|
Harald Hoyer |
f3160a |
@@ -0,0 +1,22 @@
|
|
Harald Hoyer |
f3160a |
+#!/bin/sh
|
|
Harald Hoyer |
f3160a |
+# don't let udev and this script step on eachother's toes
|
|
Harald Hoyer |
f3160a |
+for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
|
|
Harald Hoyer |
f3160a |
+ > "/etc/udev/rules.d/$x"
|
|
Harald Hoyer |
f3160a |
+done
|
|
Harald Hoyer |
f3160a |
+udevadm control --reload-rules
|
|
Harald Hoyer |
f3160a |
+# save a partition at the beginning for future flagging purposes
|
|
Harald Hoyer |
f3160a |
+sfdisk -C 524288 -H 2 -S 32 -L /dev/sda <
|
|
Harald Hoyer |
f3160a |
+,16
|
|
Harald Hoyer |
f3160a |
+,10240
|
|
Harald Hoyer |
f3160a |
+,10240
|
|
Harald Hoyer |
f3160a |
+,10240
|
|
Harald Hoyer |
f3160a |
+EOF
|
|
Harald Hoyer |
f3160a |
+mkfs.btrfs -mraid10 -L root /dev/sda2 /dev/sda3 /dev/sda4
|
|
Harald Hoyer |
f3160a |
+btrfs device scan
|
|
Harald Hoyer |
f3160a |
+set -e
|
|
Harald Hoyer |
f3160a |
+mkdir -p /sysroot
|
|
Harald Hoyer |
f3160a |
+mount /dev/sda4 /sysroot
|
|
Harald Hoyer |
f3160a |
+cp -a -t /sysroot /source/*
|
|
Harald Hoyer |
f3160a |
+umount /sysroot
|
|
Harald Hoyer |
f3160a |
+echo "dracut-root-block-created" >/dev/sda1
|
|
Harald Hoyer |
f3160a |
+poweroff -f
|
|
Harald Hoyer |
f3160a |
diff --git a/test/TEST-15-BTRFSRAID/hard-off.sh b/test/TEST-15-BTRFSRAID/hard-off.sh
|
|
Harald Hoyer |
f3160a |
new file mode 100755
|
|
Harald Hoyer |
f3160a |
index 0000000..12c3d5a
|
|
Harald Hoyer |
f3160a |
--- /dev/null
|
|
Harald Hoyer |
f3160a |
+++ b/test/TEST-15-BTRFSRAID/hard-off.sh
|
|
Harald Hoyer |
f3160a |
@@ -0,0 +1,3 @@
|
|
Harald Hoyer |
f3160a |
+#!/bin/sh
|
|
Harald Hoyer |
f3160a |
+getarg rd.shell || poweroff -f
|
|
Harald Hoyer |
f3160a |
+getarg failme && poweroff -f
|
|
Harald Hoyer |
f3160a |
diff --git a/test/TEST-15-BTRFSRAID/test-init b/test/TEST-15-BTRFSRAID/test-init
|
|
Harald Hoyer |
f3160a |
new file mode 100755
|
|
Harald Hoyer |
f3160a |
index 0000000..8f7cdf3
|
|
Harald Hoyer |
f3160a |
--- /dev/null
|
|
Harald Hoyer |
f3160a |
+++ b/test/TEST-15-BTRFSRAID/test-init
|
|
Harald Hoyer |
f3160a |
@@ -0,0 +1,11 @@
|
|
Harald Hoyer |
f3160a |
+#!/bin/sh
|
|
Harald Hoyer |
f3160a |
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
|
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 |
+stty sane
|
|
Harald Hoyer |
f3160a |
+echo "made it to the rootfs! Powering down."
|
|
Harald Hoyer |
f3160a |
+mount -n -o remount,ro /
|
|
Harald Hoyer |
f3160a |
+poweroff -f
|
|
Harald Hoyer |
f3160a |
diff --git a/test/TEST-15-BTRFSRAID/test.sh b/test/TEST-15-BTRFSRAID/test.sh
|
|
Harald Hoyer |
f3160a |
new file mode 100755
|
|
Harald Hoyer |
f3160a |
index 0000000..96ecd2e
|
|
Harald Hoyer |
f3160a |
--- /dev/null
|
|
Harald Hoyer |
f3160a |
+++ b/test/TEST-15-BTRFSRAID/test.sh
|
|
Harald Hoyer |
f3160a |
@@ -0,0 +1,82 @@
|
|
Harald Hoyer |
f3160a |
+#!/bin/bash
|
|
Harald Hoyer |
f3160a |
+TEST_DESCRIPTION="root filesystem on multiple device btrfs"
|
|
Harald Hoyer |
f3160a |
+
|
|
Harald Hoyer |
f3160a |
+KVERSION=${KVERSION-$(uname -r)}
|
|
Harald Hoyer |
f3160a |
+
|
|
Harald Hoyer |
f3160a |
+# Uncomment this to debug failures
|
|
Harald Hoyer |
f3160a |
+#DEBUGFAIL="rd.shell"
|
|
Harald Hoyer |
f3160a |
+DISKIMAGE=/var/tmp/TEST-15-BTRFSRAID-root.img
|
|
Harald Hoyer |
f3160a |
+test_run() {
|
|
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=LABEL=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 $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/null of=$DISKIMAGE bs=1M seek=1024
|
|
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 |
+ (
|
|
Harald Hoyer |
f3160a |
+ initdir=overlay/source
|
|
Harald Hoyer |
f3160a |
+ . $basedir/dracut-functions
|
|
Harald Hoyer |
f3160a |
+ dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
|
|
Harald Hoyer |
f3160a |
+ /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient
|
|
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 |
+ 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 |
+ cp -a /etc/ld.so.conf* $initdir/etc
|
|
Harald Hoyer |
f3160a |
+ sudo ldconfig -r "$initdir"
|
|
Harald Hoyer |
f3160a |
+ )
|
|
Harald Hoyer |
f3160a |
+
|
|
Harald Hoyer |
f3160a |
+ # second, install the files needed to make the root filesystem
|
|
Harald Hoyer |
f3160a |
+ (
|
|
Harald Hoyer |
f3160a |
+ initdir=overlay
|
|
Harald Hoyer |
f3160a |
+ . $basedir/dracut-functions
|
|
Harald Hoyer |
f3160a |
+ dracut_install sfdisk mkfs.btrfs poweroff cp umount
|
|
Harald Hoyer |
f3160a |
+ inst_hook initqueue 01 ./create-root.sh
|
|
Harald Hoyer |
f3160a |
+ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
|
|
Harald Hoyer |
f3160a |
+ )
|
|
Harald Hoyer |
f3160a |
+
|
|
Harald Hoyer |
f3160a |
+ # create an initramfs that will create the target root filesystem.
|
|
Harald Hoyer |
f3160a |
+ # We do it this way so that we do not risk trashing the host mdraid
|
|
Harald Hoyer |
f3160a |
+ # devices, volume groups, encrypted partitions, etc.
|
|
Harald Hoyer |
f3160a |
+ $basedir/dracut -l -i overlay / \
|
|
Harald Hoyer |
f3160a |
+ -m "dash btrfs udev-rules base rootfs-block kernel-modules" \
|
|
Harald Hoyer |
f3160a |
+ -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
|
|
Harald Hoyer |
f3160a |
+ --nomdadmconf \
|
|
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 $DISKIMAGE -m 256M -nographic -net none \
|
|
Harald Hoyer |
f3160a |
+ -kernel "/boot/vmlinuz-$kernel" \
|
|
Harald Hoyer |
f3160a |
+ -append "root=LABEL=root rw 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 $DISKIMAGE || return 1
|
|
Harald Hoyer |
f3160a |
+ (
|
|
Harald Hoyer |
f3160a |
+ initdir=overlay
|
|
Harald Hoyer |
f3160a |
+ . $basedir/dracut-functions
|
|
Harald Hoyer |
f3160a |
+ dracut_install poweroff shutdown
|
|
Harald Hoyer |
f3160a |
+ inst_hook emergency 000 ./hard-off.sh
|
|
Harald Hoyer |
f3160a |
+ inst ./cryptroot-ask /sbin/cryptroot-ask
|
|
Harald Hoyer |
f3160a |
+ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
|
|
Harald Hoyer |
f3160a |
+ )
|
|
Harald Hoyer |
f3160a |
+ sudo $basedir/dracut -l -i overlay / \
|
|
Harald Hoyer |
f3160a |
+ -o "plymouth network" \
|
|
Harald Hoyer |
f3160a |
+ -a "debug" \
|
|
Harald Hoyer |
f3160a |
+ -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
|
|
Harald Hoyer |
f3160a |
+ -f initramfs.testing $KVERSION || return 1
|
|
Harald Hoyer |
f3160a |
+}
|
|
Harald Hoyer |
f3160a |
+
|
|
Harald Hoyer |
f3160a |
+test_cleanup() {
|
|
Harald Hoyer |
f3160a |
+ rm -fr overlay mnt
|
|
Harald Hoyer |
f3160a |
+ rm -f $DISKIMAGE initramfs.makeroot initramfs.testing
|
|
Harald Hoyer |
f3160a |
+}
|
|
Harald Hoyer |
f3160a |
+
|
|
Harald Hoyer |
f3160a |
+. $testdir/test-functions
|