summaryrefslogtreecommitdiffstats
path: root/ttcn3-tcpdump-start.sh
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-02-15 14:43:58 +0100
committerHarald Welte <laforge@gnumonks.org>2018-02-15 17:22:52 +0000
commitb01d313b83f2a1b6038e2ab063fe3f157deeaccc (patch)
tree331dfeaf4873d9036755f5a86f1266778561d85e /ttcn3-tcpdump-start.sh
parentef59855ac7daf06e9c780cb1000616924027ed1d (diff)
ttcn3-tcpdump-start.sh: Wait for pcap file creation to start test
It was spotted in the jenkins artficats that pcap files for some tests are missing. It is probably due to the fact that tcpdump is started in the background and immediately after the test is started. Some tests are really quick, which means they are executing before tcpdump starts creating the file and recording. While still having the file created doesn't mean tcpdump is already recording, we at least ensure the file is created and we can see it's empty at the end. Running this patch in my PC indeed shows that usually the pcap file is not created immediately after and it waits for 1 second to continue. The hack to make sure tcpdump is already recording before starting the test is to create some traffic (ie ping 127.0.0.1) and then check the following condition: $(tcpdump -r file.pcap | wc -l) -gt 0 Change-Id: I17a456a27c8e33571f333f4b7efdf61161ebb174
Diffstat (limited to 'ttcn3-tcpdump-start.sh')
-rwxr-xr-xttcn3-tcpdump-start.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/ttcn3-tcpdump-start.sh b/ttcn3-tcpdump-start.sh
index 664c080..10e8ab4 100755
--- a/ttcn3-tcpdump-start.sh
+++ b/ttcn3-tcpdump-start.sh
@@ -22,3 +22,13 @@ fi
$CMD -s 0 -n -i any -w "$TTCN3_PCAP_PATH/$TESTCASE.pcap" >$TTCN3_PCAP_PATH/$TESTCASE.pcap.log 2>&1 &
PID=$!
echo $PID > $PIDFILE
+
+# Wait until tcpdump creates the pcap file to give it some time to start listenting.
+# Timeout is 10 seconds.
+i=0
+while [ ! -f "$TTCN3_PCAP_PATH/$TESTCASE.pcap" ] && [ $i -lt 10 ]
+do
+ echo "Waiting for tcpdump to start... $i"
+ sleep 1
+ i=$((i+1))
+done