ttcn3-tcpdump-stop.sh: order the SUT to print talloc report

The idea is to generate a talloc report after execution of a test
case and store it together with PCAP files.  This might be useful
for detecting memory leaks and finding the relevant test cases.

To enable this feature, make sure that osmo_interact_vty.py from
osmo-python-tests is installed (see [1]), and the following
variables are set (see [2]):

* OSMO_SUT_HOST (e.g. "127.0.0.1"), and
* OSMO_SUT_PORT (e.g. 4242).

Change-Id: I1b03b17426d8760c55976e3b78ca2f3af248c055
Depends: [1] Ida8e08e7fe4f171f934a2d4eef4568da7c398f5c
Related: [2] Icd4c2d80db934535d499598282ed9416d8088163
Related: OS#5328
diff --git a/ttcn3-tcpdump-stop.sh b/ttcn3-tcpdump-stop.sh
index b2a3a3e..4fbc53f 100755
--- a/ttcn3-tcpdump-stop.sh
+++ b/ttcn3-tcpdump-stop.sh
@@ -32,6 +32,19 @@
 	TTCN3_PCAP_PATH=/tmp
 fi
 
+# Order the SUT to print a talloc report
+if [ "z$OSMO_SUT_HOST" != "z" ] && [ "z$OSMO_SUT_PORT" != "z" ]; then
+	if [ -x "$(command -v osmo_interact_vty.py)" ]; then
+		osmo_interact_vty.py \
+			-H $OSMO_SUT_HOST -p $OSMO_SUT_PORT \
+			-c "en; show talloc-context application full" \
+				> "$TTCN3_PCAP_PATH/$TESTCASE.talloc"
+	else
+		echo "Missing osmo_interact_vty.py from osmo-python-tests!"
+		echo " -> Unable to obtain talloc report from the SUT"
+	fi
+fi
+
 # Wait for up to 2 seconds if we keep receiving traffinc from packet dumper,
 # otherwise we might lose last packets from test.
 i=0