aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/mgcp/mgcp_test.c16
-rw-r--r--openbsc/tests/mgcp/mgcp_test.ok6
2 files changed, 14 insertions, 8 deletions
diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c
index b2d20b45b..d36aaa8c6 100644
--- a/openbsc/tests/mgcp/mgcp_test.c
+++ b/openbsc/tests/mgcp/mgcp_test.c
@@ -417,7 +417,7 @@ static void test_packet_error_detection(void)
struct mgcp_trunk_config trunk;
struct mgcp_endpoint endp;
struct mgcp_rtp_state state;
- struct mgcp_rtp_end rtp;
+ struct mgcp_rtp_end *rtp = &endp.net_end;
struct sockaddr_in addr = {0};
char buffer[4096];
@@ -426,14 +426,20 @@ static void test_packet_error_detection(void)
memset(&trunk, 0, sizeof(trunk));
memset(&endp, 0, sizeof(endp));
memset(&state, 0, sizeof(state));
- memset(&rtp, 0, sizeof(rtp));
trunk.number_endpoints = 1;
trunk.endpoints = &endp;
+ endp.tcfg = &trunk;
+
+ /* This doesn't free endp but resets/frees all fields of the structure
+ * and invokes mgcp_rtp_end_reset() for each mgcp_rtp_end. OTOH, it
+ * expects valid pointer fields (either NULL or talloc'ed), so the
+ * memset is still needed. It also requires that endp.tcfg and
+ * trunk.endpoints are set up properly. */
+ mgcp_free_endp(&endp);
- rtp.payload_type = 98;
+ rtp->payload_type = 98;
endp.allow_patch = 1;
- endp.tcfg = &trunk;
for (i = 0; i < ARRAY_SIZE(test_rtp_packets1); ++i) {
struct rtp_packet_info *info = test_rtp_packets1 + i;
@@ -442,7 +448,7 @@ static void test_packet_error_detection(void)
OSMO_ASSERT(info->len >= 0);
memmove(buffer, info->data, info->len);
- mgcp_patch_and_count(&endp, &state, &rtp, &addr,
+ mgcp_patch_and_count(&endp, &state, rtp, &addr,
buffer, info->len);
printf("TS: %d, dTS: %d, TS Errs: in %d, out %d\n",
diff --git a/openbsc/tests/mgcp/mgcp_test.ok b/openbsc/tests/mgcp/mgcp_test.ok
index 8c3fa266b..5666424bd 100644
--- a/openbsc/tests/mgcp/mgcp_test.ok
+++ b/openbsc/tests/mgcp/mgcp_test.ok
@@ -41,7 +41,7 @@ TS: 1280, dTS: 160, TS Errs: in 3, out 3
TS: 1400, dTS: 120, TS Errs: in 4, out 4
TS: 1560, dTS: 160, TS Errs: in 5, out 5
TS: 1720, dTS: 160, TS Errs: in 5, out 5
-TS: 1720, dTS: 160, TS Errs: in 5, out 6
-TS: 1880, dTS: 160, TS Errs: in 5, out 6
-TS: 2040, dTS: 160, TS Errs: in 5, out 6
+TS: 1880, dTS: 160, TS Errs: in 5, out 5
+TS: 2040, dTS: 160, TS Errs: in 5, out 5
+TS: 2200, dTS: 160, TS Errs: in 5, out 5
Done