Blame tests/p_iputils/tracepath_test.sh
Branch: a17f9bc37bfc9793934f639f53334ba3274d5b71
Christoph Galuschka
fe4cd3
#!/bin/sh
Christoph Galuschka
fe4cd3
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka
fe4cd3
Christoph Galuschka
fe4cd3
TEST=tracepath
Christoph Galuschka
fe4cd3
Christoph Galuschka
fe4cd3
# Testing availability of network
Christoph Galuschka
fe4cd3
if [ $SKIP_QA_HARNESS -eq 1 ]; then
Athmane Madjoudj
b0e7f7
HOST="ci.centos.org"
Christoph Galuschka
fe4cd3
else
Christoph Galuschka
fe4cd3
HOST="repo.centos.qa"
Christoph Galuschka
fe4cd3
fi
Christoph Galuschka
fe4cd3
Christoph Galuschka
67e17b
t_Log "Running $0 - running ${TEST} to ${HOST}"
Christoph Galuschka
fe4cd3
Christoph Galuschka
67e17b
IP=$(host ${HOST})
Christoph Galuschka
dea7b2
FILE=/var/tmp/tracepath_result
Christoph Galuschka
6a95e1
ret_val=1
Christoph Galuschka
06f0c0
# getting IP-address of default gateway as a fall back
Christoph Galuschka
06f0c0
defgw=$(ip route list | grep default | cut -d' ' -f3)
Christoph Galuschka
67e17b
Christoph Galuschka
06f0c0
if [[ $IP =~ .*address\ ([0-9.]*) ]]
Christoph Galuschka
fe4cd3
then
Christoph Galuschka
dea7b2
tracepath -n ${HOST} > ${FILE}
Christoph Galuschka
dea7b2
COUNT=$(grep -c ${BASH_REMATCH[1]} ${FILE})
Christoph Galuschka
dea7b2
TTL=$(grep -c 'Too many hops' ${FILE})
Christoph Galuschka
06f0c0
GW=$(grep -c ${defgw} ${FILE})
Christoph Galuschka
6a95e1
if ([ $COUNT = 1 ] || [ $COUNT = 2 ])
Christoph Galuschka
06f0c0
then
Christoph Galuschka
67e17b
t_Log "${TEST} reached ${HOST}"
Christoph Galuschka
67e17b
ret_val=0
Christoph Galuschka
6a95e1
elif ([ $COUNT = 0 ] && [ $TTL = 1 ])
Christoph Galuschka
06f0c0
then
Christoph Galuschka
dea7b2
t_Log "${TEST} didn't reach ${HOST} because of too many hops. This is treated as SUCCESS."
Christoph Galuschka
5ca0de
ret_val=0
Christoph Galuschka
06f0c0
elif ([ $COUNT = 0 ] && [ $GW -gt 0 ])
Christoph Galuschka
06f0c0
then
Christoph Galuschka
06f0c0
t_Log "${TEST} didn't reach ${HOST} (maybe because of ACLs on the network), but at least the Default Gateway ${defgw} was reached. Treating as SUCCESS."
Christoph Galuschka
06f0c0
ret_val=0
Christoph Galuschka
6a95e1
else
Christoph Galuschka
6a95e1
t_Log "${TEST} didn't return anything we expect - FAILING"
Christoph Galuschka
6a95e1
ret_val=1
Christoph Galuschka
fe4cd3
fi
Christoph Galuschka
fe4cd3
fi
Christoph Galuschka
fe4cd3
Christoph Galuschka
da2882
/bin/rm ${FILE}
Christoph Galuschka
2b9efa
t_CheckExitStatus $ret_val