From c161015ba84181d2b9f27ee709c61d4e22ff61ba Mon Sep 17 00:00:00 2001 From: Christoph Galuschka Date: Nov 17 2011 10:18:44 +0000 Subject: Added install and function test for tcpdump --- diff --git a/tests/p_tcpdump/0_install_tcpdump.sh b/tests/p_tcpdump/0_install_tcpdump.sh new file mode 100755 index 0000000..f64d244 --- /dev/null +++ b/tests/p_tcpdump/0_install_tcpdump.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# Author: Christoph Galuschka + +# Install tcpdump +t_InstallPackage tcpdump + diff --git a/tests/p_tcpdump/tcpdump_test.sh b/tests/p_tcpdump/tcpdump_test.sh new file mode 100755 index 0000000..0a1e9e1 --- /dev/null +++ b/tests/p_tcpdump/tcpdump_test.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# Author: Christoph Galuschka + +t_Log "Running $0 - TCPdump test" + +#Dumping 4 pings to loopback to file +tcpdump -n -p -i lo -w /var/tmp/centos_test.pcap & +# If we don't wait a short time, the first paket will be missed by tcpdump +sleep 1 +ping -c 4 -i 0.25 127.0.0.1 +killall tcpdump + +# reading from file, for each ping we should see two pakets +WORKING=$(tcpdump -r /var/tmp/centos_test.pcap | grep -ci icmp) +if [ $WORKING == 8 ]; then ret_val=0; fi + +# Remove file afterwards +/bin/rm /var/tmp/centos_test.pcap + +t_CheckExitStatus $?