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/.
dexter gerrit-no-reply at lists.osmocom.orgdexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/19120 ) Change subject: mgcp_test: do not access endpoint array elements directly ...................................................................... mgcp_test: do not access endpoint array elements directly The test assumes that the endpoint "rtpbridge/X at mgw" is at array position X in many places. This does not necessarly have to match. Accessing the array elements directly was the prefered way when the MGW did use integer numbers and not strings to identify endpoints. Since the endpoint name strings are used to access the endpoints the unit-test should also reflect this. Lets replace the integer variable last_endpoint with a string variable and do related verifications based on strings. Change-Id: Ic950c427f23be4a792af94972554637c2b0fbdf2 Related: OS#2659 --- M tests/mgcp/mgcp_test.c 1 file changed, 31 insertions(+), 31 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/20/19120/1 diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c index 0e87c15..8c084b4 100644 --- a/tests/mgcp/mgcp_test.c +++ b/tests/mgcp/mgcp_test.c @@ -592,7 +592,7 @@ return msg; } -static int last_endpoint = -1; +static char last_endpoint[MGCP_ENDPOINT_MAXLEN]; static int mgcp_test_policy_cb(struct mgcp_endpoint *endp, int state, const char *transaction_id) @@ -604,10 +604,10 @@ state, endp->name); trunk = endp->trunk; - last_endpoint = -1; + last_endpoint[0] = '\0'; for (i = 0; i < trunk->vty_number_endpoints; i++) { if (strcmp(endp->name, trunk->endpoints[i]->name) == 0) - last_endpoint = i; + strcpy(last_endpoint, trunk->endpoints[i]->name); } return MGCP_POLICY_CONT; @@ -787,7 +787,7 @@ printf("\n================================================\n"); printf("Testing %s\n", t->name); - last_endpoint = -1; + last_endpoint[0] = '\0'; dummy_packets = 0; osmo_talloc_replace_string(cfg, &trunk->audio_fmtp_extra, @@ -822,8 +822,8 @@ if (dummy_packets) printf("Dummy packets: %d\n", dummy_packets); - if (last_endpoint != -1) { - endp = trunk->endpoints[last_endpoint]; + if (last_endpoint[0] != '\0') { + endp = mgcp_endp_by_name(NULL, last_endpoint, cfg); conn = mgcp_conn_get_rtp(endp, "1"); if (conn) { @@ -878,10 +878,10 @@ /* Check detected payload type */ if (conn && t->ptype != PTYPE_IGNORE) { - OSMO_ASSERT(last_endpoint != -1); - endp = trunk->endpoints[last_endpoint]; + OSMO_ASSERT(last_endpoint[0] != '\0'); + endp = mgcp_endp_by_name(NULL, last_endpoint, cfg); - fprintf(stderr, "endpoint 0x%x: " + fprintf(stderr, "endpoint:%s: " "payload type %d (expected %d)\n", last_endpoint, conn->end.codec->payload_type, t->ptype); @@ -1402,7 +1402,7 @@ mgcp_trunk_alloc_endpts(trunk2); /* Allocate endpoint 1 at mgw with two codecs */ - last_endpoint = -1; + last_endpoint[0] = '\0'; inp = create_msg(CRCX_MULT_1, NULL); resp = mgcp_handle_message(cfg, inp); OSMO_ASSERT(get_conn_id_from_response(resp->data, conn_id, @@ -1410,14 +1410,14 @@ msgb_free(inp); msgb_free(resp); - OSMO_ASSERT(last_endpoint == 1); - endp = trunk->endpoints[last_endpoint]; + OSMO_ASSERT(strcmp(last_endpoint,"rtpbridge/1 at mgw") == 0); + endp = mgcp_endp_by_name(NULL, last_endpoint, cfg); conn = mgcp_conn_get_rtp(endp, conn_id); OSMO_ASSERT(conn); OSMO_ASSERT(conn->end.codec->payload_type == 18); /* Allocate 2 at mgw with three codecs, last one ignored */ - last_endpoint = -1; + last_endpoint[0] = '\0'; inp = create_msg(CRCX_MULT_2, NULL); resp = mgcp_handle_message(cfg, inp); OSMO_ASSERT(get_conn_id_from_response(resp->data, conn_id, @@ -1425,8 +1425,8 @@ msgb_free(inp); msgb_free(resp); - OSMO_ASSERT(last_endpoint == 2); - endp = trunk->endpoints[last_endpoint]; + OSMO_ASSERT(strcmp(last_endpoint,"rtpbridge/2 at mgw") == 0); + endp = mgcp_endp_by_name(NULL, last_endpoint, cfg); conn = mgcp_conn_get_rtp(endp, conn_id); OSMO_ASSERT(conn); OSMO_ASSERT(conn->end.codec->payload_type == 18); @@ -1437,7 +1437,7 @@ * it makes and since we already decided in OS#2658 that a missing * LCO should pick a sane default codec, it makes sense to expect * the same behaviour if SDP lacks proper payload type information */ - last_endpoint = -1; + last_endpoint[0] = '\0'; inp = create_msg(CRCX_MULT_3, NULL); resp = mgcp_handle_message(cfg, inp); OSMO_ASSERT(get_conn_id_from_response(resp->data, conn_id, @@ -1445,14 +1445,14 @@ msgb_free(inp); msgb_free(resp); - OSMO_ASSERT(last_endpoint == 3); - endp = trunk->endpoints[last_endpoint]; + OSMO_ASSERT(strcmp(last_endpoint,"rtpbridge/3 at mgw") == 0); + endp = mgcp_endp_by_name(NULL, last_endpoint, cfg); conn = mgcp_conn_get_rtp(endp, conn_id); OSMO_ASSERT(conn); OSMO_ASSERT(conn->end.codec->payload_type == 0); /* Allocate 4 at mgw with a single codec */ - last_endpoint = -1; + last_endpoint[0] = '\0'; inp = create_msg(CRCX_MULT_4, NULL); resp = mgcp_handle_message(cfg, inp); OSMO_ASSERT(get_conn_id_from_response(resp->data, conn_id, @@ -1460,14 +1460,14 @@ msgb_free(inp); msgb_free(resp); - OSMO_ASSERT(last_endpoint == 4); - endp = trunk->endpoints[last_endpoint]; + OSMO_ASSERT(strcmp(last_endpoint,"rtpbridge/4 at mgw") == 0); + endp = mgcp_endp_by_name(NULL, last_endpoint, cfg); conn = mgcp_conn_get_rtp(endp, conn_id); OSMO_ASSERT(conn); OSMO_ASSERT(conn->end.codec->payload_type == 18); /* Allocate 5 at mgw and let osmo-mgw pick a codec from the list */ - last_endpoint = -1; + last_endpoint[0] = '\0'; inp = create_msg(CRCX_MULT_GSM_EXACT, NULL); trunk->no_audio_transcoding = 1; resp = mgcp_handle_message(cfg, inp); @@ -1476,19 +1476,19 @@ msgb_free(inp); msgb_free(resp); - OSMO_ASSERT(last_endpoint == 5); - endp = trunk->endpoints[last_endpoint]; + OSMO_ASSERT(strcmp(last_endpoint,"rtpbridge/5 at mgw") == 0); + endp = mgcp_endp_by_name(NULL, last_endpoint, cfg); conn = mgcp_conn_get_rtp(endp, conn_id); OSMO_ASSERT(conn); OSMO_ASSERT(conn->end.codec->payload_type == 0); inp = create_msg(MDCX_NAT_DUMMY, conn_id); - last_endpoint = -1; + last_endpoint[0] = '\0'; resp = mgcp_handle_message(cfg, inp); msgb_free(inp); msgb_free(resp); - OSMO_ASSERT(last_endpoint == 5); - endp = trunk->endpoints[last_endpoint]; + OSMO_ASSERT(strcmp(last_endpoint,"rtpbridge/5 at mgw") == 0); + endp = mgcp_endp_by_name(NULL, last_endpoint, cfg); conn = mgcp_conn_get_rtp(endp, conn_id); OSMO_ASSERT(conn); OSMO_ASSERT(conn->end.codec->payload_type == 3); @@ -1508,7 +1508,7 @@ conn = mgcp_conn_get_rtp(endp, conn_id); OSMO_ASSERT(!conn); - last_endpoint = -1; + last_endpoint[0] = '\0'; inp = create_msg(CRCX_MULT_GSM_EXACT, NULL); trunk->no_audio_transcoding = 0; resp = mgcp_handle_message(cfg, inp); @@ -1517,8 +1517,8 @@ msgb_free(inp); msgb_free(resp); - OSMO_ASSERT(last_endpoint == 5); - endp = trunk->endpoints[last_endpoint]; + OSMO_ASSERT(strcmp(last_endpoint,"rtpbridge/5 at mgw") == 0); + endp = mgcp_endp_by_name(NULL, last_endpoint, cfg); conn = mgcp_conn_get_rtp(endp, conn_id); OSMO_ASSERT(conn); OSMO_ASSERT(conn->end.codec->payload_type == 0); @@ -1543,7 +1543,7 @@ trunk->vty_number_endpoints = 64; mgcp_trunk_alloc_endpts(trunk); - endp = trunk->endpoints[1]; + endp = mgcp_endp_by_name(NULL, "rtpbridge/1 at mgw", cfg); _conn = mgcp_conn_alloc(NULL, endp, MGCP_CONN_TYPE_RTP, "test-connection"); -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/19120 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: Ic950c427f23be4a792af94972554637c2b0fbdf2 Gerrit-Change-Number: 19120 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200703/7d43b2ff/attachment.htm>