Print more self-explanatory error message on bind/connect failures
When sockets cannot be bound or connected, the existing TTCN-3 code prints
the following rather cryptic error messages:
"IPA-CTRL-IPA(47)@f70ff1fd5cfd: Dynamic test case error: Using the value of an optional field containing omit. (Transport endpoint is not connected)"
The "Transport endpoint is not connected" sort-of gives it away, but
let's make it more explicit by introducing explicit checks for the
res.connId and manual setverdict(fail) statements with proper error
message.
Change-Id: Id22a1b5189d81c4fca03d5e7aff60ffdd1ad56bf
diff --git a/library/RTP_Emulation.ttcn b/library/RTP_Emulation.ttcn
index a3a0509..20e4299 100644
--- a/library/RTP_Emulation.ttcn
+++ b/library/RTP_Emulation.ttcn
@@ -264,10 +264,18 @@
}
res := RTP_CodecPort_CtrlFunct.f_IPL4_listen(RTP, g_local_host,
g_local_port, {udp:={}});
+ if (not ispresent(res.connId)) {
+ setverdict(fail, "Could not listen on RTP socket, check your configuration");
+ self.stop;
+ }
g_rtp_conn_id := res.connId;
tr_rtp.connId := g_rtp_conn_id;
res := RTP_CodecPort_CtrlFunct.f_IPL4_listen(RTCP, g_local_host,
g_local_port+1, {udp:={}});
+ if (not ispresent(res.connId)) {
+ setverdict(fail, "Could not listen on RTCP socket, check your configuration");
+ self.stop;
+ }
g_rtcp_conn_id := res.connId;
tr_rtcp.connId := g_rtcp_conn_id;
CTRL.reply(RTPEM_bind:{g_local_host, g_local_port});
@@ -282,10 +290,18 @@
g_remote_port,
g_local_host, g_local_port,
g_rtp_conn_id, {udp:={}});
+ if (not ispresent(res.connId)) {
+ setverdict(fail, "Could not connect to RTP socket, check your configuration");
+ self.stop;
+ }
res := RTP_CodecPort_CtrlFunct.f_IPL4_connect(RTCP, g_remote_host,
g_remote_port+1,
g_local_host, g_local_port+1,
g_rtcp_conn_id, {udp:={}});
+ if (not ispresent(res.connId)) {
+ setverdict(fail, "Could not connect to RTCP socket, check your configuration");
+ self.stop;
+ }
CTRL.reply(RTPEM_connect:{g_remote_host, g_remote_port});
}
[] CTRL.getcall(RTPEM_mode:{RTPEM_MODE_NONE}) {