Blame tests/p_tcpdump/tcpdump_lo.sh

Christoph Galuschka c16101
#!/bin/sh
Christoph Galuschka dae1aa
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Athmane Madjoudj 859bbc
#         Athmane Madjoudj <athmanem@gmail.com>
Christoph Galuschka c16101
Christoph Galuschka 2e82fd
t_Log "Running $0 - TCPdump test to lo"
Christoph Galuschka c16101
Christoph Galuschka adb04e
#Dumping pings to loopback to file
Christoph Galuschka 2e82fd
FILE='/var/tmp/lo_test.pcap'
Christoph Galuschka adb04e
COUNT='4'
Christoph Galuschka 2e82fd
Christoph Galuschka 2e82fd
tcpdump -q -n -p -i lo -w $FILE &
Christoph Galuschka c16101
# If we don't wait a short time, the first paket will be missed by tcpdump
Christoph Galuschka c16101
sleep 1
Christoph Galuschka adb04e
ping -q -c $COUNT -i 0.25 127.0.0.1
Athmane Madjoudj ec845b
sleep 1
Christoph Galuschka 2e82fd
killall -s SIGINT tcpdump
Athmane Madjoudj 848fa1
sleep 1
Christoph Galuschka c16101
# reading from file, for each ping we should see two pakets
Christoph Galuschka 2e82fd
WORKING=$( tcpdump -r $FILE | grep -ci icmp )
Christoph Galuschka adb04e
if [ $WORKING == $[COUNT*2] ]
Christoph Galuschka 2e82fd
  then
Christoph Galuschka 2e82fd
  ret_val=0
Christoph Galuschka 2e82fd
else
Christoph Galuschka adb04e
  t_Log "ping to loopback droped pakets!! This should not happen on loopback"
Christoph Galuschka 2e82fd
  ret_val=1
Christoph Galuschka 2e82fd
fi
Christoph Galuschka c16101
Christoph Galuschka c16101
# Remove file afterwards
Christoph Galuschka 2e82fd
/bin/rm $FILE
Christoph Galuschka c16101
Athmane Madjoudj 7f72f6
t_CheckExitStatus $ret_val