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/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 */