aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite-capture.sh
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2011-05-26 20:23:38 +0000
committerGerald Combs <gerald@wireshark.org>2011-05-26 20:23:38 +0000
commitc1b210c23c298f7ad22fd2c35ba80c26b02a4385 (patch)
treee2217c9578b4815f5a639d8ace52d21715574433 /test/suite-capture.sh
parenta4f53c991cf7132eb41352ae02a267758599c821 (diff)
Add a "capture from stdin" test.
svn path=/trunk/; revision=37416
Diffstat (limited to 'test/suite-capture.sh')
-rwxr-xr-xtest/suite-capture.sh36
1 files changed, 35 insertions, 1 deletions
diff --git a/test/suite-capture.sh b/test/suite-capture.sh
index dc8e775c16..5fe7983f3f 100755
--- a/test/suite-capture.sh
+++ b/test/suite-capture.sh
@@ -43,7 +43,7 @@ capture_test_output_print() {
traffic_gen_ping() {
# Generate some traffic for quiet networks.
# This will have to be adjusted for non-Windows systems.
-
+
# the following will run in the background and return immediately
{
date
@@ -199,6 +199,37 @@ capture_step_fifo() {
fi
}
+# capture packets via a fifo
+capture_step_stdin() {
+ (cat $CAPFILE; sleep 1; tail -c +25 $CAPFILE) | \
+ $DUT -i - $TRAFFIC_CAPTURE_PROMISC \
+ -w ./testout.pcap \
+ -a duration:$TRAFFIC_CAPTURE_DURATION \
+ > ./testout.txt 2>&1
+ RETURNVALUE=$?
+ if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
+ test_step_failed "exit status of $DUT: $RETURNVALUE"
+ return
+ fi
+
+ # we should have an output file now
+ if [ ! -f "./testout.pcap" ]; then
+ test_step_failed "No output file!"
+ return
+ fi
+
+ # ok, we got a capture file, does it contain exactly 8 packets?
+ $CAPINFOS ./testout.pcap > ./testout.txt
+ grep -Ei 'Number of packets:[[:blank:]]+8' ./testout.txt > /dev/null
+ if [ $? -eq 0 ]; then
+ test_step_ok
+ else
+ echo
+ cat ./testout.txt
+ test_step_failed "No or not enough traffic captured."
+ fi
+}
+
# capture exactly 2 times 10 packets (multiple files)
capture_step_2multi_10packets() {
if [ $SKIP_CAPTURE -ne 0 ] ; then
@@ -356,6 +387,7 @@ wireshark_capture_suite() {
# read filter doesn't work with Wireshark and capturing!
#test_step_add "Capture read filter (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_read_filter
test_step_add "Capture snapshot length 68 bytes (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_snapshot
+ test_step_add "Capture via stdin" capture_step_stdin
}
tshark_capture_suite() {
@@ -365,6 +397,7 @@ tshark_capture_suite() {
if [ $TEST_FIFO ]; then
test_step_add "Capture via fifo" capture_step_fifo
fi
+ test_step_add "Capture via stdin" capture_step_stdin
# tshark now using dumpcap for capturing, read filters won't work by definition
#test_step_add "Capture read filter (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_read_filter
test_step_add "Capture snapshot length 68 bytes (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_snapshot
@@ -378,6 +411,7 @@ dumpcap_capture_suite() {
if [ $TEST_FIFO ]; then
test_step_add "Capture via fifo" capture_step_fifo
fi
+ test_step_add "Capture via stdin" capture_step_stdin
# read (display) filters intentionally doesn't work with dumpcap!
#test_step_add "Capture read filter (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_read_filter
test_step_add "Capture snapshot length 68 bytes (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_snapshot