From ff53445872f546ba64981b91761794b7efaeb9a6 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Fri, 12 Oct 2012 11:56:58 +0200
Subject: [PATCH] testsuite fixups

---
 test/TEST-14-IMSM/test.sh         | 10 ++--
 test/TEST-20-NFS/test.sh          |  4 +-
 test/TEST-40-NBD/test.sh          |  4 +-
 test/TEST-50-MULTINIC/client-init |  9 +++-
 test/TEST-50-MULTINIC/dhcpd.conf  |  6 +--
 test/TEST-50-MULTINIC/test.sh     | 96 ++++++++++++++++++++++++---------------
 6 files changed, 81 insertions(+), 48 deletions(-)

diff --git a/test/TEST-14-IMSM/test.sh b/test/TEST-14-IMSM/test.sh
index 3c8dc2f..263bb9c 100755
--- a/test/TEST-14-IMSM/test.sh
+++ b/test/TEST-14-IMSM/test.sh
@@ -23,14 +23,18 @@ client_run() {
 }
 
 test_run() {
+
+### MDADM does not want qemu with dmraids
+#    client_run || return 1
+#    client_run rd_NO_DM || return 1
+#    client_run rd_NO_MD failme && return 1
+####
+
     client_run rd_NO_MDIMSM || return 1
-    client_run || return 1
-    client_run rd_NO_DM || return 1
     # This test succeeds, because the mirror parts are found without
     # assembling the mirror itsself, which is what we want
     client_run rd_NO_DM rd_NO_MDIMSM rd_NO_MDADMCONF || return 1
     client_run rd_NO_MD rd_NO_MDIMSM failme && return 1
-    client_run rd_NO_MD failme && return 1
    return 0
 }
 
