aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2018-05-23 20:27:02 +0200
committerHarald Welte <laforge@gnumonks.org>2018-05-23 20:27:02 +0200
commit9220f6336e0716849ab4ebaa35b71adfe179da8d (patch)
tree4031eeb1f917c10527226bca4dd03cbae1f05173
parent898a7e06cc94de19bde28e9823a0bec6ca92a5c0 (diff)
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
-rw-r--r--bsc-nat/MGCP_Adapter.ttcn4
-rw-r--r--bts/BTS_Tests.ttcn8
-rw-r--r--library/IPA_Emulation.ttcnpp8
-rw-r--r--library/MGCP_Emulation.ttcn9
-rw-r--r--library/NS_Emulation.ttcn4
-rw-r--r--library/RTP_Emulation.ttcn16
-rw-r--r--library/SMPP_Emulation.ttcn4
-rw-r--r--mgw/MGCP_Test.ttcn4
-rw-r--r--mgw/RTP_Endpoint.ttcn11
-rw-r--r--selftest/Selftest.ttcn4
10 files changed, 68 insertions, 4 deletions
diff --git a/bsc-nat/MGCP_Adapter.ttcn b/bsc-nat/MGCP_Adapter.ttcn
index 1351997c..6491c685 100644
--- a/bsc-nat/MGCP_Adapter.ttcn
+++ b/bsc-nat/MGCP_Adapter.ttcn
@@ -47,6 +47,10 @@ function main() runs on MGCP_Adapter_CT {
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 49bf45e3..bc3f1869 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -396,6 +396,10 @@ private function f_trxc_connect() runs on ConnHdlr {
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 @@ private function f_main_trxc_connect() runs on test_CT {
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 be64dd17..41a3968d 100644
--- a/library/IPA_Emulation.ttcnpp
+++ b/library/IPA_Emulation.ttcnpp
@@ -201,6 +201,10 @@ function f_connect(charstring remote_host, IPL4asp_Types.PortNumber remote_port,
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 @@ function f_bind(charstring local_host, IPL4asp_Types.PortNumber local_port,
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 aaef39eb..e2f79b32 100644
--- a/library/MGCP_Emulation.ttcn
+++ b/library/MGCP_Emulation.ttcn
@@ -237,7 +237,10 @@ function main(MGCPOps ops, MGCP_conn_parameters p, charstring id) runs on MGCP_E
} 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 @@ function main(MGCPOps ops, MGCP_conn_parameters p, charstring id) runs on MGCP_E
/* 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 27acae27..d43d15c1 100644
--- a/library/NS_Emulation.ttcn
+++ b/library/NS_Emulation.ttcn
@@ -81,6 +81,10 @@ module NS_Emulation {
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 a3a05090..20e4299c 100644
--- a/library/RTP_Emulation.ttcn
+++ b/library/RTP_Emulation.ttcn
@@ -264,10 +264,18 @@ function f_main() runs on RTP_Emulation_CT
}
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 @@ function f_main() runs on RTP_Emulation_CT
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 83e7801f..c14340ca 100644
--- a/library/SMPP_Emulation.ttcn
+++ b/library/SMPP_Emulation.ttcn
@@ -134,6 +134,10 @@ runs on SMPP_Emulation_CT {
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 c1ff3fc9..1892a423 100644
--- a/mgw/MGCP_Test.ttcn
+++ b/mgw/MGCP_Test.ttcn
@@ -68,6 +68,10 @@ module MGCP_Test {
* 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 d33423aa..3c939a22 100644
--- a/mgw/RTP_Endpoint.ttcn
+++ b/mgw/RTP_Endpoint.ttcn
@@ -109,8 +109,10 @@ module RTP_Endpoint {
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 @@ module RTP_Endpoint {
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 1ff17fe7..826d2449 100644
--- a/selftest/Selftest.ttcn
+++ b/selftest/Selftest.ttcn
@@ -55,6 +55,10 @@ function f_tcp_client_init() runs on IPA_selftest_CT {
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;
}