|author||Pau Espin Pedrol <firstname.lastname@example.org>||2018-02-15 14:43:58 +0100|
|committer||Harald Welte <email@example.com>||2018-02-15 17:22:52 +0000|
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')
1 files changed, 10 insertions, 0 deletions
diff --git a/ttcn3-tcpdump-start.sh b/ttcn3-tcpdump-start.sh
index 664c080..10e8ab4 100755
@@ -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