aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-03-16 09:53:49 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2012-03-16 10:21:29 +0100
commitd77023b1c2f7faca914b4d0401cf08980d3e038e (patch)
tree19408d105690336cd6658777f7dfdcd8a1abc7ce
parent5563e6c26848e7577e5aecd5d5ab610a92896acc (diff)
mgcp_test: Add wrong messages as input and check what happens
Test parsing some invalid messages and see if we start to crash.
-rw-r--r--openbsc/tests/mgcp/mgcp_test.c20
-rw-r--r--openbsc/tests/mgcp/mgcp_test.ok12
2 files changed, 30 insertions, 2 deletions
diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c
index 6e0df753d..d151ebb1f 100644
--- a/openbsc/tests/mgcp/mgcp_test.c
+++ b/openbsc/tests/mgcp/mgcp_test.c
@@ -28,6 +28,16 @@
#define AUEP1_RET "200 158663169 OK\r\n"
#define AUEP2 "AUEP 18983213 ds/e1-2/1@172.16.6.66 MGCP 1.0\r\n"
#define AUEP2_RET "500 18983213 FAIL\r\n"
+#define EMPTY "\r\n"
+#define EMPTY_RET NULL
+#define SHORT "CRCX \r\n"
+#define SHORT_RET "510 000000 FAIL\r\n"
+
+#define SHORT2 "CRCX 1"
+#define SHORT2_RET "510 000000 FAIL\r\n"
+#define SHORT3 "CRCX 1 1@mgw"
+#define SHORT4 "CRCX 1 1@mgw MGCP"
+#define SHORT5 "CRCX 1 1@mgw MGCP 1.0"
#define CRCX "CRCX 2 1@mgw MGCP 1.0\r\n" \
"M: sendrecv\r\n" \
@@ -68,6 +78,11 @@ const struct mgcp_test tests[] = {
{ "AUEP2", AUEP2, AUEP2_RET },
{ "CRCX", CRCX, CRCX_RET },
{ "CRCX_ZYN", CRCX_ZYN, CRCX_RET },
+ { "EMPTY", EMPTY, EMPTY_RET },
+ { "SHORT1", SHORT, SHORT_RET },
+ { "SHORT2", SHORT2, SHORT2_RET },
+ { "SHORT3", SHORT3, SHORT2_RET },
+ { "SHORT4", SHORT4, SHORT2_RET },
};
static struct msgb *create_msg(const char *str)
@@ -102,7 +117,10 @@ static void test_messages(void)
inp = create_msg(t->req);
msg = mgcp_handle_message(cfg, inp);
msgb_free(inp);
- if (strcmp((char *) msg->data, t->exp_resp) != 0)
+ if (!t->exp_resp) {
+ if (msg)
+ printf("%s failed '%s'\n", t->name, (char *) msg->data);
+ } else if (strcmp((char *) msg->data, t->exp_resp) != 0)
printf("%s failed '%s'\n", t->name, (char *) msg->data);
msgb_free(msg);
}
diff --git a/openbsc/tests/mgcp/mgcp_test.ok b/openbsc/tests/mgcp/mgcp_test.ok
index 1a01c28a8..092c96913 100644
--- a/openbsc/tests/mgcp/mgcp_test.ok
+++ b/openbsc/tests/mgcp/mgcp_test.ok
@@ -1,2 +1,12 @@
-Testing AUEP
+Testing AUEP1
+Testing AUEP2
+Testing CRCX
+Testing CRCX_ZYN
+CRCX_ZYN failed '400 2 FAIL
+'
+Testing EMPTY
+Testing SHORT1
+Testing SHORT2
+Testing SHORT3
+Testing SHORT4
Done