[PATCH] osmo-ttcn3-hacks[master]: ttcn3-tcpdump-start.sh: Wait for pcap file creation to start...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Thu Feb 15 15:11:32 UTC 2018


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/6474

to look at the new patch set (#2).

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
---
M ttcn3-tcpdump-start.sh
1 file changed, 10 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/74/6474/2

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 @@
 $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

-- 
To view, visit https://gerrit.osmocom.org/6474
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I17a456a27c8e33571f333f4b7efdf61161ebb174
Gerrit-PatchSet: 2
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list