bstinson / centos / t_functional

Forked from centos/t_functional 4 years ago
Clone

Blame tests/p_arpwatch/arpwatch_test.sh

Christoph Galuschka 7bc035
#!/bin/sh
Christoph Galuschka ca9eca
#         Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka 7bc035
Christoph Galuschka 7bc035
t_Log "Running $0 - arpwatch on eth0"
Christoph Galuschka 7bc035
Athmane Madjoudj 820d69
# Kill arpwatch instance from previous test
Athmane Madjoudj 820d69
killall arpwatch
Athmane Madjoudj 820d69
Christoph Galuschka 7bc035
# getting IP-address of default gateway
Alice Kaerast 6c678d
defgw=$(route -n | grep 'UG[ \t]' | awk '{print $2}')
Alice Kaerast 6c678d
if [ -z $defgw ]
Alice Kaerast 6c678d
  then
Alice Kaerast 6c678d
  t_Log "No default gateway, can't test arpwatch"
Alice Kaerast 6c678d
  exit
Alice Kaerast 6c678d
fi
Christoph Galuschka 7bc035
Christoph Galuschka 7bc035
# setting path to arp.dat
Christoph Galuschka 7bc035
if (t_GetPkgRel basesystem | grep -q el5)
Christoph Galuschka 7bc035
  then
Christoph Galuschka 7bc035
  arpdat='/var/arpwatch/arp.dat'
Christoph Galuschka 7bc035
else
Christoph Galuschka 7bc035
  arpdat='/var/lib/arpwatch/arp.dat'
Christoph Galuschka 7bc035
fi
Christoph Galuschka 7bc035
Christoph Galuschka 7bc035
# beginning and running test
Christoph Galuschka 89571c
arpwatch
Christoph Galuschka 89571c
sleep 4
Christoph Galuschka 89571c
arp -d $defgw
Christoph Galuschka 89571c
sleep 2
Christoph Galuschka 89571c
ping -q -i 0.5 -c 5 $defgw
Christoph Galuschka 89571c
killall arpwatch
Christoph Galuschka 89571c
sleep 2
Christoph Galuschka 89571c
grep -q $defgw $arpdat
Christoph Galuschka 89571c
Christoph Galuschka 89571c
t_CheckExitStatus $?
Christoph Galuschka 7bc035
Christoph Galuschka 7bc035
# cleaning up
Christoph Galuschka 7bc035
cat /dev/null > $arpdat
Christoph Galuschka 7bc035