diff options
author | Harald Hoyer <harald@redhat.com> | 2011-11-16 14:04:27 +0100 |
---|---|---|
committer | Harald Hoyer <harald@redhat.com> | 2011-11-16 14:04:27 +0100 |
commit | 0be1785aea176779557a1150c3591f9ebd1e7446 (patch) | |
tree | cfb236157ce2ca289e06ac2ed81cb0907c32a5eb | |
parent | bf7487ab18a0b19af7c77e970ff0792b70fbdee6 (diff) | |
download | dracut-0be1785aea176779557a1150c3591f9ebd1e7446.tar.gz dracut-0be1785aea176779557a1150c3591f9ebd1e7446.tar.bz2 dracut-0be1785aea176779557a1150c3591f9ebd1e7446.zip |
test: introduce $TESTDIR tmpdir
to keep the git source tree clean, test files are now created in a
$TESTDIR created with mktemp.
-rwxr-xr-x | test/TEST-01-BASIC/test.sh | 100 | ||||
-rwxr-xr-x | test/TEST-10-RAID/test.sh | 35 | ||||
-rwxr-xr-x | test/TEST-11-LVM/test.sh | 35 | ||||
-rwxr-xr-x | test/TEST-12-RAID-DEG/test.sh | 47 | ||||
-rwxr-xr-x | test/TEST-13-ENC-RAID-LVM/test.sh | 67 | ||||
-rwxr-xr-x | test/TEST-14-IMSM/test.sh | 57 | ||||
-rwxr-xr-x | test/TEST-15-BTRFSRAID/test.sh | 40 | ||||
-rw-r--r-- | test/TEST-16-DMSQUASH/create.py | 14 | ||||
-rwxr-xr-x | test/TEST-16-DMSQUASH/test.sh | 33 | ||||
-rwxr-xr-x | test/TEST-20-NFS/test.sh | 82 | ||||
-rwxr-xr-x | test/TEST-30-ISCSI/test.sh | 111 | ||||
-rwxr-xr-x | test/TEST-40-NBD/test.sh | 99 | ||||
-rwxr-xr-x | test/TEST-50-MULTINIC/test.sh | 57 | ||||
-rw-r--r-- | test/test-functions | 10 |
14 files changed, 438 insertions, 349 deletions
diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh index 95724277..53933694 100755 --- a/test/TEST-01-BASIC/test.sh +++ b/test/TEST-01-BASIC/test.sh @@ -7,82 +7,84 @@ KVERSION=${KVERSION-$(uname -r)} #DEBUGFAIL="rd.shell rd.break" test_run() { - $testdir/run-qemu -hda root.ext3 -m 256M -nographic \ + $testdir/run-qemu \ + -hda $TESTDIR/root.ext3 \ + -m 256M -nographic \ -net none -kernel /boot/vmlinuz-$KVERSION \ -append "root=LABEL=dracut 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.ext3 || return 1 + -initrd $TESTDIR/initramfs.testing + grep -m 1 -q dracut-root-block-success $TESTDIR/root.ext3 || return 1 } test_setup() { - - if [ ! -e root.ext3 ]; then - + rm -f $TESTDIR/root.ext3 # Create the blank file to use as a root filesystem - dd if=/dev/zero of=root.ext3 bs=1M count=40 + dd if=/dev/null of=$TESTDIR/root.ext3 bs=1M seek=40 - kernel=$KVERSION + kernel=$KVERSION # Create what will eventually be our root filesystem onto an overlay - ( - initdir=overlay/source - . $basedir/dracut-functions - dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ - /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient \ - umount strace less - inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script" - inst "$basedir/modules.d/40network/ifup" "/sbin/ifup" - dracut_install grep - inst ./test-init /sbin/init - find_binary plymouth >/dev/null && dracut_install plymouth - (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) - cp -a /etc/ld.so.conf* $initdir/etc - sudo ldconfig -r "$initdir" - ) - + ( + initdir=$TESTDIR/overlay/source + . $basedir/dracut-functions + dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ + /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient \ + umount strace less + inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script" + inst "$basedir/modules.d/40network/ifup" "/sbin/ifup" + dracut_install grep + inst ./test-init /sbin/init + find_binary plymouth >/dev/null && dracut_install plymouth + (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) + cp -a /etc/ld.so.conf* $initdir/etc + sudo ldconfig -r "$initdir" + ) + # second, install the files needed to make the root filesystem - ( - initdir=overlay - . $basedir/dracut-functions - dracut_install sfdisk mkfs.ext3 poweroff cp umount - inst_hook initqueue 01 ./create-root.sh - inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules - ) - + ( + initdir=$TESTDIR/overlay + . $basedir/dracut-functions + dracut_install sfdisk mkfs.ext3 poweroff cp umount + inst_hook initqueue 01 ./create-root.sh + inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules + ) + # 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. - $basedir/dracut -l -i overlay / \ - -m "dash udev-rules base rootfs-block kernel-modules" \ - -d "piix ide-gd_mod ata_piix ext3 sd_mod" \ - --nomdadmconf \ - -f initramfs.makeroot $KVERSION || return 1 - rm -rf overlay + $basedir/dracut -l -i $TESTDIR/overlay / \ + -m "dash udev-rules base rootfs-block kernel-modules" \ + -d "piix ide-gd_mod ata_piix ext3 sd_mod" \ + --nomdadmconf \ + -f $TESTDIR/initramfs.makeroot $KVERSION || return 1 + rm -rf overlay # Invoke KVM and/or QEMU to actually create the target filesystem. - $testdir/run-qemu -hda root.ext3 -m 256M -nographic -net none \ - -kernel "/boot/vmlinuz-$kernel" \ - -append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \ - -initrd initramfs.makeroot || return 1 - grep -m 1 -q dracut-root-block-created root.ext3 || return 1 - fi + + $testdir/run-qemu \ + -hda $TESTDIR/root.ext3 \ + -m 256M -nographic -net none \ + -kernel "/boot/vmlinuz-$kernel" \ + -append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \ + -initrd $TESTDIR/initramfs.makeroot || return 1 + grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1 + ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install poweroff shutdown inst_hook emergency 000 ./hard-off.sh inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ) - sudo $basedir/dracut -l -i overlay / \ + sudo $basedir/dracut -l -i $TESTDIR/overlay / \ -a "debug" \ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \ - -f initramfs.testing $KVERSION || return 1 + -f $TESTDIR/initramfs.testing $KVERSION || return 1 # -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm" } test_cleanup() { - rm -fr overlay mnt - rm -f root.ext3 initramfs.makeroot initramfs.testing + return 0 } . $testdir/test-functions diff --git a/test/TEST-10-RAID/test.sh b/test/TEST-10-RAID/test.sh index fe95437d..90758d82 100755 --- a/test/TEST-10-RAID/test.sh +++ b/test/TEST-10-RAID/test.sh @@ -5,23 +5,26 @@ KVERSION=${KVERSION-$(uname -r)} # Uncomment this to debug failures #DEBUGFAIL="rd.shell" -DISKIMAGE=/var/tmp/TEST-10-RAID-root.img +DISKIMAGE=$TESTDIR/TEST-10-RAID-root.img test_run() { - $testdir/run-qemu -hda $DISKIMAGE -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 + -initrd $TESTDIR/initramfs.testing grep -m 1 -q dracut-root-block-success $DISKIMAGE || return 1 } test_setup() { # Create the blank file to use as a root filesystem + rm -f $DISKIMAGE dd if=/dev/null of=$DISKIMAGE bs=1M seek=40 kernel=$KVERSION # Create what will eventually be our root filesystem onto an overlay ( - initdir=overlay/source + initdir=$TESTDIR/overlay/source . $basedir/dracut-functions dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient @@ -38,7 +41,7 @@ test_setup() { # second, install the files needed to make the root filesystem ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install sfdisk mke2fs poweroff cp umount inst_hook initqueue 01 ./create-root.sh @@ -48,36 +51,38 @@ 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. - $basedir/dracut -l -i overlay / \ + $basedir/dracut -l -i $TESTDIR/overlay / \ -m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \ --nomdadmconf \ - -f initramfs.makeroot $KVERSION || return 1 - rm -rf overlay + -f $TESTDIR/initramfs.makeroot $KVERSION || return 1 + rm -rf $TESTDIR/overlay # Invoke KVM and/or QEMU to actually create the target filesystem. - $testdir/run-qemu -hda $DISKIMAGE -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 + -initrd $TESTDIR/initramfs.makeroot || return 1 grep -m 1 -q dracut-root-block-created $DISKIMAGE || return 1 + ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install poweroff shutdown inst_hook emergency 000 ./hard-off.sh inst ./cryptroot-ask /sbin/cryptroot-ask inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ) - sudo $basedir/dracut -l -i overlay / \ + sudo $basedir/dracut -l -i $TESTDIR/overlay / \ -o "plymouth network" \ -a "debug" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \ - -f initramfs.testing $KVERSION || return 1 + -f $TESTDIR/initramfs.testing $KVERSION || return 1 } test_cleanup() { - rm -fr overlay mnt - rm -f $DISKIMAGE initramfs.makeroot initramfs.testing + return 0 } . $testdir/test-functions diff --git a/test/TEST-11-LVM/test.sh b/test/TEST-11-LVM/test.sh index 813b0728..85af4b29 100755 --- a/test/TEST-11-LVM/test.sh +++ b/test/TEST-11-LVM/test.sh @@ -7,21 +7,23 @@ KVERSION=${KVERSION-$(uname -r)} #DEBUGFAIL="rd.break rd.shell" test_run() { - $testdir/run-qemu -hda root.ext2 -m 256M -nographic \ + $testdir/run-qemu \ + -hda $TESTDIR/root.ext2 \ + -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 + -initrd $TESTDIR/initramfs.testing + grep -m 1 -q dracut-root-block-success $TESTDIR/root.ext2 || 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=$TESTDIR/root.ext2 bs=1M seek=40 kernel=$KVERSION # Create what will eventually be our root filesystem onto an overlay ( - initdir=overlay/source + initdir=$TESTDIR/overlay/source . $basedir/dracut-functions dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient @@ -38,7 +40,7 @@ test_setup() { # second, install the files needed to make the root filesystem ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install sfdisk mke2fs poweroff cp umount inst_hook initqueue 01 ./create-root.sh @@ -48,34 +50,33 @@ 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. - $basedir/dracut -l -i overlay / \ + $basedir/dracut -l -i $TESTDIR/overlay / \ -m "dash lvm mdraid udev-rules base rootfs-block kernel-modules" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \ - -f initramfs.makeroot $KVERSION || return 1 - rm -rf overlay + -f $TESTDIR/initramfs.makeroot $KVERSION || return 1 + rm -rf $TESTDIR/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 $TESTDIR/root.ext2 -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 + -initrd $TESTDIR/initramfs.makeroot || return 1 + grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1 ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install poweroff shutdown inst_hook emergency 000 ./hard-off.sh inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ) - sudo $basedir/dracut -l -i overlay / \ + sudo $basedir/dracut -l -i $TESTDIR/overlay / \ -o "plymouth network" \ -a "debug" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \ - -f initramfs.testing $KVERSION || return 1 + -f $TESTDIR/initramfs.testing $KVERSION || return 1 } test_cleanup() { - rm -fr overlay mnt - rm -f root.ext2 initramfs.makeroot initramfs.testing + return 0 } . $testdir/test-functions diff --git a/test/TEST-12-RAID-DEG/test.sh b/test/TEST-12-RAID-DEG/test.sh index 37fd67ca..bc4b2f6b 100755 --- a/test/TEST-12-RAID-DEG/test.sh +++ b/test/TEST-12-RAID-DEG/test.sh @@ -8,22 +8,23 @@ KVERSION=${KVERSION-$(uname -r)} client_run() { echo "CLIENT TEST START: $@" - $testdir/run-qemu -hda root.ext2 -m 256M -nographic \ + $testdir/run-qemu \ + -hda $TESTDIR/root.ext2 -m 256M -nographic \ -net none -kernel /boot/vmlinuz-$KVERSION \ -append "$@ root=LABEL=root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL " \ - -initrd initramfs.testing - if ! grep -m 1 -q dracut-root-block-success root.ext2; then + -initrd $TESTDIR/initramfs.testing + if ! grep -m 1 -q dracut-root-block-success $TESTDIR/root.ext2; then echo "CLIENT TEST END: $@ [FAIL]" return 1; fi - sed -i -e 's#dracut-root-block-success#dracut-root-block-xxxxxxx#' root.ext2 + sed -i -e 's#dracut-root-block-success#dracut-root-block-xxxxxxx#' $TESTDIR/root.ext2 echo "CLIENT TEST END: $@ [OK]" return 0 } test_run() { - eval $(grep --binary-files=text -m 1 MD_UUID root.ext2) + eval $(grep --binary-files=text -m 1 MD_UUID $TESTDIR/root.ext2) echo "MD_UUID=$MD_UUID" client_run || return 1 @@ -51,12 +52,13 @@ test_run() { test_setup() { # Create the blank file to use as a root filesystem - dd if=/dev/zero of=root.ext2 bs=1M count=40 + rm -f $TESTDIR/root.ext2 + dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=40 kernel=$KVERSION # Create what will eventually be our root filesystem onto an overlay ( - initdir=overlay/source + initdir=$TESTDIR/overlay/source . $basedir/dracut-functions dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient @@ -72,7 +74,7 @@ test_setup() { # second, install the files needed to make the root filesystem ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install sfdisk mke2fs poweroff cp umount dd grep inst_hook initqueue 01 ./create-root.sh @@ -82,38 +84,39 @@ 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. - $basedir/dracut -l -i overlay / \ + $basedir/dracut -l -i $TESTDIR/overlay / \ -m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \ - -f initramfs.makeroot $KVERSION || return 1 - rm -rf overlay + -f $TESTDIR/initramfs.makeroot $KVERSION || return 1 + rm -rf $TESTDIR/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 $TESTDIR/root.ext2 \ + -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 - eval $(grep --binary-files=text -m 1 MD_UUID root.ext2) + -initrd $TESTDIR/initramfs.makeroot || return 1 + grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1 + eval $(grep --binary-files=text -m 1 MD_UUID $TESTDIR/root.ext2) ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install poweroff shutdown inst_hook emergency 000 ./hard-off.sh inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules inst ./cryptroot-ask /sbin/cryptroot-ask - mkdir -p overlay/etc - echo "ARRAY /dev/md0 level=raid5 num-devices=3 UUID=$MD_UUID" > overlay/etc/mdadm.conf + mkdir -p $initdir/etc + echo "ARRAY /dev/md0 level=raid5 num-devices=3 UUID=$MD_UUID" > $initdir/etc/mdadm.conf ) - sudo $basedir/dracut -l -i overlay / \ + sudo $basedir/dracut -l -i $TESTDIR/overlay / \ -o "plymouth network" \ -a "debug" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \ - -f initramfs.testing $KVERSION || return 1 + -f $TESTDIR/initramfs.testing $KVERSION || return 1 } test_cleanup() { - rm -fr overlay mnt - rm -f root.ext2 initramfs.makeroot initramfs.testing + return 0 } . $testdir/test-functions diff --git a/test/TEST-13-ENC-RAID-LVM/test.sh b/test/TEST-13-ENC-RAID-LVM/test.sh index c250fad8..723a1201 100755 --- a/test/TEST-13-ENC-RAID-LVM/test.sh +++ b/test/TEST-13-ENC-RAID-LVM/test.sh @@ -7,36 +7,45 @@ KVERSION=${KVERSION-$(uname -r)} #DEBUGFAIL="rd.shell" # udev.log-priority=debug test_run() { - LUKSARGS=$(cat luks.txt) + LUKSARGS=$(cat $TESTDIR/luks.txt) - dd if=/dev/zero of=check-success.img bs=1M count=1 + dd if=/dev/zero of=$TESTDIR/check-success.img bs=1M count=1 echo "CLIENT TEST START: $LUKSARGS" - $testdir/run-qemu -hda root.ext2 -hdb check-success.img -m 256M -nographic \ + $testdir/run-qemu \ + -hda $TESTDIR/root.ext2 \ + -hdb $TESTDIR/check-success.img \ + -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 $LUKSARGS $DEBUGFAIL" \ - -initrd initramfs.testing - grep -m 1 -q dracut-root-block-success check-success.img || return 1 + -initrd $TESTDIR/initramfs.testing + grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1 echo "CLIENT TEST END: [OK]" - dd if=/dev/zero of=check-success.img bs=1M count=1 + dd if=/dev/zero of=$TESTDIR/check-success.img bs=1M count=1 echo "CLIENT TEST START: Any LUKS" - $testdir/run-qemu -hda root.ext2 -hdb check-success.img -m 256M -nographic \ + $testdir/run-qemu \ + -hda $TESTDIR/root.ext2 \ + -hdb $TESTDIR/check-success.img \ + -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 check-success.img || return 1 + -initrd $TESTDIR/initramfs.testing + grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1 echo "CLIENT TEST END: [OK]" - dd if=/dev/zero of=check-success.img bs=1M count=1 + dd if=/dev/zero of=$TESTDIR/check-success.img bs=1M count=1 echo "CLIENT TEST START: Wrong LUKS UUID" - $testdir/run-qemu -hda root.ext2 -hdb check-success.img -m 256M -nographic \ + $testdir/run-qemu \ + -hda $TESTDIR/root.ext2 \ + -hdb $TESTDIR/check-success.img \ + -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 rd.luks.uuid=failme" \ - -initrd initramfs.testing - grep -m 1 -q dracut-root-block-success check-success.img && return 1 + -initrd $TESTDIR/initramfs.testing + grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img && return 1 echo "CLIENT TEST END: [OK]" return 0 @@ -44,12 +53,13 @@ test_run() { test_setup() { # Create the blank file to use as a root filesystem - dd if=/dev/zero of=root.ext2 bs=1M count=80 + rm -f $TESTDIR/root.ext2 + dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=80 kernel=$KVERSION # Create what will eventually be our root filesystem onto an overlay ( - initdir=overlay/source + initdir=$TESTDIR/overlay/source . $basedir/dracut-functions dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient @@ -65,7 +75,7 @@ test_setup() { # second, install the files needed to make the root filesystem ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install sfdisk mke2fs poweroff cp umount grep inst_hook initqueue 01 ./create-root.sh @@ -75,42 +85,41 @@ 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. - $basedir/dracut -l -i overlay / \ + $basedir/dracut -l -i $TESTDIR/overlay / \ -m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \ - -f initramfs.makeroot $KVERSION || return 1 - rm -rf overlay + -f $TESTDIR/initramfs.makeroot $KVERSION || return 1 + rm -rf $TESTDIR/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 $TESTDIR/root.ext2 -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 - cryptoUUIDS=$(grep --binary-files=text -m 3 ID_FS_UUID root.ext2) + -initrd $TESTDIR/initramfs.makeroot || return 1 + grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1 + cryptoUUIDS=$(grep --binary-files=text -m 3 ID_FS_UUID $TESTDIR/root.ext2) for uuid in $cryptoUUIDS; do eval $uuid printf ' rd.luks.uuid=luks-%s ' $ID_FS_UUID - done > luks.txt + done > $TESTDIR/luks.txt ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install poweroff shutdown inst_hook emergency 000 ./hard-off.sh inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules inst ./cryptroot-ask /sbin/cryptroot-ask ) - sudo $basedir/dracut -l -i overlay / \ + sudo $basedir/dracut -l -i $TESTDIR/overlay / \ -o "plymouth network" \ -a "debug" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \ - -f initramfs.testing $KVERSION || return 1 + -f $TESTDIR/initramfs.testing $KVERSION || return 1 } test_cleanup() { - rm -fr overlay mnt - rm -f root.ext2 initramfs.makeroot initramfs.testing luks.txt check-success.img + return 0 } . $testdir/test-functions diff --git a/test/TEST-14-IMSM/test.sh b/test/TEST-14-IMSM/test.sh index 70f23e85..317780f3 100755 --- a/test/TEST-14-IMSM/test.sh +++ b/test/TEST-14-IMSM/test.sh @@ -9,21 +9,28 @@ KVERSION=${KVERSION-$(uname -r)} client_run() { echo "CLIENT TEST START: $@" - $testdir/run-qemu -hda root.ext2 -hdb disk1 -hdc disk2 -m 256M -nographic \ + $testdir/run-qemu \ + -hda $TESTDIR/root.ext2 \ + -hdb $TESTDIR/disk1 \ + -hdc $TESTDIR/disk2 \ + -m 256M -nographic \ -net none -kernel /boot/vmlinuz-$KVERSION \ -append "$@ root=LABEL=root rw quiet rd.retry=5 rd.debug console=ttyS0,115200n81 selinux=0 rd.info $DEBUGFAIL" \ - -initrd initramfs.testing - if ! grep -m 1 -q dracut-root-block-success root.ext2; then + -initrd $TESTDIR/initramfs.testing + if ! grep -m 1 -q dracut-root-block-success $TESTDIR/root.ext2; then echo "CLIENT TEST END: $@ [FAIL]" return 1; fi - sed -i -e 's#dracut-root-block-success#dracut-root-block-xxxxxxx#' root.ext2 + sed -i -e 's#dracut-root-block-success#dracut-root-block-xxxxxxx#' $TESTDIR/root.ext2 echo "CLIENT TEST END: $@ [OK]" return 0 } test_run() { + echo "IMSM test does not work anymore" + return 1 + client_run rd.md.imsm || return 1 client_run || return 1 client_run rd.dm=0 || return 1 @@ -37,15 +44,21 @@ test_run() { } test_setup() { + echo "IMSM test does not work anymore" + return 1 + # Create the blank file to use as a root filesystem - dd if=/dev/zero of=root.ext2 bs=1M count=1 - dd if=/dev/zero of=disk1 bs=1M count=80 - dd if=/dev/zero of=disk2 bs=1M count=80 + rm -f $TESTDIR/root.ext2 + rm -f $TESTDIR/disk1 + rm -f $TESTDIR/disk2 + dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=1 + dd if=/dev/null of=$TESTDIR/disk1 bs=1M seek=80 + dd if=/dev/null of=$TESTDIR/disk2 bs=1M seek=80 kernel=$KVERSION # Create what will eventually be our root filesystem onto an overlay ( - initdir=overlay/source + initdir=$TESTDIR/overlay/source . $basedir/dracut-functions dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient @@ -62,7 +75,7 @@ test_setup() { # second, install the files needed to make the root filesystem ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install sfdisk mke2fs poweroff cp umount inst_hook initqueue 01 ./create-root.sh @@ -72,35 +85,37 @@ 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. - $basedir/dracut -l -i overlay / \ + $basedir/dracut -l -i $TESTDIR/overlay / \ -m "dash lvm mdraid dmraid udev-rules base rootfs-block kernel-modules" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod dm-multipath dm-crypt dm-round-robin faulty linear multipath raid0 raid10 raid1 raid456" \ - -f initramfs.makeroot $KVERSION || return 1 - rm -rf overlay + -f $TESTDIR/initramfs.makeroot $KVERSION || return 1 + rm -rf $TESTDIR/overlay # Invoke KVM and/or QEMU to actually create the target filesystem. - $testdir/run-qemu -hda root.ext2 -hdb disk1 -hdc disk2 -m 256M -nographic -net none \ + $testdir/run-qemu \ + -hda $TESTDIR/root.ext2 \ + -hdb $TESTDIR/disk1 \ + -hdc $TESTDIR/disk2 \ + -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 + -initrd $TESTDIR/initramfs.makeroot || return 1 + grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1 ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install poweroff shutdown inst_hook emergency 000 ./hard-off.sh inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ) - sudo $basedir/dracut -l -i overlay / \ + sudo $basedir/dracut -l -i $TESTDIR/overlay / \ -o "plymouth network" \ -a "debug" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \ - -f initramfs.testing $KVERSION || return 1 + -f $TESTDIR/initramfs.testing $KVERSION || return 1 } test_cleanup() { - rm -fr overlay mnt - rm -f root.ext2 initramfs.makeroot initramfs.testing - rm -f disk1 disk2 + return 0 } . $testdir/test-functions diff --git a/test/TEST-15-BTRFSRAID/test.sh b/test/TEST-15-BTRFSRAID/test.sh index 96ecd2ed..bacdb4a1 100755 --- a/test/TEST-15-BTRFSRAID/test.sh +++ b/test/TEST-15-BTRFSRAID/test.sh @@ -5,23 +5,26 @@ KVERSION=${KVERSION-$(uname -r)} # Uncomment this to debug failures #DEBUGFAIL="rd.shell" -DISKIMAGE=/var/tmp/TEST-15-BTRFSRAID-root.img +DISKIMAGE=$TESTDIR/TEST-15-BTRFSRAID-root.img test_run() { - $testdir/run-qemu -hda $DISKIMAGE -m 256M -nographic \ + $testdir/run-qemu \ + -hda $DISKIMAGE \ + -m 256M -nographic \ -net none -kernel /boot/vmlinuz-$KVERSION \ -append "root=LABEL=root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \ - -initrd initramfs.testing + -initrd $TESTDIR/initramfs.testing grep -m 1 -q dracut-root-block-success $DISKIMAGE || return 1 } test_setup() { # Create the blank file to use as a root filesystem + rm -f $DISKIMAGE dd if=/dev/null of=$DISKIMAGE bs=1M seek=1024 kernel=$KVERSION # Create what will eventually be our root filesystem onto an overlay ( - initdir=overlay/source + initdir=$TESTDIR/overlay/source . $basedir/dracut-functions dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient @@ -37,7 +40,7 @@ test_setup() { # second, install the files needed to make the root filesystem ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install sfdisk mkfs.btrfs poweroff cp umount inst_hook initqueue 01 ./create-root.sh @@ -47,36 +50,41 @@ 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. - $basedir/dracut -l -i overlay / \ + $basedir/dracut -l -i $TESTDIR/overlay / \ -m "dash btrfs udev-rules base rootfs-block kernel-modules" \ -d "piix ide-gd_mod ata_piix btrfs sd_mod" \ --nomdadmconf \ - -f initramfs.makeroot $KVERSION || return 1 - rm -rf overlay + -f $TESTDIR/initramfs.makeroot $KVERSION || return 1 + + rm -rf $TESTDIR/overlay + # Invoke KVM and/or QEMU to actually create the target filesystem. - $testdir/run-qemu -hda $DISKIMAGE -m 256M -nographic -net none \ + $testdir/run-qemu \ + -hda $DISKIMAGE \ + -m 256M -nographic -net none \ -kernel "/boot/vmlinuz-$kernel" \ -append "root=LABEL=root rw quiet console=ttyS0,115200n81 selinux=0" \ - -initrd initramfs.makeroot || return 1 + -initrd $TESTDIR/initramfs.makeroot || return 1 + grep -m 1 -q dracut-root-block-created $DISKIMAGE || return 1 - ( - initdir=overlay + + ( + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install poweroff shutdown inst_hook emergency 000 ./hard-off.sh inst ./cryptroot-ask /sbin/cryptroot-ask inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ) - sudo $basedir/dracut -l -i overlay / \ + sudo $basedir/dracut -l -i $TESTDIR/overlay / \ -o "plymouth network" \ -a "debug" \ -d "piix ide-gd_mod ata_piix btrfs sd_mod" \ - -f initramfs.testing $KVERSION || return 1 + -f $TESTDIR/initramfs.testing $KVERSION || return 1 } test_cleanup() { - rm -fr overlay mnt - rm -f $DISKIMAGE initramfs.makeroot initramfs.testing + return 0 } . $testdir/test-functions diff --git a/test/TEST-16-DMSQUASH/create.py b/test/TEST-16-DMSQUASH/create.py index 15d29ffd..53a62665 100644 --- a/test/TEST-16-DMSQUASH/create.py +++ b/test/TEST-16-DMSQUASH/create.py @@ -30,8 +30,18 @@ import imgcreate from imgcreate.fs import makedirs class myLiveImageCreator(imgcreate.x86LiveImageCreator): + def __init__(self, ks, name, fslabel=None, releasever=None, tmpdir="/tmp", + title="Linux", product="Linux"): + + imgcreate.x86LiveImageCreator.__init__(self, ks, name, + fslabel=fslabel, + releasever=releasever, + tmpdir=tmpdir) + + #self._outdir=os.getenv("TESTDIR", ".") + def install(self, repo_urls = {}): - copy_tree("root-source", self._instroot) + copy_tree(os.environ.get("TESTDIR", ".") + "/root-source", self._instroot) def configure(self): self._create_bootconfig() @@ -173,7 +183,7 @@ def main(): print "----------------------------------" creator.launch_shell() creator.unmount() - creator.package() + creator.package(os.environ.get("TESTDIR", ".")) except imgcreate.CreatorError, e: logging.error(u"Error creating Live CD : %s" % e) return 1 diff --git a/test/TEST-16-DMSQUASH/test.sh b/test/TEST-16-DMSQUASH/test.sh index 5d8075cf..5a98fb70 100755 --- a/test/TEST-16-DMSQUASH/test.sh +++ b/test/TEST-16-DMSQUASH/test.sh @@ -7,35 +7,39 @@ KVERSION=${KVERSION-$(uname -r)} #DEBUGFAIL="rd.shell rd.break" test_run() { - $testdir/run-qemu -boot order=d -cdrom livecd.iso -hda root.img -m 256M -nographic \ + $testdir/run-qemu \ + -boot order=d \ + -cdrom $TESTDIR/livecd.iso \ + -hda $TESTDIR/root.img \ + -m 256M -nographic \ -net none -kernel /boot/vmlinuz-$KVERSION \ -append "root=live:CDLABEL=LiveCD live 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.img || return 1 + -initrd $TESTDIR/initramfs.testing + grep -m 1 -q dracut-root-block-success $TESTDIR/root.img || return 1 } test_setup() { - mkdir -p overlay + mkdir -p $TESTDIR/overlay ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install poweroff shutdown inst_hook emergency 000 ./hard-off.sh inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ) - dd if=/dev/null of=root.img seek=100 + dd if=/dev/zero of=$TESTDIR/root.img count=100 - sudo $basedir/dracut -l -i overlay / \ - -a "debug" \ + sudo $basedir/dracut -l -i $TESTDIR/overlay / \ + -a "debug dmsquash-live" \ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \ - -f initramfs.testing $KVERSION || return 1 + -f $TESTDIR/initramfs.testing $KVERSION || return 1 - mkdir -p root-source + mkdir -p $TESTDIR/root-source kernel=$KVERSION # Create what will eventually be our root filesystem onto an overlay ( - initdir=root-source + initdir=$TESTDIR/root-source . $basedir/dracut-functions dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient \ @@ -47,7 +51,7 @@ test_setup() { inst_simple "$f" done inst ./test-init /sbin/init - inst ./initramfs.testing "/boot/initramfs-$KVERSION.img" + inst $TESTDIR/initramfs.testing "/boot/initramfs-$KVERSION.img" inst /boot/vmlinuz-$KVERSION find_binary plymouth >/dev/null && dracut_install plymouth (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) @@ -55,12 +59,11 @@ test_setup() { sudo ldconfig -r "$initdir" ) python create.py -d -c livecd-fedora-minimal.ks - exit 0 + return 0 } test_cleanup() { - rm -fr overlay root-source - rm -f root.img initramfs.makeroot initramfs.testing livecd.iso + return 0 } . $testdir/test-functions diff --git a/test/TEST-20-NFS/test.sh b/test/TEST-20-NFS/test.sh index 60f4b97c..6f906c4b 100755 --- a/test/TEST-20-NFS/test.sh +++ b/test/TEST-20-NFS/test.sh @@ -12,14 +12,16 @@ run_server() { # Start server first echo "NFS TEST SETUP: Starting DHCP/NFS server" - $testdir/run-qemu -hda server.ext2 -m 256M -nographic \ + $testdir/run-qemu \ + -hda $TESTDIR/server.ext2 -m 256M -nographic \ -net nic,macaddr=52:54:00:12:34:56,model=e1000 \ - -net socket,listen=127.0.0.1:12345 \ + -net socket,listen=127.0.0.1:12320 \ -serial $SERIAL \ -kernel /boot/vmlinuz-$KVERSION \ -append "root=/dev/sda rw quiet console=ttyS0,115200n81 selinux=0" \ - -initrd initramfs.server -pidfile server.pid -daemonize || return 1 - sudo chmod 644 server.pid || return 1 + -initrd $TESTDIR/initramfs.server \ + -pidfile $TESTDIR/server.pid -daemonize || return 1 + sudo chmod 644 $TESTDIR/server.pid || return 1 # Cleanup the terminal if we have one tty -s && stty sane @@ -39,25 +41,27 @@ client_test() { echo "CLIENT TEST START: $test_name" # Need this so kvm-qemu will boot (needs non-/dev/zero local disk) - if ! dd if=/dev/zero of=client.img bs=1M count=1; then + if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1; then echo "Unable to make client sda image" 1>&2 return 1 fi - $testdir/run-qemu -hda client.img -m 256M -nographic \ + $testdir/run-qemu \ + -hda $TESTDIR/client.img \ + -m 256M -nographic \ -net nic,macaddr=$mac,model=e1000 \ - -net socket,connect=127.0.0.1:12345 \ + -net socket,connect=127.0.0.1:12320 \ -kernel /boot/vmlinuz-$KVERSION \ -append "$cmdline $DEBUGFAIL rd.debug rd.retry=10 rd.info quiet ro console=ttyS0,115200n81 selinux=0" \ - -initrd initramfs.testing + -initrd $TESTDIR/initramfs.testing - if [[ $? -ne 0 ]] || ! grep -m 1 -q nfs-OK client.img; then + if [[ $? -ne 0 ]] || ! grep -m 1 -q nfs-OK $TESTDIR/client.img; then echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]" return 1 fi # nfsinfo=( server:/path nfs{,4} options ) - nfsinfo=($(awk '{print $2, $3, $4; exit}' client.img)) + nfsinfo=($(awk '{print $2, $3, $4; exit}' $TESTDIR/client.img)) if [[ "${nfsinfo[0]%%:*}" != "$server" ]]; then echo "CLIENT TEST INFO: got server: ${nfsinfo[0]%%:*}" @@ -72,7 +76,7 @@ client_test() { expected=0 check_opt=${check_opt:1} fi - + opts=${nfsinfo[2]}, while [[ $opts ]]; do if [[ ${opts%%,*} = $check_opt ]]; then @@ -148,6 +152,8 @@ test_nfsv3() { client_test "NFSv3 root=dhcp DHCP proto:IP:path,options" \ 52:54:00:12:34:07 "root=dhcp" 192.168.50.3 wsize=4096 || return 1 + + return 0 } test_nfsv4() { @@ -167,12 +173,14 @@ test_nfsv4() { client_test "NFSv4 root=dhcp DHCP proto:IP:path,options" \ 52:54:00:12:34:87 "root=dhcp" 192.168.50.3 wsize=4096 || return 1 + + return 0 } test_run() { if [[ -s server.pid ]]; then - sudo kill -TERM $(cat server.pid) - rm -f server.pid + sudo kill -TERM $(cat $TESTDIR/server.pid) + rm -f $TESTDIR/server.pid fi if ! run_server; then @@ -185,9 +193,9 @@ test_run() { ret=$? - if [[ -s server.pid ]]; then - sudo kill -TERM $(cat server.pid) - rm -f server.pid + if [[ -s $TESTDIR/server.pid ]]; then + sudo kill -TERM $(cat $TESTDIR/server.pid) + rm -f $TESTDIR/server.pid fi return $ret @@ -195,14 +203,14 @@ test_run() { test_setup() { # Make server root - dd if=/dev/zero of=server.ext2 bs=1M count=60 - mke2fs -F server.ext2 - mkdir mnt - sudo mount -o loop server.ext2 mnt + dd if=/dev/null of=$TESTDIR/server.ext2 bs=1M seek=60 + mke2fs -F $TESTDIR/server.ext2 + mkdir $TESTDIR/mnt + sudo mount -o loop $TESTDIR/server.ext2 $TESTDIR/mnt kernel=$KVERSION ( - initdir=mnt + initdir=$TESTDIR/mnt . $basedir/dracut-functions dracut_install sh ls shutdown poweroff stty cat ps ln ip \ /lib/terminfo/l/linux dmesg mkdir cp ping exportfs \ @@ -247,7 +255,7 @@ test_setup() { ) # Make client root inside server root - initdir=mnt/nfs/client + initdir=$TESTDIR/mnt/nfs/client mkdir -p $initdir ( @@ -272,17 +280,17 @@ test_setup() { sudo ldconfig -r "$initdir" ) - mkdir -p mnt/nfs/nfs3-5 - mkdir -p mnt/nfs/ip/192.168.50.101 - mkdir -p mnt/nfs/tftpboot/nfs4-5 + mkdir -p $TESTDIR/mnt/nfs/nfs3-5 + mkdir -p $TESTDIR/mnt/nfs/ip/192.168.50.101 + mkdir -p $TESTDIR/mnt/nfs/tftpboot/nfs4-5 - sudo umount mnt - rm -fr mnt + sudo umount $TESTDIR/mnt + rm -fr $TESTDIR/mnt # Make an overlay with needed tools for the test harness ( - initdir=overlay - mkdir overlay + initdir=$TESTDIR/overlay + mkdir $TESTDIR/overlay . $basedir/dracut-functions dracut_install poweroff shutdown inst_hook emergency 000 ./hard-off.sh @@ -290,26 +298,24 @@ test_setup() { ) # Make server's dracut image - $basedir/dracut -l -i overlay / \ + $basedir/dracut -l -i $TESTDIR/overlay / \ -m "dash udev-rules base rootfs-block debug kernel-modules" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod e1000" \ - -f initramfs.server $KVERSION || return 1 + -f $TESTDIR/initramfs.server $KVERSION || return 1 # Make client's dracut image - $basedir/dracut -l -i overlay / \ + $basedir/dracut -l -i $TESTDIR/overlay / \ -o "plymouth" \ -a "debug" \ -d "piix ide-gd_mod ata_piix sd_mod e1000 nfs sunrpc" \ - -f initramfs.testing $KVERSION || return 1 + -f $TESTDIR/initramfs.testing $KVERSION || return 1 } test_cleanup() { - if [[ -s server.pid ]]; then - sudo kill -TERM $(cat server.pid) - rm -f server.pid + if [[ -s $TESTDIR/server.pid ]]; then + sudo kill -TERM $(cat $TESTDIR/server.pid) + rm -f $TESTDIR/server.pid fi - rm -rf mnt overlay - rm -f server.ext2 client.img initramfs.server initramfs.testing } . $testdir/test-functions diff --git a/test/TEST-30-ISCSI/test.sh b/test/TEST-30-ISCSI/test.sh index 5713942f..ee125c4b 100755 --- a/test/TEST-30-ISCSI/test.sh +++ b/test/TEST-30-ISCSI/test.sh @@ -11,15 +11,20 @@ run_server() { # Start server first echo "iSCSI TEST SETUP: Starting DHCP/iSCSI server" - $testdir/run-qemu -hda server.ext2 -hdb root.ext2 -m 256M -nographic \ - -hdc iscsidisk2.img -hdd iscsidisk3.img \ + $testdir/run-qemu \ + -hda $TESTDIR/server.ext2 \ + -hdb $TESTDIR/root.ext2 \ + -hdc $TESTDIR/iscsidisk2.img \ + -hdd $TESTDIR/iscsidisk3.img \ + -m 256M -nographic \ -net nic,macaddr=52:54:00:12:34:56,model=e1000 \ - -net socket,listen=127.0.0.1:12345 \ + -net socket,listen=127.0.0.1:12330 \ -serial $SERIAL \ -kernel /boot/vmlinuz-$KVERSION \ -append "root=/dev/sda rw quiet console=ttyS0,115200n81 selinux=0" \ - -initrd initramfs.server -pidfile server.pid -daemonize || return 1 - sudo chmod 644 server.pid || return 1 + -initrd $TESTDIR/initramfs.server \ + -pidfile $TESTDIR/server.pid -daemonize || return 1 + sudo chmod 644 $TESTDIR/server.pid || return 1 # Cleanup the terminal if we have one tty -s && stty sane @@ -31,27 +36,35 @@ run_server() { run_client() { # Need this so kvm-qemu will boot (needs non-/dev/zero local disk) - if ! dd if=/dev/zero of=client.img bs=1M count=1; then + if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1; then echo "Unable to make client sda image" 1>&2 return 1 fi - $testdir/run-qemu -hda client.img -m 256M -nographic \ + $testdir/run-qemu \ + -hda $TESTDIR/client.img \ + -m 256M -nographic \ -net nic,macaddr=52:54:00:12:34:00,model=e1000 \ - -net socket,connect=127.0.0.1:12345 \ + -net socket,connect=127.0.0.1:12330 \ -kernel /boot/vmlinuz-$KVERSION \ -append "root=LABEL=sysroot ip=192.168.50.101::192.168.50.1:255.255.255.0:iscsi-1:eth0:off netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target1 netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2 rw quiet rd.retry=5 rd.debug rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \ - -initrd initramfs.testing - grep -m 1 -q iscsi-OK client.img || return 1 + -initrd $TESTDIR/initramfs.testing + grep -m 1 -q iscsi-OK $TESTDIR/client.img || return 1 + if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1; then + echo "Unable to make client sda image" 1>&2 + return 1 + fi - $testdir/run-qemu -hda client.img -m 256M -nographic \ + $testdir/run-qemu \ + -hda $TESTDIR/client.img \ + -m 256M -nographic \ -net nic,macaddr=52:54:00:12:34:00,model=e1000 \ - -net socket,connect=127.0.0.1:12345 \ + -net socket,connect=127.0.0.1:12330 \ -kernel /boot/vmlinuz-$KVERSION \ -append "root=dhcp rw quiet rd.retry=5 rd.debug rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \ - -initrd initramfs.testing - grep -m 1 -q iscsi-OK client.img || return 1 + -initrd $TESTDIR/initramfs.testing + grep -m 1 -q iscsi-OK $TESTDIR/client.img || return 1 } @@ -62,9 +75,9 @@ test_run() { fi run_client ret=$? - if [[ -s server.pid ]]; then - sudo kill -TERM $(cat server.pid) - rm -f server.pid + if [[ -s $TESTDIR/server.pid ]]; then + sudo kill -TERM $(cat $TESTDIR/server.pid) + rm -f $TESTDIR/server.pid fi return $ret } @@ -76,14 +89,14 @@ test_setup() { fi # Create the blank file to use as a root filesystem - dd if=/dev/zero of=root.ext2 bs=1M count=20 - dd if=/dev/zero of=iscsidisk2.img bs=1M count=20 - dd if=/dev/zero of=iscsidisk3.img bs=1M count=20 + dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=20 + dd if=/dev/null of=$TESTDIR/iscsidisk2.img bs=1M seek=20 + dd if=/dev/null of=$TESTDIR/iscsidisk3.img bs=1M seek=20 kernel=$KVERSION # Create what will eventually be our root filesystem onto an overlay ( - initdir=overlay/source + initdir=$TESTDIR/overlay/source . $basedir/dracut-functions dracut_install sh shutdown poweroff stty cat ps ln ip \ /lib/terminfo/l/linux mount dmesg mkdir \ @@ -96,7 +109,7 @@ test_setup() { # second, install the files needed to make the root filesystem ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install sfdisk mke2fs poweroff cp umount inst_hook initqueue 01 ./create-root.sh @@ -106,49 +119,52 @@ 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. - $basedir/dracut -l -i overlay / \ + $basedir/dracut -l -i $TESTDIR/overlay / \ -m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \ - -f initramfs.makeroot $KVERSION || return 1 - rm -rf overlay + -f $TESTDIR/initramfs.makeroot $KVERSION || return 1 + rm -rf $TESTDIR/overlay # Need this so kvm-qemu will boot (needs non-/dev/zero local disk) - if ! dd if=/dev/zero of=client.img bs=1M count=1; then + if ! dd if=/dev/null of=$TESTDIR/client.img bs=1M seek=1; then echo "Unable to make client sdb image" 1>&2 return 1 fi # Invoke KVM and/or QEMU to actually create the target filesystem. - $testdir/run-qemu -hda root.ext2 -hdb client.img \ - -hdc iscsidisk2.img -hdd iscsidisk3.img \ + $testdir/run-qemu \ + -hda $TESTDIR/root.ext2 \ + -hdb $TESTDIR/client.img \ + -hdc $TESTDIR/iscsidisk2.img \ + -hdd $TESTDIR/iscsidisk3.img \ -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 client.img || return 1 - rm client.img + -initrd $TESTDIR/initramfs.makeroot || return 1 + grep -m 1 -q dracut-root-block-created $TESTDIR/client.img || return 1 + rm $TESTDIR/client.img ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install poweroff shutdown inst_hook emergency 000 ./hard-off.sh inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ) - sudo $basedir/dracut -l -i overlay / \ + sudo $basedir/dracut -l -i $TESTDIR/overlay / \ -o "plymouth dmraid" \ -a "debug" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \ - -f initramfs.testing $KVERSION || return 1 + -f $TESTDIR/initramfs.testing $KVERSION || return 1 # Make server root - dd if=/dev/zero of=server.ext2 bs=1M count=60 - mke2fs -F server.ext2 - mkdir mnt - sudo mount -o loop server.ext2 mnt + dd if=/dev/null of=$TESTDIR/server.ext2 bs=1M seek=60 + mke2fs -F $TESTDIR/server.ext2 + mkdir $TESTDIR/mnt + sudo mount -o loop $TESTDIR/server.ext2 $TESTDIR/mnt kernel=$KVERSION ( - initdir=mnt + initdir=$TESTDIR/mnt . $basedir/dracut-functions ( cd "$initdir"; @@ -176,25 +192,22 @@ test_setup() { sudo ldconfig -r "$initdir" ) - sudo umount mnt - rm -fr mnt + sudo umount $TESTDIR/mnt + rm -fr $TESTDIR/mnt # Make server's dracut image - $basedir/dracut -l -i overlay / \ + $basedir/dracut -l -i $TESTDIR/overlay / \ -m "dash udev-rules base rootfs-block debug kernel-modules" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod e1000" \ - -f initramfs.server $KVERSION || return 1 + -f $TESTDIR/initramfs.server $KVERSION || return 1 } test_cleanup() { - if [[ -s server.pid ]]; then - sudo kill -TERM $(cat server.pid) - rm -f server.pid + if [[ -s $TESTDIR/server.pid ]]; then + sudo kill -TERM $(cat $TESTDIR/server.pid) + rm -f $TESTDIR/server.pid fi - rm -rf mnt overlay - rm -f client.ext2 server.ext2 client.img initramfs.server initramfs.testing - rm -f initramfs.makeroot root.ext2 iscsidisk2.img iscsidisk3.img } . $testdir/test-functions diff --git a/test/TEST-40-NBD/test.sh b/test/TEST-40-NBD/test.sh index c5603fd2..255e3bc7 100755 --- a/test/TEST-40-NBD/test.sh +++ b/test/TEST-40-NBD/test.sh @@ -14,15 +14,18 @@ run_server() { # Start server first echo "NBD TEST SETUP: Starting DHCP/NBD server" - $testdir/run-qemu -hda server.ext2 -hdb nbd.ext2 -hdc encrypted.ext2 \ + $testdir/run-qemu \ + -hda $TESTDIR/server.ext2 \ + -hdb $TESTDIR/nbd.ext2 \ + -hdc $TESTDIR/encrypted.ext2 \ -m 256M -nographic \ -net nic,macaddr=52:54:00:12:34:56,model=e1000 \ - -net socket,listen=127.0.0.1:12345 \ + -net socket,listen=127.0.0.1:12340 \ -serial $SERIAL \ -kernel /boot/vmlinuz-$KVERSION \ -append "root=/dev/sda rw quiet console=ttyS0,115200n81 selinux=0" \ - -initrd initramfs.server -pidfile server.pid -daemonize || return 1 - sudo chmod 644 server.pid || return 1 + -initrd $TESTDIR/initramfs.server -pidfile $TESTDIR/server.pid -daemonize || return 1 + sudo chmod 644 $TESTDIR/server.pid || return 1 # Cleanup the terminal if we have one tty -s && stty sane @@ -45,25 +48,27 @@ client_test() { echo "CLIENT TEST START: $test_name" # Clear out the flags for each test - if ! dd if=/dev/zero of=flag.img bs=1M count=1; then + if ! dd if=/dev/zero of=$TESTDIR/flag.img bs=1M count=1; then echo "Unable to make client sda image" 1>&2 return 1 fi - $testdir/run-qemu -hda flag.img -m 256M -nographic \ + $testdir/run-qemu \ + -hda $TESTDIR/flag.img \ + -m 256M -nographic \ -net nic,macaddr=$mac,model=e1000 \ - -net socket,connect=127.0.0.1:12345 \ + -net socket,connect=127.0.0.1:12340 \ -kernel /boot/vmlinuz-$KVERSION \ -append "$cmdline $DEBUGFAIL rd.debug rd.info ro quiet console=ttyS0,115200n81 selinux=0" \ - -initrd initramfs.testing + -initrd $TESTDIR/initramfs.testing - if [[ $? -ne 0 ]] || ! grep -m 1 -q nbd-OK flag.img; then + if [[ $? -ne 0 ]] || ! grep -m 1 -q nbd-OK $TESTDIR/flag.img; then echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]" return 1 fi # nbdinfo=( fstype fsoptions ) - nbdinfo=($(awk '{print $2, $3; exit}' flag.img)) + nbdinfo=($(awk '{print $2, $3; exit}' $TESTDIR/flag.img)) if [[ "${nbdinfo[0]}" != "$fstype" ]]; then echo "CLIENT TEST END: $test_name [FAILED - WRONG FS TYPE]" @@ -171,21 +176,21 @@ client_run() { "root=/dev/dracut/root netroot=dhcp" || return 1 if [[ -s server.pid ]]; then - sudo kill -TERM $(cat server.pid) - rm -f server.pid + sudo kill -TERM $(cat $TESTDIR/server.pid) + rm -f $TESTDIR/server.pid fi } make_encrypted_root() { # Create the blank file to use as a root filesystem - dd if=/dev/zero of=encrypted.ext2 bs=1M count=20 - dd if=/dev/zero of=flag.img bs=1M count=1 + dd if=/dev/null of=$TESTDIR/encrypted.ext2 bs=1M seek=20 + dd if=/dev/null of=$TESTDIR/flag.img bs=1M seek=1 kernel=$KVERSION # Create what will eventually be our root filesystem onto an overlay ( - initdir=overlay/source + initdir=$TESTDIR/overlay/source . $basedir/dracut-functions dracut_install sh df free ls shutdown poweroff stty cat ps ln ip \ /lib/terminfo/l/linux mount dmesg mkdir cp ping @@ -196,7 +201,7 @@ make_encrypted_root() { # second, install the files needed to make the root filesystem ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install mke2fs poweroff cp umount tune2fs inst_hook initqueue 01 ./create-root.sh @@ -206,30 +211,33 @@ 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. - $basedir/dracut -l -i overlay / \ + $basedir/dracut -l -i $TESTDIR/overlay / \ -m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \ -d "piix ide-gd_mod ata_piix ext2 ext3 sd_mod" \ - -f initramfs.makeroot $KVERSION || return 1 - rm -rf overlay + -f $TESTDIR/initramfs.makeroot $KVERSION || return 1 + rm -rf $TESTDIR/overlay # Invoke KVM and/or QEMU to actually create the target filesystem. - $testdir/run-qemu -hda flag.img -hdb encrypted.ext2 -m 256M \ + $testdir/run-qemu \ + -hda $TESTDIR/flag.img \ + -hdb $TESTDIR/encrypted.ext2 \ + -m 256M \ -nographic -net none \ -kernel "/boot/vmlinuz-$kernel" \ -append "root=/dev/dracut/root rw quiet console=ttyS0,115200n81 selinux=0" \ - -initrd initramfs.makeroot || return 1 - grep -m 1 -q dracut-root-block-created flag.img || return 1 + -initrd $TESTDIR/initramfs.makeroot || return 1 + grep -m 1 -q dracut-root-block-created $TESTDIR/flag.img || return 1 } make_client_root() { - dd if=/dev/zero of=nbd.ext2 bs=1M count=30 - mke2fs -F -j nbd.ext2 - mkdir mnt - sudo mount -o loop nbd.ext2 mnt + dd if=/dev/null of=$TESTDIR/nbd.ext2 bs=1M seek=30 + mke2fs -F -j $TESTDIR/nbd.ext2 + mkdir $TESTDIR/mnt + sudo mount -o loop $TESTDIR/nbd.ext2 $TESTDIR/mnt kernel=$KVERSION ( - initdir=mnt + initdir=$TESTDIR/mnt . $basedir/dracut-functions dracut_install sh ls shutdown poweroff stty cat ps ln ip \ /lib/terminfo/l/linux dmesg mkdir cp ping @@ -249,19 +257,19 @@ make_client_root() { sudo ldconfig -r "$initdir" ) - sudo umount mnt - rm -fr mnt + sudo umount $TESTDIR/mnt + rm -fr $TESTDIR/mnt } make_server_root() { - dd if=/dev/zero of=server.ext2 bs=1M count=30 - mke2fs -F server.ext2 - mkdir mnt - sudo mount -o loop server.ext2 mnt + dd if=/dev/null of=$TESTDIR/server.ext2 bs=1M seek=30 + mke2fs -F $TESTDIR/server.ext2 + mkdir $TESTDIR/mnt + sudo mount -o loop $TESTDIR/server.ext2 $TESTDIR/mnt kernel=$KVERSION ( - initdir=mnt + initdir=$TESTDIR/mnt . $basedir/dracut-functions dracut_install sh ls shutdown poweroff stty cat ps ln ip \ /lib/terminfo/l/linux dmesg mkdir cp ping grep \ @@ -286,8 +294,8 @@ make_server_root() { sudo ldconfig -r "$initdir" ) - sudo umount mnt - rm -fr mnt + sudo umount $TESTDIR/mnt + rm -fr $TESTDIR/mnt } test_setup() { @@ -300,7 +308,7 @@ test_setup() { # Make the test image ( - initdir=overlay + initdir=$TESTDIR/overlay . $basedir/dracut-functions dracut_install poweroff shutdown inst_hook emergency 000 ./hard-off.sh @@ -308,30 +316,27 @@ test_setup() { inst ./cryptroot-ask /sbin/cryptroot-ask ) - sudo $basedir/dracut -l -i overlay / \ + sudo $basedir/dracut -l -i $TESTDIR/overlay / \ -m "dash udev-rules rootfs-block base debug kernel-modules" \ -d "piix ide-gd_mod ata_piix ext2 ext3 sd_mod e1000" \ - -f initramfs.server $KVERSION || return 1 + -f $TESTDIR/initramfs.server $KVERSION || return 1 - sudo $basedir/dracut -l -i overlay / \ + sudo $basedir/dracut -l -i $TESTDIR/overlay / \ -o "plymouth" \ -a "debug" \ -d "piix ide-gd_mod ata_piix ext2 ext3 sd_mod e1000" \ - -f initramfs.testing $KVERSION || return 1 + -f $TESTDIR/initramfs.testing $KVERSION || return 1 } kill_server() { - if [[ -s server.pid ]]; then - sudo kill -TERM $(cat server.pid) - rm -f server.pid + if [[ -s $TESTDIR/server.pid ]]; then + sudo kill -TERM $(cat $TESTDIR/server.pid) + rm -f $TESTDIR/server.pid fi } test_cleanup() { kill_server - rm -fr overlay mnt - rm -f flag.img server.ext2 nbd.ext2 encrypted.ext2 - rm -f initramfs.server initramfs.testing initramfs.makeroot } . $testdir/test-functions diff --git a/test/TEST-50-MULTINIC/test.sh b/test/TEST-50-MULTINIC/test.sh index 608fffcc..7ad42db8 100755 --- a/test/TEST-50-MULTINIC/test.sh +++ b/test/TEST-50-MULTINIC/test.sh @@ -12,14 +12,14 @@ run_server() { # Start server first echo "MULTINIC TEST SETUP: Starting DHCP/NFS server" - $testdir/run-qemu -hda server.ext2 -m 256M -nographic \ + $testdir/run-qemu -hda $TESTDIR/server.ext2 -m 256M -nographic \ -net nic,macaddr=52:54:00:12:34:56,model=e1000 \ - -net socket,listen=127.0.0.1:12345 \ + -net socket,listen=127.0.0.1:12350 \ -serial $SERIAL \ -kernel /boot/vmlinuz-$KVERSION \ -append "selinux=0 root=/dev/sda rd.debug rd.info rw quiet console=ttyS0,115200n81" \ - -initrd initramfs.server -pidfile server.pid -daemonize || return 1 - sudo chmod 644 server.pid || return 1 + -initrd $TESTDIR/initramfs.server -pidfile $TESTDIR/server.pid -daemonize || return 1 + sudo chmod 644 $TESTDIR/server.pid || return 1 # Cleanup the terminal if we have one tty -s && stty sane @@ -39,22 +39,22 @@ client_test() { echo "CLIENT TEST START: $test_name" # Need this so kvm-qemu will boot (needs non-/dev/zero local disk) - if ! dd if=/dev/zero of=client.img bs=1M count=1; then + if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1; then echo "Unable to make client sda image" 1>&2 return 1 fi - $testdir/run-qemu -hda client.img -m 512M -nographic \ + $testdir/run-qemu -hda $TESTDIR/client.img -m 512M -nographic \ -net nic,macaddr=52:54:00:12:34:$mac1,model=e1000 \ -net nic,macaddr=52:54:00:12:34:$mac2,model=e1000 \ -net nic,macaddr=52:54:00:12:34:$mac3,model=e1000 \ - -net socket,connect=127.0.0.1:12345 \ + -net socket,connect=127.0.0.1:12350 \ -hdc /dev/null \ -kernel /boot/vmlinuz-$KVERSION \ -append "$cmdline $DEBUGFAIL rd.retry=5 rd.debug rd.info ro quiet console=ttyS0,115200n81 selinux=0 rd.copystate" \ - -initrd initramfs.testing + -initrd $TESTDIR/initramfs.testing - if [[ $? -ne 0 ]] || ! grep -m 1 -q OK client.img; then + if [[ $? -ne 0 ]] || ! grep -m 1 -q OK $TESTDIR/client.img; then echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]" return 1 fi @@ -62,7 +62,7 @@ client_test() { for i in $check ; do echo $i - if ! grep -m 1 -q $i client.img; then + if ! grep -m 1 -q $i $TESTDIR/client.img; then echo "CLIENT TEST END: $test_name [FAILED - BAD IF]" return 1 fi @@ -122,14 +122,14 @@ test_client() { test_setup() { # Make server root - dd if=/dev/zero of=server.ext2 bs=1M count=60 - mke2fs -F server.ext2 - mkdir mnt - sudo mount -o loop server.ext2 mnt + dd if=/dev/null of=$TESTDIR/server.ext2 bs=1M seek=60 + mke2fs -F $TESTDIR/server.ext2 + mkdir $TESTDIR/mnt + sudo mount -o loop $TESTDIR/server.ext2 $TESTDIR/mnt kernel=$KVERSION ( - initdir=mnt + initdir=$TESTDIR/mnt . $basedir/dracut-functions dracut_install sh ls shutdown poweroff stty cat ps ln ip \ /lib/terminfo/l/linux dmesg mkdir cp ping exportfs \ @@ -183,7 +183,7 @@ test_setup() { ) # Make client root inside server root - initdir=mnt/nfs/client + initdir=$TESTDIR/mnt/nfs/client mkdir -p $initdir ( @@ -208,13 +208,13 @@ test_setup() { sudo ldconfig -r "$initdir" ) - sudo umount mnt - rm -fr mnt + sudo umount $TESTDIR/mnt + rm -fr $TESTDIR/mnt # Make an overlay with needed tools for the test harness ( - initdir=overlay - mkdir overlay + initdir=$TESTDIR/overlay + mkdir $TESTDIR/overlay . $basedir/dracut-functions dracut_install poweroff shutdown inst_hook emergency 000 ./hard-off.sh @@ -222,29 +222,28 @@ test_setup() { ) # Make server's dracut image - $basedir/dracut -l -i overlay / \ + $basedir/dracut -l -i $TESTDIR/overlay / \ -m "dash udev-rules base rootfs-block debug kernel-modules" \ -d "piix ide-gd_mod ata_piix ext2 sd_mod e1000" \ - -f initramfs.server $KVERSION || return 1 + -f $TESTDIR/initramfs.server $KVERSION || return 1 # Make client's dracut image - $basedir/dracut -l -i overlay / \ + $basedir/dracut -l -i $TESTDIR/overlay / \ -o "plymouth" \ -a "debug" \ -d "piix sd_mod sr_mod ata_piix ide-gd_mod e1000 nfs sunrpc" \ - -f initramfs.testing $KVERSION || return 1 + -f $TESTDIR/initramfs.testing $KVERSION || return 1 } kill_server() { - if [[ -s server.pid ]]; then - sudo kill -TERM $(cat server.pid) - rm -f server.pid + if [[ -s $TESTDIR/server.pid ]]; then + sudo kill -TERM $(cat $TESTDIR/server.pid) + rm -f $TESTDIR/server.pid fi } test_cleanup() { - rm -rf mnt overlay - rm -f server.ext2 client.img initramfs.server initramfs.testing + kill_server } . $testdir/test-functions diff --git a/test/test-functions b/test/test-functions index 70cab538..1609a54a 100644 --- a/test/test-functions +++ b/test/test-functions @@ -1,6 +1,12 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin export PATH +[[ -e .testdir ]] && . .testdir +if [[ -z "$TESTDIR" ]] || [[ ! -d "$TESTDIR" ]]; then + TESTDIR=$(mktemp -d -t dracut-test.XXXXXX) +fi +echo "TESTDIR=\"$TESTDIR\"" > .testdir +export TESTDIR while (($# > 0)); do case $1 in @@ -15,6 +21,8 @@ while (($# > 0)); do --clean) echo "TEST CLEANUP: $TEST_DESCRIPTION" test_cleanup + rm -fr "$TESTDIR" + rm -f .testdir exit $?;; --all) echo -n "TEST: $TEST_DESCRIPTION "; @@ -22,6 +30,8 @@ while (($# > 0)); do test_setup && test_run ret=$? test_cleanup + rm -fr "$TESTDIR" + rm -f .testdir exit $ret ) </dev/null >test.log 2>&1 ret=$? |