pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37723?usp=email )


Change subject: ttcn3-tcpdump-start.sh: store multiple runs of same test into 
different pcap file
......................................................................

ttcn3-tcpdump-start.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, 36 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/23/37723/1

diff --git a/ttcn3-dumpcap-stop.sh b/ttcn3-dumpcap-stop.sh
index 188b8da..6fa586c 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.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"
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"

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37723?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ib68fc4df1f5a105b4b2c904d2d2003c621a2ad31
Gerrit-Change-Number: 37723
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-MessageType: newchange

Reply via email to