[MERGED] osmo-mgw[master]: mgcp_client: show failure by MGCP SDP section parsing test

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Feb 22 07:56:01 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: mgcp_client: show failure by MGCP SDP section parsing test
......................................................................


mgcp_client: show failure by MGCP SDP section parsing test

To show how the current code fails, add test_sdp_section_start() to
mgcp_client_test.c, and temporarily accept failing output. This will be fixed
in change I62a2453cd9e2e7d5408423161fa65ec9c9989f98.

Change-Id: I5c6d3566b8f6dbf04c0cd8b127423f5295c19f8d
---
M tests/mgcp_client/mgcp_client_test.c
M tests/mgcp_client/mgcp_client_test.err
M tests/mgcp_client/mgcp_client_test.ok
3 files changed, 180 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved; Verified



diff --git a/tests/mgcp_client/mgcp_client_test.c b/tests/mgcp_client/mgcp_client_test.c
index ef2fca8..588b313 100644
--- a/tests/mgcp_client/mgcp_client_test.c
+++ b/tests/mgcp_client/mgcp_client_test.c
@@ -271,6 +271,111 @@
 	fprintf(stderr, "%s() done\n", __func__);
 }
 
+struct sdp_section_start_test {
+	const char *body;
+	int expect_rc;
+	struct mgcp_response expect_params;
+};
+
+static struct sdp_section_start_test sdp_section_start_tests[] = {
+	{
+		.body = "",
+		.expect_rc = -EINVAL,
+	},
+	{
+		.body = "\n\n",
+	},
+	{
+		.body = "\r\n\r\n",
+	},
+	{
+		.body = "\n\r\n\r",
+	},
+	{
+		.body = "some mgcp header data\r\nand header params"
+			"\n\n"
+			"m=audio 23\r\n",
+		.expect_params = {
+			.audio_port = 23,
+		},
+	},
+	{
+		.body = "some mgcp header data\r\nand header params"
+			"\r\n\r\n"
+			"m=audio 23\r\n",
+		.expect_params = {
+			.audio_port = 23,
+		},
+	},
+	{
+		.body = "some mgcp header data\r\nand header params"
+			"\n\r\n\r"
+			"m=audio 23\r\n",
+		.expect_params = {
+			.audio_port = 23,
+		},
+	},
+	{
+		.body = "some mgcp header data\r\nand header params"
+			"\n\r\n"
+			"m=audio 23\r\n",
+		.expect_rc = -EINVAL,
+	},
+	{
+		.body = "some mgcp header data\r\nand header params"
+			"\r\n\r"
+			"m=audio 23\r\n",
+		.expect_rc = -EINVAL,
+	},
+	{
+		.body = "some mgcp header data\r\nand header params"
+			"\n\r\r"
+			"m=audio 23\r\n",
+		.expect_rc = -EINVAL,
+	},
+};
+
+void test_sdp_section_start()
+{
+	int i;
+	int failures = 0;
+
+	for (i = 0; i < ARRAY_SIZE(sdp_section_start_tests); i++) {
+		int rc;
+		struct sdp_section_start_test *t = &sdp_section_start_tests[i];
+		struct mgcp_response *r = talloc_zero(ctx, struct mgcp_response);
+
+		r->body = talloc_strdup(r, t->body);
+
+		printf("\n%s() test [%d]:\n", __func__, i);
+		fprintf(stderr, "\n%s() test [%d]:\n", __func__, i);
+		fprintf(stderr, "body: \"%s\"\n", osmo_escape_str(r->body, -1));
+
+		rc = mgcp_response_parse_params(r);
+
+		fprintf(stderr, "got rc=%d\n", rc);
+		if (rc != t->expect_rc) {
+			fprintf(stderr, "FAIL: Expected rc=%d\n", t->expect_rc);
+			failures++;
+		}
+		if (rc) {
+			talloc_free(r);
+			continue;
+		}
+
+		fprintf(stderr, "got audio_port=%u\n", t->expect_params.audio_port);
+		if (r->audio_port != t->expect_params.audio_port) {
+			fprintf(stderr, "FAIL: Expected audio_port=%u\n", t->expect_params.audio_port);
+			failures++;
+		}
+		talloc_free(r);
+	}
+
+	/* Expecting failures due to known bugs, will be resolved in a subsequent commit.
+	OSMO_ASSERT(!failures);
+	*/
+}
+
 static const struct log_info_cat log_categories[] = {
 };
 
