Skip to content

Commit

Permalink
Low: test-findif: make it work with findif.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
  • Loading branch information
jnpkrn committed Oct 15, 2012
1 parent 6cae519 commit 298a714
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions tools/test-findif.sh
Expand Up @@ -32,6 +32,11 @@ verbosely () { echo $1; $1; }


PRG=./findif
SCRIPT=../heartbeat/findif.sh
SCRIPT_CMD="$(head -n1 ${SCRIPT} | sed 's|#!||') \
-c \"source ${SCRIPT}; findif\""

CMD="${PRG}"

DUMMY_USER=test-findif

Expand Down Expand Up @@ -90,7 +95,9 @@ setup() {
die "Only tested with Linux, feel free to edit the condition."
fi

[ -x ${PRG} ] || die "Forgot to compile ${PRG} for me to test?"
if [ "${CMD}" = "${PRG}" ]; then
[ -x ${PRG} ] || die "Forgot to compile ${PRG} for me to test?"
fi

if [ $(id -u) -ne 0 ]; then
die "Due to (unobtrusive) juggling with routing, run as root."
Expand All @@ -106,7 +113,6 @@ setup() {
modprobe dummy || die "No dummy kernel module (per name) at hand."
fi


if ! ifconfig dummy0 ${DUMMY_IP} netmask ${DUMMY_NM}; then
die "Cannot ifconfig dummy0"
fi
Expand Down Expand Up @@ -135,7 +141,7 @@ proceed() {

env="OCF_RESKEY_ip=${ip} OCF_RESKEY_cidr_netmask=${mask}"
echo "${env}"
res="$(su ${DUMMY_USER} -c "${env} ${PRG} 2>&1")"
res="$(su ${DUMMY_USER} -c "${env} ${CMD} 2>&1")"
got_ec=$?

res="$(echo "${res}" | tr '\t' ' ' | tr -s ' ')"
Expand Down Expand Up @@ -196,16 +202,25 @@ proceed() {
}

if [ $# -ge 1 ]; then
case $1 in
setup|proceed|teardown)
verbosely $1
exit 0
;;
*)
echo "usage: ./$0 [setup|proceed|teardown]"
exit 0
;;
esac
while true; do
case $1 in
--script)
CMD="${SCRIPT_CMD}"
[ $# -eq 1 ] && break
;;
setup|proceed|teardown)
verbosely $1
ret=$?
[ $ret -ne 0 ] && exit $ret
;;
*)
echo "usage: ./$0 [setup|proceed|teardown]"
exit 0
;;
esac
[ $# -eq 1 ] && exit 0
shift
done
fi

verbosely setup
Expand Down

0 comments on commit 298a714

Please sign in to comment.