From d6862983155c31896ac46dc9d43f4086850a0d44 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Mon, 18 Jun 2012 19:28:44 +0200 Subject: [PATCH] TEST-50-MULTINIC: libnss cleanup --- test/TEST-50-MULTINIC/test.sh | 235 +++++++++++++++++++---------------------- 1 file changed, 110 insertions(+), 125 deletions(-) diff --git a/test/TEST-50-MULTINIC/test.sh b/test/TEST-50-MULTINIC/test.sh index 1655608..5c7ca6c 100755 --- a/test/TEST-50-MULTINIC/test.sh +++ b/test/TEST-50-MULTINIC/test.sh @@ -1,4 +1,6 @@ #!/bin/bash +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh TEST_DESCRIPTION="root filesystem on NFS with multiple nics" KVERSION=${KVERSION-$(uname -r)} @@ -41,15 +43,15 @@ client_test() { # Need this so kvm-qemu will boot (needs non-/dev/zero local disk) 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 + echo "Unable to make client sda image" 1>&2 + return 1 fi $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:12350 \ + -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:12350 \ -hdc /dev/null \ -watchdog ib700 -watchdog-action poweroff \ -kernel /boot/vmlinuz-$KVERSION \ @@ -57,17 +59,17 @@ client_test() { -initrd $TESTDIR/initramfs.testing if [[ $? -ne 0 ]] || ! grep -m 1 -q OK $TESTDIR/client.img; then - echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]" - return 1 + echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]" + return 1 fi for i in $check ; do - echo $i - if ! grep -m 1 -q $i $TESTDIR/client.img; then - echo "CLIENT TEST END: $test_name [FAILED - BAD IF]" - return 1 - fi + echo $i + if ! grep -m 1 -q $i $TESTDIR/client.img; then + echo "CLIENT TEST END: $test_name [FAILED - BAD IF]" + return 1 + fi done echo "CLIENT TEST END: $test_name [OK]" @@ -77,8 +79,8 @@ client_test() { test_run() { if ! run_server; then - echo "Failed to start server" 1>&2 - return 1 + echo "Failed to start server" 1>&2 + return 1 fi test_client || { kill_server; return 1; } } @@ -90,33 +92,33 @@ test_client() { # 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 + 00 01 02 \ + "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \ + "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 + 00 01 02 \ + "root=dhcp BOOTIF=52-54-00-12-34-02" \ + "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 + FF 00 FE \ + "root=nfs:192.168.50.1:/nfs/client ip=dhcp" \ + "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 + 00 01 02 \ + "root=nfs:192.168.50.1:/nfs/client ip=eth1:dhcp ip=eth2:dhcp bootdev=eth1" \ + "eth1 eth2" || 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 + 00 01 02 \ + "root=dhcp ip=eth0:dhcp ip=eth1:dhcp ip=eth2:dhcp bootdev=eth2" \ + "eth0 eth1 eth2" || return 1 kill_server return 0 @@ -129,86 +131,70 @@ test_setup() { mkdir $TESTDIR/mnt sudo mount -o loop $TESTDIR/server.ext3 $TESTDIR/mnt - export kernel=$KVERSION - export srcmods="/lib/modules/$kernel/" - # Detect lib paths - . $basedir/dracut-functions.sh - if ! [[ $libdirs ]] ; then - if strstr "$(ldd /bin/sh)" "/lib64/" &>/dev/null \ - && [[ -d /lib64 ]]; then - libdirs+=" /lib64" - [[ -d /usr/lib64 ]] && libdirs+=" /usr/lib64" - else - libdirs+=" /lib" - [[ -d /usr/lib ]] && libdirs+=" /usr/lib" - fi - fi ( - initdir=$TESTDIR/mnt - - for _f in modules.builtin.bin modules.builtin; do - [[ $srcmods/$_f ]] && break - done || { - dfatal "No modules.builtin.bin and modules.builtin found!" - return 1 - } + initdir=$TESTDIR/mnt + + ( + cd "$initdir"; + mkdir -p dev sys proc run etc var/run tmp var/lib/{dhcpd,rpcbind} + mkdir -p var/lib/nfs/{v4recovery,rpc_pipefs} + chmod 777 var/lib/rpcbind var/lib/nfs + ) + + for _f in modules.builtin.bin modules.builtin; do + [[ $srcmods/$_f ]] && break + done || { + dfatal "No modules.builtin.bin and modules.builtin found!" + return 1 + } for _f in modules.builtin.bin modules.builtin modules.order; do - [[ $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f" - done + [[ $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f" + done - dracut_install sh ls shutdown poweroff stty cat ps ln ip \ - dmesg mkdir cp ping exportfs \ - modprobe rpc.nfsd rpc.mountd showmount tcpdump \ - /etc/services sleep mount chmod + dracut_install sh ls shutdown poweroff stty cat ps ln ip \ + dmesg mkdir cp ping exportfs \ + modprobe rpc.nfsd rpc.mountd showmount tcpdump \ + /etc/services sleep mount chmod for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do - [ -f ${_terminfodir}/l/linux ] && break - done - dracut_install -o ${_terminfodir}/l/linux - type -P portmap >/dev/null && dracut_install portmap - type -P rpcbind >/dev/null && dracut_install rpcbind - [ -f /etc/netconfig ] && dracut_install /etc/netconfig - type -P dhcpd >/dev/null && dracut_install dhcpd - [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd - instmods nfsd sunrpc ipv6 lockd - inst ./server-init.sh /sbin/init - inst ./hosts /etc/hosts - inst ./exports /etc/exports - inst ./dhcpd.conf /etc/dhcpd.conf - dracut_install /etc/nsswitch.conf /etc/rpc /etc/protocols - dracut_install rpc.idmapd /etc/idmapd.conf - - inst_libdir_file 'libnfsidmap_nsswitch.so*' - inst_libdir_file 'libnfsidmap/*.so*' - inst_libdir_file 'libnfsidmap*.so*' + [ -f ${_terminfodir}/l/linux ] && break + done + dracut_install -o ${_terminfodir}/l/linux + type -P portmap >/dev/null && dracut_install portmap + type -P rpcbind >/dev/null && dracut_install rpcbind + [ -f /etc/netconfig ] && dracut_install /etc/netconfig + type -P dhcpd >/dev/null && dracut_install dhcpd + [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd + instmods nfsd sunrpc ipv6 lockd + inst ./server-init.sh /sbin/init + inst ./hosts /etc/hosts + inst ./exports /etc/exports + inst ./dhcpd.conf /etc/dhcpd.conf + dracut_install /etc/nsswitch.conf /etc/rpc /etc/protocols + + dracut_install rpc.idmapd /etc/idmapd.conf + + inst_libdir_file 'libnfsidmap_nsswitch.so*' + inst_libdir_file 'libnfsidmap/*.so*' + inst_libdir_file 'libnfsidmap*.so*' _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \ - | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|') + | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|') _nsslibs=${_nsslibs#|} _nsslibs=${_nsslibs%|} - inst_libdir_file -n "$_nsslibs" 'libnss*.so*' + inst_libdir_file -n "$_nsslibs" 'libnss*.so*' - ( - cd "$initdir"; - mkdir -p dev sys proc etc var/run tmp var/lib/{dhcpd,rpcbind} - mkdir -p var/lib/nfs/{v4recovery,rpc_pipefs} - chmod 777 var/lib/rpcbind var/lib/nfs - ) + inst /etc/nsswitch.conf /etc/nsswitch.conf + inst /etc/passwd /etc/passwd + inst /etc/group /etc/group - inst /etc/nsswitch.conf /etc/nsswitch.conf - inst /etc/passwd /etc/passwd - inst /etc/group /etc/group - for i in /lib*/libnss_files**;do - inst_library $i - done + /sbin/depmod -a -b "$initdir" $kernel - /sbin/depmod -a -b "$initdir" $kernel - - cp -a /etc/ld.so.conf* $initdir/etc - sudo ldconfig -r "$initdir" + cp -a /etc/ld.so.conf* $initdir/etc + sudo ldconfig -r "$initdir" ) # Make client root inside server root @@ -216,49 +202,48 @@ test_setup() { mkdir -p $initdir ( - dracut_install sh shutdown poweroff stty cat ps ln ip \ + dracut_install sh shutdown poweroff stty cat ps ln ip \ mount dmesg mkdir cp ping grep ls for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do - [ -f ${_terminfodir}/l/linux ] && break - done - dracut_install -o ${_terminfodir}/l/linux - inst ./client-init.sh /sbin/init - ( - cd "$initdir" - mkdir -p dev sys proc etc run - mkdir -p var/lib/nfs/rpc_pipefs - ) - inst /etc/nsswitch.conf /etc/nsswitch.conf - inst /etc/passwd /etc/passwd - inst /etc/group /etc/group - - inst_libdir_file 'libnfsidmap_nsswitch.so*' - inst_libdir_file 'libnfsidmap/*.so*' - inst_libdir_file 'libnfsidmap*.so*' + [ -f ${_terminfodir}/l/linux ] && break + done + dracut_install -o ${_terminfodir}/l/linux + inst ./client-init.sh /sbin/init + ( + cd "$initdir" + mkdir -p dev sys proc etc run + mkdir -p var/lib/nfs/rpc_pipefs + ) + inst /etc/nsswitch.conf /etc/nsswitch.conf + inst /etc/passwd /etc/passwd + inst /etc/group /etc/group + + dracut_install rpc.idmapd /etc/idmapd.conf + inst_libdir_file 'libnfsidmap_nsswitch.so*' + inst_libdir_file 'libnfsidmap/*.so*' + inst_libdir_file 'libnfsidmap*.so*' _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \ - | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|') + | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|') _nsslibs=${_nsslibs#|} _nsslibs=${_nsslibs%|} - inst_libdir_file -n "$_nsslibs" 'libnss*.so*' + inst_libdir_file -n "$_nsslibs" 'libnss*.so*' - cp -a /etc/ld.so.conf* $initdir/etc - sudo ldconfig -r "$initdir" + cp -a /etc/ld.so.conf* $initdir/etc + sudo ldconfig -r "$initdir" ) - chroot $initdir - sudo umount $TESTDIR/mnt rm -fr $TESTDIR/mnt # Make an overlay with needed tools for the test harness ( - initdir=$TESTDIR/overlay - mkdir $TESTDIR/overlay - dracut_install poweroff shutdown - inst_hook emergency 000 ./hard-off.sh - inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules + initdir=$TESTDIR/overlay + mkdir $TESTDIR/overlay + dracut_install poweroff shutdown + inst_hook emergency 000 ./hard-off.sh + inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ) # Make server's dracut image @@ -277,8 +262,8 @@ test_setup() { kill_server() { if [[ -s $TESTDIR/server.pid ]]; then - sudo kill -TERM $(cat $TESTDIR/server.pid) - rm -f $TESTDIR/server.pid + sudo kill -TERM $(cat $TESTDIR/server.pid) + rm -f $TESTDIR/server.pid fi }