pespin has uploaded this change for review.

View Change

library/MGCP_Emulation: Fix Dynamic test case error returning unbound value

As spotted today while running HNBGW_Tests.TC_rab_assignment, probably after upgrade to titan 11:
17:54:36.223786 1570 MGCP_Emulation.ttcn:241 Dynamic test case error: Copying an unbound charstring value.

The error happened because in that failure path the component running
the function was not stopped, and hence an unset variable was returned.
Hence, make sure we tear everything down (including component going
through the failure path).

Change-Id: Id1d28924e90ed80199b61a143dac35fc6f50de68
---
M library/MGCP_Emulation.ttcn
1 file changed, 29 insertions(+), 24 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/17/40417/1
diff --git a/library/MGCP_Emulation.ttcn b/library/MGCP_Emulation.ttcn
index 7106f63..8dd3d3f 100644
--- a/library/MGCP_Emulation.ttcn
+++ b/library/MGCP_Emulation.ttcn
@@ -35,6 +35,7 @@
import from MGCP_Templates all;
import from Osmocom_Types all;
import from IPL4asp_Types all;
+import from Misc_Helpers all;

type component MGCP_ConnHdlr {
/* Simple send/recv without caring about peer addr+port. Used with multi_conn_mode=false. */
@@ -149,8 +150,9 @@
return MgcpEndpointTable[i].comp_ref;
}
}
- setverdict(fail, "MGCP Endpoint Table not found by Endpoint", ep);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+ log2str("MGCP Endpoint Table not found by Endpoint", ep));
+ return MgcpEndpointTable[0].comp_ref; /* Make compiler happy returning something */
}

private function f_ep_by_comp(MGCP_ConnHdlr client)
@@ -161,8 +163,9 @@
return MgcpEndpointTable[i].endpoint;
}
}
- setverdict(fail, "MGCP Endpoint Table not found by component ", client);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+ log2str("MGCP Endpoint Table not found by component ", client));
+ return MgcpEndpointTable[0].endpoint; /* Make compiler happy returning something */
}

private function f_ep_table_add(MGCP_ConnHdlr comp_ref, MgcpEndpoint ep)
@@ -175,7 +178,7 @@
return;
}
}
- testcase.stop("MGCP Endpoint Table full!");
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "MGCP Endpoint Table full!");
}

private function f_ep_table_del(MGCP_ConnHdlr comp_ref, MgcpEndpoint ep)
@@ -189,8 +192,8 @@
return;
}
}
- setverdict(fail, "MGCP Endpoint Table: Couldn't find to-be-deleted entry!");
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+ log2str("MGCP Endpoint Table: Couldn't find to-be-deleted entry!"));
}

private function f_ep_table_change_connhdlr(MGCP_ConnHdlr comp_ref, MgcpEndpoint ep)
@@ -203,8 +206,8 @@
return;
}
}
- setverdict(fail, "MGCP Endpoint Table: Couldn't find entry to move to ", comp_ref);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+ log2str("MGCP Endpoint Table: Couldn't find entry to move to ", comp_ref));
}

/* Check if the given transaction ID is a pending CRCX. If yes, return true + remove */
@@ -235,8 +238,8 @@
} else {
var MgcpEndpoint ep;
if (f_mgcp_find_param(msg, "Z", ep) == false) {
- setverdict(fail, "No SpecificEndpointName in MGCP response", msg);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+ log2str("No SpecificEndpointName in MGCP response", msg));
}
return ep;
}
@@ -280,8 +283,8 @@
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");
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+ log2str("Could not connect MGCP socket, check your configuration"));
}
g_mgcp_conn_id := res.connId;

@@ -329,8 +332,8 @@
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");
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+ log2str("Could not connect MGCP socket, check your configuration"));
}
}
if (ischosen(mrf.msg.command)) {
@@ -358,8 +361,8 @@
}
}
} else {
- setverdict(fail, "Received unexpected MGCP response: ", mrf.msg.response);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+ log2str("Received unexpected MGCP response: ", mrf.msg.response));
}
}
[] MGCP_PROC.getcall(MGCPEM_register:{?,?}) -> param(crit, vc_conn) {
@@ -448,8 +451,9 @@
return ret;
}
}
- setverdict(fail, "Couldn't find Expect for CRCX", cmd);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+ log2str("Couldn't find Expect for CRCX", cmd));
+ return MgcpExpectTable[0].vc_conn; /* Make compiler happy returning something */
}

private function f_create_expect(ExpectCriteria crit, MGCP_ConnHdlr hdlr)
@@ -459,8 +463,8 @@
/* Check an entry like this is not already present */
for (i := 0; i < sizeof(MgcpExpectTable); i := i+1) {
if (crit == MgcpExpectTable[i].crit) {
- setverdict(fail, "Crit already present", crit);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+ log2str("Crit already present", crit));
}
}
for (i := 0; i < sizeof(MgcpExpectTable); i := i+1) {
@@ -471,7 +475,7 @@
return;
}
}
- testcase.stop("No space left in MgcpExpectTable")
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No space left in MgcpExpectTable");
}

/* client/conn_hdlr side function to use procedure port to create expect in emulation */
@@ -528,8 +532,9 @@
return "AMR-WB";
}

- setverdict(fail, "Unknown payload type ", pt);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+ log2str("Unknown payload type ", pt));
+ return "";
}

}

To view, visit change 40417. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Id1d28924e90ed80199b61a143dac35fc6f50de68
Gerrit-Change-Number: 40417
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>