Change in osmo-ttcn3-hacks[master]: Print more self-explanatory error message on bind/connect failures

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu May 24 06:09:09 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9268 )

Change subject: Print more self-explanatory error message on bind/connect failures
......................................................................

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
---
M bsc-nat/MGCP_Adapter.ttcn
M bts/BTS_Tests.ttcn
M library/IPA_Emulation.ttcnpp
M library/MGCP_Emulation.ttcn
M library/NS_Emulation.ttcn
M library/RTP_Emulation.ttcn
M library/SMPP_Emulation.ttcn
M mgw/MGCP_Test.ttcn
M mgw/RTP_Endpoint.ttcn
M selftest/Selftest.ttcn
10 files changed, 68 insertions(+), 4 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/bsc-nat/MGCP_Adapter.ttcn b/bsc-nat/MGCP_Adapter.ttcn
index 1351997..6491c68 100644
--- a/bsc-nat/MGCP_Adapter.ttcn
+++ b/bsc-nat/MGCP_Adapter.ttcn
@@ -47,6 +47,10 @@
 	res := MGCP_CodecPort_CtrlFunct.f_IPL4_connect(MGCP_UDP, mp_mgw_ip, mp_mgw_udp_port,
 						mp_callagent_ip, mp_callagent_udp_port,
 						0, { udp:={} });
+	if (not ispresent(res.connId)) {
+		setverdict(fail, "Could not connect MGCP, check your configuration");
+		self.stop;
+	}
 	g_mgcp_conn_id := res.connId;
 
 	while (true) {
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index 49bf45e..bc3f186 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -396,6 +396,10 @@
 	var Result res;
 	res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, mp_bb_trxc_ip, mp_bb_trxc_port,
 							"", -1, -1, {udp:={}}, {});
+	if (not ispresent(res.connId)) {
+		setverdict(fail, "Could not connect to trx-control interface of trxcon, check your configuration");
+		self.stop;
+	}
 	g_bb_trxc_conn_id := res.connId;
 }
 
@@ -1043,6 +1047,10 @@
 	var Result res;
 	res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, mp_bb_trxc_ip, mp_bb_trxc_port,
 							"", -1, -1, {udp:={}}, {});
+	if (not ispresent(res.connId)) {
+		setverdict(fail, "Could not connect to trx-control interface of trxcon, check your configuration");
+		self.stop;
+	}
 	g_bb_trxc_conn_id := res.connId;
 }
 
diff --git a/library/IPA_Emulation.ttcnpp b/library/IPA_Emulation.ttcnpp
index be64dd1..41a3968 100644
--- a/library/IPA_Emulation.ttcnpp
+++ b/library/IPA_Emulation.ttcnpp
@@ -201,6 +201,10 @@
 	var IPL4asp_Types.Result res;
 	res := IPA_CodecPort_CtrlFunct.f_IPL4_connect(IPA_PORT, remote_host, remote_port,
 						local_host, local_port, 0, { tcp:={} });
+	if (not ispresent(res.connId)) {
+		setverdict(fail, "Could not connect IPA socket, check your configuration");
+		self.stop;
+	}
 	g_ipa_conn_id := res.connId;
 	g_ccm_pars := ccm_pars;
 	g_is_bsc_mgw := true;
@@ -212,6 +216,10 @@
 	var IPL4asp_Types.Result res;
 	res := IPA_CodecPort_CtrlFunct.f_IPL4_listen(IPA_PORT, 
 						local_host, local_port, { tcp:={} });
+	if (not ispresent(res.connId)) {
+		setverdict(fail, "Could not listen IPA socket, check your configuration");
+		self.stop;
+	}
 	g_ipa_conn_id := res.connId;
 	g_ccm_pars := ccm_pars;
 	g_is_bsc_mgw := false;
diff --git a/library/MGCP_Emulation.ttcn b/library/MGCP_Emulation.ttcn
index aaef39e..e2f79b3 100644
--- a/library/MGCP_Emulation.ttcn
+++ b/library/MGCP_Emulation.ttcn
@@ -237,7 +237,10 @@
 	} else {
 		res := MGCP_CodecPort_CtrlFunct.f_IPL4_connect(MGCP, p.callagent_ip, p.callagent_udp_port, p.mgw_ip, p.mgw_udp_port, -1, { udp:={} });
 	}
