Browse Source

fix(TEST BONDBRIDGEVLANIFCFG): shellcheck

master
Harald Hoyer 4 years ago committed by Harald Hoyer
parent
commit
6e5878188b
  1. 0
      test/TEST-60-BONDBRIDGEVLANIFCFG/.shchkdir
  2. 8
      test/TEST-60-BONDBRIDGEVLANIFCFG/client-init.sh
  3. 2
      test/TEST-60-BONDBRIDGEVLANIFCFG/create-root.sh
  4. 48
      test/TEST-60-BONDBRIDGEVLANIFCFG/server-init.sh
  5. 59
      test/TEST-60-BONDBRIDGEVLANIFCFG/test.sh

0
test/TEST-60-BONDBRIDGEVLANIFCFG/.shchkdir

8
test/TEST-60-BONDBRIDGEVLANIFCFG/client-init.sh

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
exec > /dev/console 2>&1
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
strstr() { [ "${1#*$2*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line; done < /proc/cmdline)
CMDLINE=$(while read -r line; do echo "$line"; done < /proc/cmdline)
export TERM=linux
export PS1='initramfs-test:\w\$ '
stty sane
@ -10,10 +10,10 @@ echo "made it to the rootfs! Powering down." @@ -10,10 +10,10 @@ echo "made it to the rootfs! Powering down."

(
echo OK
ip -o -4 address show scope global | while read n if rest; do echo $if; done | sort
ip -o -4 address show scope global | while read -r _ if rest; do echo "$if"; done | sort
for i in /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-*; do
echo $i
grep -v 'UUID=' $i
echo "$i"
grep -v 'UUID=' "$i"
done
echo EOF
) | dd oflag=direct,dsync of=/dev/sda

2
test/TEST-60-BONDBRIDGEVLANIFCFG/create-root.sh

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/bin/sh
# don't let udev and this script step on eachother's toes
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
: > "/etc/udev/rules.d/$x"
done
rm -f -- /etc/lvm/lvm.conf
udevadm control --reload

48
test/TEST-60-BONDBRIDGEVLANIFCFG/server-init.sh

@ -15,10 +15,10 @@ wait_for_if_link() { @@ -15,10 +15,10 @@ wait_for_if_link() {
while [ $cnt -lt 600 ]; do
ip link show

li=$(ip -o link show dev $1 2> /dev/null)
li=$(ip -o link show dev "$1" 2> /dev/null)
[ -n "$li" ] && return 0
if [[ $2 ]]; then
li=$(ip -o link show dev $2 2> /dev/null)
li=$(ip -o link show dev "$2" 2> /dev/null)
[ -n "$li" ] && return 0
fi
sleep 0.1
@ -31,7 +31,7 @@ wait_for_if_up() { @@ -31,7 +31,7 @@ wait_for_if_up() {
local cnt=0
local li
while [ $cnt -lt 200 ]; do
li=$(ip -o link show up dev $1)
li=$(ip -o link show up dev "$1")
[ -n "$li" ] && return 0
sleep 0.1
cnt=$((cnt + 1))
@ -51,7 +51,7 @@ wait_for_route_ok() { @@ -51,7 +51,7 @@ wait_for_route_ok() {
}

linkup() {
wait_for_if_link $1 2> /dev/null && ip link set $1 up 2> /dev/null && wait_for_if_up $1 2> /dev/null
wait_for_if_link "$1" 2> /dev/null && ip link set "$1" up 2> /dev/null && wait_for_if_up "$1" 2> /dev/null
}

udevadm settle
@ -64,13 +64,13 @@ wait_for_if_link eth2 ens5 @@ -64,13 +64,13 @@ wait_for_if_link eth2 ens5
wait_for_if_link eth3 ens6

modprobe --all -b -q 8021q ipvlan macvlan
> /dev/watchdog
: > /dev/watchdog
ip addr add 127.0.0.1/8 dev lo
linkup lo
ip link set dev eth0 name ens3
ip addr add 192.168.50.1/24 dev ens3
linkup ens3
> /dev/watchdog
: > /dev/watchdog
ip link set dev eth1 name ens4
ip link add dev ens4.1 link ens4 type vlan id 1
ip link add dev ens4.2 link ens4 type vlan id 2
@ -90,45 +90,45 @@ ip addr add 192.168.51.1/24 dev ens5 @@ -90,45 +90,45 @@ ip addr add 192.168.51.1/24 dev ens5
linkup ens5
ip link set dev eth3 name ens6
linkup ens6
> /dev/watchdog
: > /dev/watchdog
modprobe af_packet
> /dev/watchdog
: > /dev/watchdog
modprobe sunrpc
> /dev/watchdog
: > /dev/watchdog
mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs
> /dev/watchdog
: > /dev/watchdog
[ -x /sbin/portmap ] && portmap
> /dev/watchdog
: > /dev/watchdog
mkdir -p /run/rpcbind
[ -x /sbin/rpcbind ] && rpcbind
> /dev/watchdog
: > /dev/watchdog
modprobe nfsd
> /dev/watchdog
: > /dev/watchdog
mount -t nfsd nfsd /proc/fs/nfsd
> /dev/watchdog
: > /dev/watchdog
exportfs -r
> /dev/watchdog
: > /dev/watchdog
rpc.nfsd
> /dev/watchdog
: > /dev/watchdog
rpc.mountd
> /dev/watchdog
: > /dev/watchdog
rpc.idmapd -S
> /dev/watchdog
: > /dev/watchdog
exportfs -r
> /dev/watchdog
> /var/lib/dhcpd/dhcpd.leases
> /dev/watchdog
: > /dev/watchdog
: > /var/lib/dhcpd/dhcpd.leases
: > /dev/watchdog
chmod 777 /var/lib/dhcpd/dhcpd.leases
> /dev/watchdog
: > /dev/watchdog
dhcpd -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases ens3 ens5
#echo -n 'V' > /dev/watchdog
#echo -n 'V' : > /dev/watchdog
#sh -i
#tcpdump -i ens3
# Wait forever for the VM to die
echo "Serving"
while :; do
sleep 10
> /dev/watchdog
: > /dev/watchdog
done
mount -n -o remount,ro /
poweroff -f

59
test/TEST-60-BONDBRIDGEVLANIFCFG/test.sh

@ -10,6 +10,7 @@ else @@ -10,6 +10,7 @@ else
OMIT_NETWORK="network-manager"
fi

# shellcheck disable=SC2034
TEST_DESCRIPTION="root filesystem on NFS with bridging/bonding/vlan with $USE_NETWORK"

KVERSION=${KVERSION-$(uname -r)}
@ -23,7 +24,7 @@ run_server() { @@ -23,7 +24,7 @@ run_server() {
# Start server first
echo "MULTINIC TEST SETUP: Starting DHCP/NFS server"

$testdir/run-qemu \
"$testdir"/run-qemu \
-hda "$TESTDIR"/server.ext3 \
-netdev socket,id=n0,listen=127.0.0.1:12370 \
-netdev socket,id=n1,listen=127.0.0.1:12371 \
@ -33,8 +34,7 @@ run_server() { @@ -33,8 +34,7 @@ run_server() {
-device e1000,netdev=n1,mac=52:54:01:12:34:57 \
-device e1000,netdev=n2,mac=52:54:01:12:34:58 \
-device e1000,netdev=n3,mac=52:54:01:12:34:59 \
${SERIAL:+-serial "$SERIAL"} \
${SERIAL:--serial file:"$TESTDIR"/server.log} \
-serial "${SERIAL:-"file:$TESTDIR/server.log"}" \
-watchdog i6300esb -watchdog-action poweroff \
-append "panic=1 loglevel=7 root=LABEL=dracut rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0 rd.debug" \
-initrd "$TESTDIR"/initramfs.server \
@ -81,27 +81,27 @@ client_test() { @@ -81,27 +81,27 @@ client_test() {
nic3=" -netdev hubport,id=n3,hubid=3"
fi

$testdir/run-qemu \
"$testdir"/run-qemu \
-hda "$TESTDIR"/client.img \
-netdev socket,connect=127.0.0.1:12370,id=s1 \
-netdev hubport,hubid=1,id=h1,netdev=s1 \
-netdev hubport,hubid=1,id=h2 -device e1000,mac=52:54:00:12:34:01,netdev=h2 \
-netdev hubport,hubid=1,id=h3 -device e1000,mac=52:54:00:12:34:02,netdev=h3 \
$nic1 -device e1000,mac=52:54:00:12:34:03,netdev=n1 \
"$nic1" -device e1000,mac=52:54:00:12:34:03,netdev=n1 \
-netdev socket,connect=127.0.0.1:12372,id=n2 -device e1000,mac=52:54:00:12:34:04,netdev=n2 \
$nic3 -device e1000,mac=52:54:00:12:34:05,netdev=n3 \
"$nic3" -device e1000,mac=52:54:00:12:34:05,netdev=n3 \
-watchdog i6300esb -watchdog-action poweroff \
-append "panic=1 $cmdline systemd.crash_reboot rd.debug $DEBUGFAIL rd.retry=5 rw console=ttyS0,115200n81 selinux=0 init=/sbin/init" \
-initrd "$TESTDIR"/initramfs.testing

{
read OK
read -r OK _
if [[ $OK != "OK" ]]; then
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
return 1
fi

while read line; do
while read -r line; do
[[ $line == END ]] && break
CONF+="$line "
done
@ -203,26 +203,28 @@ test_setup() { @@ -203,26 +203,28 @@ test_setup() {

kernel=$KVERSION
(
mkdir -p $TESTDIR/overlay/source
mkdir -p "$TESTDIR"/overlay/source
# shellcheck disable=SC2030
export initdir=$TESTDIR/overlay/source
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh

(
cd "$initdir"
cd "$initdir" || exit
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
[[ -f $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"
[[ -f $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f"
done

inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
@ -270,8 +272,11 @@ test_setup() { @@ -270,8 +272,11 @@ test_setup() {

# Make client root inside server root
(
# shellcheck disable=SC2030
# shellcheck disable=SC2031
export initdir=$TESTDIR/overlay/source/nfs/client
. $basedir/dracut-init.sh
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
inst_multiple sh shutdown poweroff stty cat ps ln ip \
mount dmesg mkdir cp ping grep ls sort dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
@ -281,7 +286,7 @@ test_setup() { @@ -281,7 +286,7 @@ test_setup() {
inst_simple /etc/os-release
inst ./client-init.sh /sbin/init
(
cd "$initdir"
cd "$initdir" || exit
mkdir -p -- dev sys proc etc run
mkdir -p -- var/lib/nfs/rpc_pipefs
)
@ -307,8 +312,11 @@ test_setup() { @@ -307,8 +312,11 @@ test_setup() {

# second, install the files needed to make the root filesystem
(
# shellcheck disable=SC2030
# shellcheck disable=SC2031
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
inst_multiple sfdisk mkfs.ext3 poweroff cp umount sync dd
inst_hook initqueue 01 ./create-root.sh
inst_hook initqueue/finished 01 ./finished-false.sh
@ -318,24 +326,26 @@ test_setup() { @@ -318,24 +326,26 @@ 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.sh -l -i $TESTDIR/overlay / \
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-m "bash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--nomdadmconf \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
-f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1

# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext3 \
"$testdir"/run-qemu \
-drive format=raw,index=0,media=disk,file="$TESTDIR"/server.ext3 \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/server.ext3 || return 1
-initrd "$TESTDIR"/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created "$TESTDIR"/server.ext3 || return 1
rm -fr "$TESTDIR"/overlay

# Make an overlay with needed tools for the test harness
(
# shellcheck disable=SC2031
export initdir="$TESTDIR"/overlay
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
@ -344,7 +354,7 @@ test_setup() { @@ -344,7 +354,7 @@ test_setup() {
)

# Make server's dracut image
$basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
--no-early-microcode \
-m "udev-rules base rootfs-block fs-lib debug kernel-modules watchdog qemu" \
-d "ipvlan macvlan af_packet piix ide-gd_mod ata_piix ext3 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd e1000 i6300esb ib700wdt" \
@ -352,7 +362,7 @@ test_setup() { @@ -352,7 +362,7 @@ test_setup() {
-f "$TESTDIR"/initramfs.server "$KVERSION" || return 1

# Make client's dracut image
$basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
--no-early-microcode \
-o "plymouth ${OMIT_NETWORK}" \
-a "debug ${USE_NETWORK}" \
@ -363,7 +373,7 @@ test_setup() { @@ -363,7 +373,7 @@ test_setup() {

kill_server() {
if [[ -s "$TESTDIR"/server.pid ]]; then
kill -TERM -- $(cat "$TESTDIR"/server.pid)
kill -TERM -- "$(cat "$TESTDIR"/server.pid)"
rm -f -- "$TESTDIR"/server.pid
fi
}
@ -372,4 +382,5 @@ test_cleanup() { @@ -372,4 +382,5 @@ test_cleanup() {
kill_server
}

# shellcheck disable=SC1090
. "$testdir"/test-functions

Loading…
Cancel
Save