RTP_Emulation: Log the different failure verdicts before stopping

Change-Id: I177b2f4e56ac89fcab20ba6235bf968ac1873046
diff --git a/library/RTP_Emulation.ttcn b/library/RTP_Emulation.ttcn
index 5e10b3f..9095214 100644
--- a/library/RTP_Emulation.ttcn
+++ b/library/RTP_Emulation.ttcn
@@ -280,38 +280,49 @@
  * check that will fit most situations and  is intended to be executed by
  * the testcases as as needed. */
 function f_rtpem_stats_err_check(RtpemStats s) {
+	var boolean do_stop := false;
 	log("stats: ", s);
 
 	/* Check if there was some activity at either on the RX or on the
 	 * TX side, but complete silence would indicate some problem */
 	if (s.num_pkts_tx < 1 and s.num_pkts_rx < 1) {
 		setverdict(fail, "no RTP packet activity detected (packets)");
-		mtc.stop;
+		do_stop := true;
 	}
 	if (s.bytes_payload_tx < 1 and s.bytes_payload_rx < 1) {
 		setverdict(fail, "no RTP packet activity detected (bytes)");
-		mtc.stop;
+		do_stop := true;
 	}
 
 	/* Check error counters */
 	if (s.num_pkts_rx_err_seq != 0) {
 		setverdict(fail, log2str(s.num_pkts_rx_err_seq, " RTP packet sequence number errors occurred"));
-		mtc.stop;
+		do_stop := true;
 	}
 	if (s.num_pkts_rx_err_ts != 0) {
 		setverdict(fail, log2str(s.num_pkts_rx_err_ts, " RTP packet timestamp errors occurred"));
-		mtc.stop;
+		do_stop := true;
 	}
 	if (s.num_pkts_rx_err_pt != 0) {
 		setverdict(fail, log2str(s.num_pkts_rx_err_pt, " RTP packet payload type errors occurred"));
-		mtc.stop;
+		do_stop := true;
 	}
 	if (s.num_pkts_rx_err_disabled != 0) {
 		setverdict(fail, log2str(s.num_pkts_rx_err_disabled, " RTP packets received while RX was disabled"));
-		mtc.stop;
+		do_stop := true;
 	}
 	if (s.num_pkts_rx_err_payload != 0) {
 		setverdict(fail, log2str(s.num_pkts_rx_err_payload, " RTP packets with mismatching payload received"));
+		do_stop := true;
+	}
+
+	if (do_stop) {
+		if (self == mtc) {
+			/* Properly stop all ports before disconnecting them. This avoids
+			* running into the dynamic testcase error due to messages arriving on
+			* unconnected ports. */
+			all component.stop;
+		}
 		mtc.stop;
 	}
 }