bstinson / centos / t_functional

Forked from centos/t_functional 3 years ago
Clone

Blame tests/p_traceroute/traceroute_test.sh

Christoph Galuschka 08145a
#!/bin/sh
Christoph Galuschka 08145a
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka 08145a
Christoph Galuschka 164a07
t_Log "Running $0 - running traceroute to default gw"
Christoph Galuschka 08145a
Christoph Galuschka 164a07
# Finding Default Gateway
Christoph Galuschka 08145a
Christoph Galuschka 164a07
IP=$(ip route list default | grep 'default via ')
Christoph Galuschka 164a07
regex='.*via\ (.*)\ dev.*'
Christoph Galuschka 164a07
if [[ $IP =~ $regex ]]
Christoph Galuschka 08145a
then
Christoph Galuschka 164a07
  t_Log "Found default gw  (${BASH_REMATCH[1]}) - now testing"
Christoph Galuschka 164a07
  COUNT=$( traceroute -n ${BASH_REMATCH[1]} | grep -c ${BASH_REMATCH[1]} )
Christoph Galuschka 08145a
  if [ $COUNT = 2 ]
Christoph Galuschka 08145a
  then
Christoph Galuschka 164a07
    t_Log "traceroute reached default-gw"
Christoph Galuschka 08145a
    ret_val=0
Christoph Galuschka 08145a
  else
Christoph Galuschka 164a07
    t_Log "traceroute didn't reach ${BASH_REMATCH[1]}"
Christoph Galuschka 08145a
    ret_val=1
Christoph Galuschka 08145a
  fi
Christoph Galuschka 08145a
else
Christoph Galuschka 164a07
  t_Log "default gw seems to be unavailable - skipping"
Christoph Galuschka 08145a
  ret_val=0
Christoph Galuschka 08145a
fi
Christoph Galuschka 08145a
Christoph Galuschka 08145a
t_CheckExitStatus $ret_val