-
+	if (not ispresent(res.connId)) {
+		setverdict(fail, "Could not connect MGCP socket, check your configuration");
+		self.stop;
+	}
 	g_mgcp_conn_id := res.connId;
 
 	while (true) {
@@ -268,6 +271,10 @@
 				/* we aren't yet connected to the remote side port, let's fix this */
 				p.callagent_udp_port := mrf.remPort;
 				res := MGCP_CodecPort_CtrlFunct.f_IPL4_connect(MGCP, p.callagent_ip, p.callagent_udp_port, p.mgw_ip, p.mgw_udp_port, g_mgcp_conn_id, { udp:={} });
+				if (not ispresent(res.connId)) {
+					setverdict(fail, "Could not connect MGCP socket, check your configuration");
+					self.stop;
+				}
 			}
 			if (ischosen(mrf.msg.command)) {
 				cmd := mrf.msg.command;
diff --git a/library/NS_Emulation.ttcn b/library/NS_Emulation.ttcn
index 27acae2..d43d15c 100644
--- a/library/NS_Emulation.ttcn
+++ b/library/NS_Emulation.ttcn
@@ -81,6 +81,10 @@
 		var Result res;
 		/* Connect the UDP socket */
 		res := f_IPL4_connect(NSCP, mp_remote_ip, mp_remote_udp_port, mp_local_ip, mp_local_udp_port, 0, { udp := {}});
+		if (not ispresent(res.connId)) {
+			setverdict(fail, "Could not connect NS UDP socket, check your configuration");
+			self.stop;
+		}
 		g_conn_id := res.connId;
 		f_change_state(NSE_S_DEAD_BLOCKED);
 		/* Send the first NS-ALIVE to test the connection */
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}) {
diff --git a/library/SMPP_Emulation.ttcn b/library/SMPP_Emulation.ttcn
index 83e7801..c14340c 100644
--- a/library/SMPP_Emulation.ttcn
+++ b/library/SMPP_Emulation.ttcn
@@ -134,6 +134,10 @@
 	var IPL4asp_Types.Result res;
 	res := SMPP_CodecPort_CtrlFunct.f_IPL4_connect(SMPP_PORT, remote_host, remote_port,
 							local_host, local_port, 0, { tcp :={} });
+	if (not ispresent(res.connId)) {
+		setverdict(fail, "Could not connect to SMPP port, check your configuration");
+		self.stop;
+	}
 	g_smpp_conn_id := res.connId;
 }
 
diff --git a/mgw/MGCP_Test.ttcn b/mgw/MGCP_Test.ttcn
index c1ff3fc..1892a42 100644
--- a/mgw/MGCP_Test.ttcn
+++ b/mgw/MGCP_Test.ttcn
@@ -68,6 +68,10 @@
 			 * source/destionation ip/port and store the connection id in g_mgcp_conn_id
 			 * */
 			res := MGCP_CodecPort_CtrlFunct.f_IPL4_connect(MGCP, mp_remote_ip, mp_remote_udp_port, mp_local_ip, mp_local_udp_port, 0, { udp := {} });
+			if (not ispresent(res.connId)) {
+				setverdict(fail, "Could not connect MGCP, check your configuration");
+				self.stop;
+			}
 			g_mgcp_conn_id := res.connId;
 
 			for (var integer i := 0; i < sizeof(vc_RTPEM); i := i+1) {
diff --git a/mgw/RTP_Endpoint.ttcn b/mgw/RTP_Endpoint.ttcn
index d33423a..3c939a2 100644
--- a/mgw/RTP_Endpoint.ttcn
+++ b/mgw/RTP_Endpoint.ttcn
@@ -109,8 +109,10 @@
 
 		res := f_IPL4_connect(RTP, sub.remote_name, sub.remote_port,
 					sub.local_name, sub.local_port, sub.connection_id, { udp := {} });
-		/* FIXME: Check for success (no res.errorCode) */
-
+		if (not ispresent(res.connId)) {
+			setverdict(fail, "Could not connect RTP, check your configuration");
+			self.stop;
+		}
 		/* connect without previous bind: save conenction id allocated by IPL4asp */
 		if (sub.connection_id == -1) {
 			sub.connection_id := res.connId;
@@ -132,7 +134,10 @@
 		var Result res;
 		rtp_endpoint_sub_close(RTP, sub);
 		res := f_IPL4_listen(RTP, sub.local_name, sub.local_port, { udp := {} });
-		/* FIXME: Check for success (no res.errorCode) */
+		if (not ispresent(res.connId)) {
+			setverdict(fail, "Could not listen to RTP, check your configuration");
+			self.stop;
+		}
 		sub.connection_id := res.connId;
 	}
 
diff --git a/selftest/Selftest.ttcn b/selftest/Selftest.ttcn
index 1ff17fe..826d244 100644
--- a/selftest/Selftest.ttcn
+++ b/selftest/Selftest.ttcn
@@ -55,6 +55,10 @@
 	var Result res;
 	map(self:IP, system:IP);
 	res := IPL4asp_PortType.f_IPL4_connect(IP, "127.0.0.1", 55555, "", -1,-1, {tcp:={}});
+	if (not ispresent(res.connId)) {
+		setverdict(fail, "Could not connect to TCP port, check your configuration");
+		self.stop;
+	}
 	g_ip_conn_id := res.connId;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/9268
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id22a1b5189d81c4fca03d5e7aff60ffdd1ad56bf
Gerrit-Change-Number: 9268
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180524/0c3ff7c5/attachment.htm>


More information about the gerrit-log mailing list