path: root/
diff options
authorPau Espin Pedrol <>2018-02-15 14:43:58 +0100
committerHarald Welte <>2018-02-15 17:22:52 +0000
commitb01d313b83f2a1b6038e2ab063fe3f157deeaccc (patch)
tree331dfeaf4873d9036755f5a86f1266778561d85e /
parentef59855ac7daf06e9c780cb1000616924027ed1d (diff) 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 and then check the following condition: $(tcpdump -r file.pcap | wc -l) -gt 0 Change-Id: I17a456a27c8e33571f333f4b7efdf61161ebb174
Diffstat (limited to '')
1 files changed, 10 insertions, 0 deletions
diff --git a/ b/
index 664c080..10e8ab4 100755
--- a/
+++ b/
@@ -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 &
echo $PID > $PIDFILE
+# Wait until tcpdump creates the pcap file to give it some time to start listenting.
+# Timeout is 10 seconds.
+while [ ! -f "$TTCN3_PCAP_PATH/$TESTCASE.pcap" ] && [ $i -lt 10 ]
+ echo "Waiting for tcpdump to start... $i"
+ sleep 1
+ i=$((i+1))