diff --git a/test/TEST-20-NFS/test.sh b/test/TEST-20-NFS/test.sh
index 340db8e..f832bca 100755
--- a/test/TEST-20-NFS/test.sh
+++ b/test/TEST-20-NFS/test.sh
@@ -222,7 +222,7 @@ test_setup() {
 	fi
 
 	dracut_install $(ls {/usr,}$LIBDIR/libnfsidmap*.so* 2>/dev/null )
-	dracut_install $(ls {/usr,}$LIBDIR/libnss*.so 2>/dev/null)
+	dracut_install $(ls {/usr,}$LIBDIR/libnss_*.so 2>/dev/null)
 	(
 	    cd "$initdir";
 	    mkdir -p dev sys proc etc var/run tmp var/lib/{dhcpd,rpcbind}
@@ -232,7 +232,7 @@ test_setup() {
 	inst /etc/nsswitch.conf /etc/nsswitch.conf
 	inst /etc/passwd /etc/passwd
 	inst /etc/group /etc/group
-	for i in /lib*/libnss_files**;do
+	for i in /lib*/libnss_files*;do
 	    inst_library $i
 	done
 
diff --git a/test/TEST-40-NBD/test.sh b/test/TEST-40-NBD/test.sh
index a6e7897..29d3e9d 100755
--- a/test/TEST-40-NBD/test.sh
+++ b/test/TEST-40-NBD/test.sh
@@ -235,7 +235,7 @@ make_client_root() {
 	inst /etc/nsswitch.conf /etc/nsswitch.conf
 	inst /etc/passwd /etc/passwd
 	inst /etc/group /etc/group
-	for i in /lib*/libnss_files**;do
+	for i in /lib*/libnss_files*;do
 	    inst_library $i
 	done
 
@@ -272,7 +272,7 @@ make_server_root() {
 	inst /etc/nsswitch.conf /etc/nsswitch.conf
 	inst /etc/passwd /etc/passwd
 	inst /etc/group /etc/group
-	for i in /lib*/libnss_files**;do
+	for i in /lib*/libnss_files*;do
 	    inst_library $i
 	done
 
diff --git a/test/TEST-50-MULTINIC/client-init b/test/TEST-50-MULTINIC/client-init
index 6b19167..697e5d7 100755
--- a/test/TEST-50-MULTINIC/client-init
+++ b/test/TEST-50-MULTINIC/client-init
@@ -4,6 +4,13 @@ export TERM=linux
 export PS1='initramfs-test:\w\$ '
 stty sane
 echo "made it to the rootfs! Powering down."
-echo OK $(cat /dev/.initramfs/net.ifaces) > /dev/sda
+ip route
+ifaces=$(ip route | while read a b c d e f; do
+        if [[ $a = "default" ]]; then
+            echo "-${e}-";
+        else
+            echo "$c"
+        fi; done)
+echo OK $ifaces > /dev/sda
 #sh -i
 poweroff -f
diff --git a/test/TEST-50-MULTINIC/dhcpd.conf b/test/TEST-50-MULTINIC/dhcpd.conf
index be8dee7..192dfc5 100644
--- a/test/TEST-50-MULTINIC/dhcpd.conf
+++ b/test/TEST-50-MULTINIC/dhcpd.conf
@@ -13,14 +13,14 @@ subnet 192.168.50.0 netmask 255.255.255.0 {
 
 	group {
 		host client-if1 {
-			hardware ethernet 52:54:00:12:34:00;
+			hardware ethernet 52:54:00:AB:34:00;
 			fixed-address 192.168.50.100;
 		}
 	}
 
 	group {
 		host client-if2 {
-			hardware ethernet 52:54:00:12:34:01;
+			hardware ethernet 52:54:00:AB:34:01;
 			fixed-address 192.168.50.101;
 		}
 	}
@@ -29,7 +29,7 @@ subnet 192.168.50.0 netmask 255.255.255.0 {
 		option root-path "nfs:192.168.50.1:/nfs/client";
 
 		host client-if3 {
-			hardware ethernet 52:54:00:12:34:02;
+			hardware ethernet 52:54:00:AB:34:02;
 			fixed-address 192.168.50.102;
 		}
 	}
diff --git a/test/TEST-50-MULTINIC/test.sh b/test/TEST-50-MULTINIC/test.sh
index 5762863..f42ba19 100755
--- a/test/TEST-50-MULTINIC/test.sh
+++ b/test/TEST-50-MULTINIC/test.sh
@@ -13,11 +13,12 @@ run_server() {
     echo "MULTINIC TEST SETUP: Starting DHCP/NFS server"
 
     $testdir/run-qemu -hda server.ext2 -m 256M -nographic \
-	-net nic,macaddr=52:54:00:12:34:56,model=e1000 \
+	-net nic,macaddr=52:54:00:AB:34:56,model=e1000 \
         -net socket,listen=127.0.0.1:12345 \
 	-serial $SERIAL \
 	-kernel /boot/vmlinuz-$KVERSION \
 	-append "selinux=0 root=/dev/sda rdinitdebug rdinfo rdnetdebug rw quiet console=ttyS0,115200n81" \
+        -boot order=c \
 	-initrd initramfs.server -pidfile server.pid -daemonize || return 1
     sudo chmod 644 server.pid || return 1
 
@@ -45,33 +46,48 @@ client_test() {
     fi
 
     $testdir/run-qemu -hda 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 nic,macaddr=52:54:00:AB:34:$mac1,model=e1000 \
+  	-net nic,macaddr=52:54:00:AB:34:$mac2,model=e1000 \
+  	-net nic,macaddr=52:54:00:AB:34:$mac3,model=e1000 \
         -net socket,connect=127.0.0.1:12345 \
   	-kernel /boot/vmlinuz-$KVERSION \
   	-append "$cmdline $DEBUGFAIL rd_retry=5 rdinitdebug rdinfo rdnetdebug ro quiet console=ttyS0,115200n81 selinux=0 rdcopystate" \
+        -boot order=c \
   	-initrd initramfs.testing
 
     if [[ $? -ne 0 ]]; then
 	echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
 	return 1
     fi
-    if ! grep -m 1 -q OK client.img; then
+
+    read line < client.img
+
+    if [[ $line != OK* ]]; then
 	echo "CLIENT TEST END: $test_name [FAILED - NO OK]"
 	return 1
     fi
 
+    echo "Checking '$line' for 'OK $check'"
 
-
-    for i in $check ; do
-	echo $i
-	if ! grep -m 1 -q $i client.img; then
+    for i in $check; do
+        if [[ $line != *$i* ]]; then
+            echo "'$line' does not contain '$i'"
 	    echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
 	    return 1
-	fi
+        fi
     done
 
+set -x
+    for i in $line; do
+        [[ $i == "OK" ]] && continue
+
+        if [[ $check != *${i}* ]]; then
+            echo "'$check' does not contain '$i'"
+	    echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
+	    return 1
+        fi
+    done
+set +x
     echo "CLIENT TEST END: $test_name [OK]"
     return 0
 }
@@ -87,45 +103,51 @@ test_run() {
     # ...:00-02 receive IP adresses all others don't
     # ...:02 receives a dhcp root-path
 
+    client_test "MULTINIC root=nfs ip=dhcp,auto" \
+	FF 00 FE \
+	"root=nfs:192.168.50.1:/nfs/client ip=dhcp,auto6 ifname=eth0:52:54:00:AB:34:FF ifname=eth1:52:54:00:AB:34:00 ifname=eth2:52:54:00:AB:34:FE" \
+	"eth1 -eth1-" || return 1
+
+    # Require two interfaces
+    client_test "MULTINIC root=nfs ip=eth1:dhcp ip=eth2:dhcp bootdev=eth1" \
+	00 01 02 \
+	"root=nfs:192.168.50.1:/nfs/client ip=eth1:dhcp ip=eth2:dhcp bootdev=eth1" \
+	"eth1 eth2 -eth1-" || return 1
+
+    # Require three interfaces with dhcp root-path
+    client_test "MULTINIC root=dhcp ip=eth0:dhcp ip=eth1:dhcp ip=eth2:dhcp bootdev=eth2" \
+	00 01 02 \
+	"root=dhcp ip=eth0:dhcp ip=eth1:dhcp ip=eth2:dhcp bootdev=eth2 ifname=eth0:52:54:00:AB:34:00 ifname=eth1:52:54:00:AB:34:01 ifname=eth2:52:54:00:AB:34:02" \
+	"eth0 eth1 eth2 -eth2-" || return 1
+
+    client_test "MULTINIC root=nfs ip=auto6,dhcp" \
+	FF 00 FE \
+	"root=nfs:192.168.50.1:/nfs/client ip=auto6,dhcp ifname=eth0:52:54:00:AB:34:FF ifname=eth1:52:54:00:AB:34:00 ifname=eth2:52:54:00:AB:34:FE" \
+	"eth1 -eth1-" || return 1
+
     # PXE Style BOOTIF=
     client_test "MULTINIC root=nfs BOOTIF=" \
 	00 01 02 \
-	"root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
-	"eth0" || return 1
+	"root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-AB-34-00 ifname=eth0:52:54:00:AB:34:00 ifname=eth1:52:54:00:AB:34:01 ifname=eth2:52:54:00:AB:34:02" \
+	"eth0 -eth0-" || return 1
 
     # PXE Style BOOTIF= with dhcp root-path
     client_test "MULTINIC root=dhcp BOOTIF=" \
 	00 01 02 \
-	"root=dhcp BOOTIF=52-54-00-12-34-02" \
-	"eth2" || return 1
+	"root=dhcp BOOTIF=52-54-00-AB-34-02 ifname=eth0:52:54:00:AB:34:00 ifname=eth1:52:54:00:AB:34:01 ifname=eth2:52:54:00:AB:34:02" \
+	"eth2 -eth2-" || return 1
 
     # Multinic case, where only one nic works
     client_test "MULTINIC root=nfs ip=dhcp" \
 	FF 00 FE \
-	"root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
-	"eth1" || return 1
-
-    client_test "MULTINIC root=nfs ip=auto6,dhcp" \
-	FF 00 FE \
-	"root=nfs:192.168.50.1:/nfs/client ip=auto6,dhcp" \
-	"eth1" || return 1
-
-    client_test "MULTINIC root=nfs ip=dhcp,auto" \
-	FF 00 FE \
-	"root=nfs:192.168.50.1:/nfs/client ip=dhcp,auto6" \
-	"eth1" || return 1
-
-    # Require two interfaces
-    client_test "MULTINIC root=nfs ip=eth1:dhcp ip=eth2:dhcp bootdev=eth1" \
-	00 01 02 \
-	"root=nfs:192.168.50.1:/nfs/client ip=eth1:dhcp ip=eth2:dhcp bootdev=eth1" \
-	"eth1 eth2" || return 1
+	"root=nfs:192.168.50.1:/nfs/client ip=dhcp ifname=eth0:52:54:00:AB:34:FF ifname=eth1:52:54:00:AB:34:00 ifname=eth2:52:54:00:AB:34:FE" \
+	"eth1 -eth1-" || return 1
 
     # Require three interfaces with dhcp root-path
     client_test "MULTINIC root=dhcp ip=eth0:dhcp ip=eth1:dhcp ip=eth2:dhcp bootdev=eth2" \
 	00 01 02 \
-	"root=dhcp ip=eth0:dhcp ip=eth1:dhcp ip=eth2:dhcp bootdev=eth2" \
-	"eth0 eth1 eth2" || return 1
+	"root=dhcp ip=eth0:dhcp ip=eth1:dhcp ip=eth2:dhcp bootdev=eth2 ifname=eth0:52:54:00:AB:34:00 ifname=eth1:52:54:00:AB:34:01 ifname=eth2:52:54:00:AB:34:02" \
+	"eth0 eth1 eth2 -eth2-" || return 1
 }
 
 test_setup() {
@@ -162,7 +184,7 @@ test_setup() {
  	fi
 
  	dracut_install $(ls {/usr,}$LIBDIR/libnfsidmap*.so* 2>/dev/null )
- 	dracut_install $(ls {/usr,}$LIBDIR/libnss*.so 2>/dev/null)
+ 	dracut_install $(ls {/usr,}$LIBDIR/libnss_*.so 2>/dev/null)
  	(
  	    cd "$initdir";
  	    mkdir -p dev sys proc etc var/run tmp var/lib/{dhcpd,rpcbind}
@@ -172,7 +194,7 @@ test_setup() {
  	inst /etc/nsswitch.conf /etc/nsswitch.conf
  	inst /etc/passwd /etc/passwd
  	inst /etc/group /etc/group
- 	for i in /lib*/libnss_files**;do
+ 	for i in /lib*/libnss_files*;do
  	    inst_library $i
  	done
 
@@ -231,7 +253,7 @@ test_setup() {
     $basedir/dracut -l -i overlay / \
 	-o "plymouth" \
 	-a "debug" \
-	-d "piix ide-gd_mod e1000 nfs sunrpc" \
+	-d "piix ide-gd_mod ata_piix sd_mod e1000 nfs sunrpc" \
 	-f initramfs.testing $KVERSION || return 1
 }
 
-- 
1.8.3.1

