summaryrefslogtreecommitdiff
path: root/test/TEST-20-NFS/test.sh
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2011-11-16 14:04:27 +0100
committerHarald Hoyer <harald@redhat.com>2011-11-16 14:04:27 +0100
commit0be1785aea176779557a1150c3591f9ebd1e7446 (patch)
treecfb236157ce2ca289e06ac2ed81cb0907c32a5eb /test/TEST-20-NFS/test.sh
parentbf7487ab18a0b19af7c77e970ff0792b70fbdee6 (diff)
downloaddracut-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.
Diffstat (limited to 'test/TEST-20-NFS/test.sh')
-rwxr-xr-xtest/TEST-20-NFS/test.sh82
1 files changed, 44 insertions, 38 deletions
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