@@ -297,6 +402,7 @@
 	test_crcx();
 	test_mgcp_msg();
 	test_mgcp_client_cancel();
+	test_sdp_section_start();
 
 	printf("Done\n");
 	fprintf(stderr, "Done\n");
diff --git a/tests/mgcp_client/mgcp_client_test.err b/tests/mgcp_client/mgcp_client_test.err
index 8e9f648..9079c27 100644
--- a/tests/mgcp_client/mgcp_client_test.err
+++ b/tests/mgcp_client/mgcp_client_test.err
@@ -12,4 +12,58 @@
 - canceling again does nothing
 DLMGCP Cannot cancel, no such transaction: 1
 test_mgcp_client_cancel() done
+
+test_sdp_section_start() test [0]:
+body: ""
+got rc=0
+FAIL: Expected rc=-22
+got audio_port=0
+
+test_sdp_section_start() test [1]:
+body: "\n\n"
+got rc=0
+got audio_port=0
+
+test_sdp_section_start() test [2]:
+body: "\r\n\r\n"
+got rc=0
+got audio_port=0
+
+test_sdp_section_start() test [3]:
+body: "\n\r\n\r"
+got rc=0
+got audio_port=0
+
+test_sdp_section_start() test [4]:
+body: "some mgcp header data\r\nand header params\n\nm=audio 23\r\n"
+got rc=0
+got audio_port=23
+
+test_sdp_section_start() test [5]:
+body: "some mgcp header data\r\nand header params\r\n\r\nm=audio 23\r\n"
+got rc=0
+got audio_port=23
+
+test_sdp_section_start() test [6]:
+body: "some mgcp header data\r\nand header params\n\r\n\rm=audio 23\r\n"
+got rc=0
+got audio_port=23
+
+test_sdp_section_start() test [7]:
+body: "some mgcp header data\r\nand header params\n\r\nm=audio 23\r\n"
+got rc=0
+FAIL: Expected rc=-22
+got audio_port=0
+
+test_sdp_section_start() test [8]:
+body: "some mgcp header data\r\nand header params\r\n\rm=audio 23\r\n"
+got rc=0
+FAIL: Expected rc=-22
+got audio_port=0
+
+test_sdp_section_start() test [9]:
+body: "some mgcp header data\r\nand header params\n\r\rm=audio 23\r\n"
+got rc=0
+FAIL: Expected rc=-22
+got audio_port=0
 Done
diff --git a/tests/mgcp_client/mgcp_client_test.ok b/tests/mgcp_client/mgcp_client_test.ok
index 4dc89b8..fc6db30 100644
--- a/tests/mgcp_client/mgcp_client_test.ok
+++ b/tests/mgcp_client/mgcp_client_test.ok
@@ -82,4 +82,24 @@
 v=0
 
 -----
+
+test_sdp_section_start() test [0]:
+
+test_sdp_section_start() test [1]:
+
+test_sdp_section_start() test [2]:
+
+test_sdp_section_start() test [3]:
+
+test_sdp_section_start() test [4]:
+
+test_sdp_section_start() test [5]:
+
+test_sdp_section_start() test [6]:
+
+test_sdp_section_start() test [7]:
+
+test_sdp_section_start() test [8]:
+
+test_sdp_section_start() test [9]:
 Done

-- 
To view, visit https://gerrit.osmocom.org/6638
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5c6d3566b8f6dbf04c0cd8b127423f5295c19f8d
Gerrit-PatchSet: 2
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list