Skip to content

Commit

Permalink
Improved unit test runner & validator
Browse files Browse the repository at this point in the history
  • Loading branch information
rmetrich committed Jan 9, 2018
1 parent a87227e commit 801604a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
23 changes: 18 additions & 5 deletions tests/setup1/run.sh
@@ -1,24 +1,28 @@
#!/bin/bash

echo
echo "$0"
echo

REAR_DIR="/path/to/rear/sources"

RESULT_DIR="/root/$(basename $0 .sh)_results"
mkdir -p $RESULT_DIR

function DebugPrint () {
echo "DebugPrint: $*" | tee $RESULT_DIR/stderr >&2
echo "DebugPrint: $*" | tee -a $RESULT_DIR/stderr >&2
}

function LogPrint () {
echo "LogPrint: $*" | tee $RESULT_DIR/stderr >&2
echo "LogPrint: $*" | tee -a $RESULT_DIR/stderr >&2
}

function LogPrintError () {
echo "LogPrintError: $*" | tee $RESULT_DIR/stderr >&2
echo "LogPrintError: $*" | tee -a $RESULT_DIR/stderr >&2
}

function BugError () {
echo "BUGERROR: $*" | tee $RESULT_DIR/stderr >&2
echo "BUGERROR: $*" | tee -a $RESULT_DIR/stderr >&2
}

function read_and_strip_file () {
Expand All @@ -29,7 +33,16 @@ TMP_DIR=/root/tmp

rm -fr $TMP_DIR

sed "s#^network_devices_setup_script=.*#network_devices_setup_script=/tmp/60-network-devices.sh#" $REAR_DIR/usr/share/rear/rescue/GNU/Linux/310_network_devices.sh > /tmp/310_network_devices.sh
# Add to sed -e below to test 'has_lower_links=0' (RHEL6)
# -e 's#$has_lower_links#0#' \

# Add to sed -e below to test 'readlink' taking only 1 filename (RHEL6)
# -e 's#readlink /foo /bar#! readlink /foo /bar#' \

# Add to sed -e below to have code using 'brctl' instead of 'ip link' (RHEL6)
# -e 's#^iplink_has_bridge_rc=#iplink_has_bridge_rc=1#' \
sed -e "s#^network_devices_setup_script=.*#network_devices_setup_script=/tmp/60-network-devices.sh#" \
$REAR_DIR/usr/share/rear/rescue/GNU/Linux/310_network_devices.sh > /tmp/310_network_devices.sh
sed "s#^netscript=.*#netscript=/tmp/62-routing.sh#" $REAR_DIR/usr/share/rear/rescue/GNU/Linux/350_routing.sh > /tmp/350_routing.sh

. /tmp/310_network_devices.sh
Expand Down
8 changes: 6 additions & 2 deletions tests/setup1/verify.sh
Expand Up @@ -6,6 +6,10 @@ if [ -z "$CASE" ]; then
exit 2
fi

echo
echo "CASE $CASE"
echo

DEVICES="$( ls /sys/class/net/ | egrep -wv "(bonding_masters|eth0|lo)" )"

# Cleanup of network interfaces
Expand Down Expand Up @@ -38,7 +42,7 @@ echo
echo "Verifying 'ip a' output"
echo
rc=0
if ! diff -u $CASE/ip_a.expected $tmpfile_ipa; then
if ! diff -u <(sort $CASE/ip_a.expected) <(sort $tmpfile_ipa); then
rc=1
else
/bin/rm $tmpfile_ipa
Expand All @@ -48,7 +52,7 @@ fi
echo
echo "Verifying 'ip r' output"
echo
if ! diff -u $CASE/ip_r.expected $tmpfile_ipr; then
if ! diff -u <(sort $CASE/ip_r.expected) <(sort $tmpfile_ipr); then
rc=1
else
/bin/rm $tmpfile_ipr
Expand Down

0 comments on commit 801604a

Please sign in to comment.