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
This commit is contained in:
parent
ef59855ac7
commit
b01d313b83
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue