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 c16101
#Dumping 4 pings to loopback to file
Christoph Galuschka 2e82fd
FILE='/var/tmp/lo_test.pcap'
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
Athmane Madjoudj 859bbc
ping -q -c 4 -i 0.25 127.0.0.1
Athmane Madjoudj ec845b
sleep 1
Christoph Galuschka 2e82fd
killall -s SIGINT tcpdump
Christoph Galuschka c16101
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 2e82fd
if [ $WORKING == 8 ]
Christoph Galuschka 2e82fd
  then
Christoph Galuschka 2e82fd
  ret_val=0
Christoph Galuschka 2e82fd
else
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