laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37723?usp=email )
Change subject: ttcn3-(tcp)dump(pcap)-stop.sh: store multiple runs of same test into different pcap file ......................................................................
ttcn3-(tcp)dump(pcap)-stop.sh: store multiple runs of same test into different pcap file
This is useful when testing the behavior of a SUT when the same scenario is run twice, for instance to debug a crash in the SUT. In this setup, it is definetly interesting to have stored pcaps of the several times the scenario is run.
Change-Id: Ib68fc4df1f5a105b4b2c904d2d2003c621a2ad31 --- M ttcn3-dumpcap-stop.sh M ttcn3-tcpdump-stop.sh 2 files changed, 22 insertions(+), 2 deletions(-)
Approvals: osmith: Looks good to me, approved laforge: Looks good to me, approved Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve
diff --git a/ttcn3-dumpcap-stop.sh b/ttcn3-dumpcap-stop.sh index 188b8da..95bcdb6 100755 --- a/ttcn3-dumpcap-stop.sh +++ b/ttcn3-dumpcap-stop.sh @@ -48,4 +48,14 @@ kill_rm_pidfile "$PIDFILE_PCAP" kill_rm_pidfile "$PIDFILE_NETCAT"
-gzip -f "$TTCN3_PCAP_PATH/$TESTCASE.pcapng" +# Add a numeral suffix to subsequent runs of the same test: +PCAP_FILENAME=$TTCN3_PCAP_PATH/$TESTCASE.pcapng +if [ -f "$TTCN3_PCAP_PATH/$TESTCASE.pcapng.gz" ]; then + i=1 + while [ -f "$TTCN3_PCAP_PATH/$TESTCASE.$i.pcapng.gz" ]; + do i=$((i+1)) + done + mv "$PCAP_FILENAME" "$TTCN3_PCAP_PATH/$TESTCASE.$i.pcapng" + PCAP_FILENAME="$TTCN3_PCAP_PATH/$TESTCASE.$i.pcapng" +fi +gzip -f "$PCAP_FILENAME" diff --git a/ttcn3-tcpdump-stop.sh b/ttcn3-tcpdump-stop.sh index 82d3a4f..0ac1b5e 100755 --- a/ttcn3-tcpdump-stop.sh +++ b/ttcn3-tcpdump-stop.sh @@ -72,4 +72,14 @@ kill_rm_pidfile "$PIDFILE_NETCAT" rm $FIFO
-gzip -f "$TTCN3_PCAP_PATH/$TESTCASE.pcap" +# Add a numeral suffix to subsequent runs of the same test: +PCAP_FILENAME=$TTCN3_PCAP_PATH/$TESTCASE.pcap +if [ -f "$TTCN3_PCAP_PATH/$TESTCASE.pcap.gz" ]; then + i=1 + while [ -f "$TTCN3_PCAP_PATH/$TESTCASE.$i.pcap.gz" ]; + do i=$((i+1)) + done + mv "$PCAP_FILENAME" "$TTCN3_PCAP_PATH/$TESTCASE.$i.pcap" + PCAP_FILENAME="$TTCN3_PCAP_PATH/$TESTCASE.$i.pcap" +fi +gzip -f "$PCAP_FILENAME"