summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-06-23 01:03:52 +0000
committerBenny Prijono <bennylp@teluu.com>2006-06-23 01:03:52 +0000
commitb864212caad9d232f327c9c16a819fecfff65d30 (patch)
tree133aa88dbf0ed1bd61b806196eb80d1b8df47322 /pjsip
parenta7eb9cce74d1af7f73323459392ac3335e6083ac (diff)
Fixed pjsip-test and added msg_err_test.c for testing parsing errors
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@547 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/build/pjsip.dsw42
-rw-r--r--pjsip/build/test_pjsip.dsp4
-rw-r--r--pjsip/src/test-pjsip/msg_err_test.c100
-rw-r--r--pjsip/src/test-pjsip/msg_logger.c1
-rw-r--r--pjsip/src/test-pjsip/test.c23
-rw-r--r--pjsip/src/test-pjsip/test.h1
-rw-r--r--pjsip/src/test-pjsip/transport_test.c2
-rw-r--r--pjsip/src/test-pjsip/tsx_uac_test.c2
-rw-r--r--pjsip/src/test-pjsip/tsx_uas_test.c2
9 files changed, 120 insertions, 57 deletions
diff --git a/pjsip/build/pjsip.dsw b/pjsip/build/pjsip.dsw
index e9321084..06c45c2f 100644
--- a/pjsip/build/pjsip.dsw
+++ b/pjsip/build/pjsip.dsw
@@ -105,45 +105,6 @@ Package=<4>
###############################################################################
-Project: "pjsua"=.\pjsua.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name pjsip_core
- End Project Dependency
- Begin Project Dependency
- Project_Dep_Name pjsip_ua
- End Project Dependency
- Begin Project Dependency
- Project_Dep_Name pjlib
- End Project Dependency
- Begin Project Dependency
- Project_Dep_Name pjmedia
- End Project Dependency
- Begin Project Dependency
- Project_Dep_Name pjsdp
- End Project Dependency
- Begin Project Dependency
- Project_Dep_Name pjmedia_codec
- End Project Dependency
- Begin Project Dependency
- Project_Dep_Name pjlib_util
- End Project Dependency
- Begin Project Dependency
- Project_Dep_Name pjsip_simple
- End Project Dependency
- Begin Project Dependency
- Project_Dep_Name pjsua_lib
- End Project Dependency
-}}}
-
-###############################################################################
-
Project: "pjsua_lib"=.\pjsua_lib.dsp - Package Owner=<4>
Package=<5>
@@ -170,6 +131,9 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name pjsip_core
End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name pjlib_util
+ End Project Dependency
}}}
###############################################################################
diff --git a/pjsip/build/test_pjsip.dsp b/pjsip/build/test_pjsip.dsp
index 213bad05..bdf1a72d 100644
--- a/pjsip/build/test_pjsip.dsp
+++ b/pjsip/build/test_pjsip.dsp
@@ -97,6 +97,10 @@ SOURCE="..\src\test-pjsip\main.c"
# End Source File
# Begin Source File
+SOURCE="..\src\test-pjsip\msg_err_test.c"
+# End Source File
+# Begin Source File
+
SOURCE="..\src\test-pjsip\msg_logger.c"
# End Source File
# Begin Source File
diff --git a/pjsip/src/test-pjsip/msg_err_test.c b/pjsip/src/test-pjsip/msg_err_test.c
new file mode 100644
index 00000000..c52c6ebf
--- /dev/null
+++ b/pjsip/src/test-pjsip/msg_err_test.c
@@ -0,0 +1,100 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include "test.h"
+#include <pjsip.h>
+#include <pjlib.h>
+
+#define THIS_FILE "msg_err_test.c"
+
+
+static pj_bool_t verify_success(pjsip_msg *msg,
+ pjsip_parser_err_report *err_list)
+{
+ return PJ_TRUE;
+}
+
+static struct test_entry
+{
+ char msg[1024];
+ pj_bool_t (*verify)(pjsip_msg *msg,
+ pjsip_parser_err_report *err_list);
+
+} test_entries[] =
+{
+ /* Syntax error in status line */
+ {
+ "SIP/2.0 200\r\n"
+ "H-Name: H-Value\r\n"
+ "\r\n",
+ &verify_success
+ },
+
+ /* Syntax error in header */
+ {
+ "SIP/2.0 200 OK\r\n"
+ "Via: SIP/2.0\r\n"
+ "H-Name: H-Value\r\n"
+ "\r\n",
+ &verify_success
+ },
+
+ /* Multiple syntax errors in headers */
+ {
+ "SIP/2.0 200 OK\r\n"
+ "Via: SIP/2.0\r\n"
+ "H-Name: H-Value\r\n"
+ "Via: SIP/2.0\r\n"
+ "\r\n",
+ &verify_success
+ }
+};
+
+
+int msg_err_test(void)
+{
+ pj_pool_t *pool;
+ unsigned i;
+
+ PJ_LOG(3,(THIS_FILE, "Testing parsing error"));
+
+ pool = pjsip_endpt_create_pool(endpt, "msgerrtest", 4000, 4000);
+
+ for (i=0; i<PJ_ARRAY_SIZE(test_entries); ++i) {
+ pjsip_parser_err_report err_list, *e;
+ pjsip_msg *msg;
+
+ PJ_LOG(3,(THIS_FILE, " Parsing msg %d", i));
+ pj_list_init(&err_list);
+ msg = pjsip_parse_msg(pool, test_entries[i].msg,
+ strlen(test_entries[i].msg), &err_list);
+
+ e = err_list.next;
+ while (e != &err_list) {
+ PJ_LOG(3,(THIS_FILE,
+ " reported syntax error at line %d col %d for %.*s",
+ e->line, e->col,
+ (int)e->hname.slen,
+ e->hname.ptr));
+ e = e->next;
+ }
+ }
+
+ pj_pool_release(pool);
+ return 0;
+}
diff --git a/pjsip/src/test-pjsip/msg_logger.c b/pjsip/src/test-pjsip/msg_logger.c
index 45a4cbaf..a4eac0da 100644
--- a/pjsip/src/test-pjsip/msg_logger.c
+++ b/pjsip/src/test-pjsip/msg_logger.c
@@ -63,7 +63,6 @@ static pjsip_module mod_msg_logger =
{ "mod-msg-logger", 14}, /* Name. */
-1, /* Id */
PJSIP_MOD_PRIORITY_TRANSPORT_LAYER-1,/* Priority */
- NULL, /* User data. */
NULL, /* load() */
NULL, /* start() */
NULL, /* stop() */
diff --git a/pjsip/src/test-pjsip/test.c b/pjsip/src/test-pjsip/test.c
index dd3453f8..f3d48332 100644
--- a/pjsip/src/test-pjsip/test.c
+++ b/pjsip/src/test-pjsip/test.c
@@ -36,7 +36,7 @@
pjsip_endpoint *endpt;
-int log_level = 5;
+int log_level = 3;
void app_perror(const char *msg, pj_status_t rc)
{
@@ -44,7 +44,7 @@ void app_perror(const char *msg, pj_status_t rc)
PJ_CHECK_STACK();
- pjsip_strerror(rc, errbuf, sizeof(errbuf));
+ pj_strerror(rc, errbuf, sizeof(errbuf));
PJ_LOG(3,(THIS_FILE, "%s: [pj_status_t=%d] %s", msg, rc, errbuf));
}
@@ -111,7 +111,7 @@ int test_main(void)
msg_logger_set_enabled(1);
/* Start transaction layer module. */
- rc = pjsip_tsx_layer_init(endpt);
+ rc = pjsip_tsx_layer_init_module(endpt);
if (rc != PJ_SUCCESS) {
app_perror(" Error initializing transaction module", rc);
goto on_return;
@@ -125,13 +125,14 @@ int test_main(void)
goto on_return;
}
- //DO_TEST(uri_test());
- //DO_TEST(msg_test());
- //DO_TEST(txdata_test());
- //DO_TEST(transport_udp_test());
- //DO_TEST(transport_loop_test());
- //DO_TEST(tsx_basic_test());
- //DO_TEST(tsx_uac_test());
+ DO_TEST(uri_test());
+ DO_TEST(msg_test());
+ DO_TEST(msg_err_test());
+ DO_TEST(txdata_test());
+ DO_TEST(transport_udp_test());
+ DO_TEST(transport_loop_test());
+ DO_TEST(tsx_basic_test());
+ DO_TEST(tsx_uac_test());
DO_TEST(tsx_uas_test());
on_return:
@@ -150,6 +151,6 @@ on_return:
else
PJ_LOG(3,(THIS_FILE, "Test completed with error(s)"));
- return 0;
+ return rc;
}
diff --git a/pjsip/src/test-pjsip/test.h b/pjsip/src/test-pjsip/test.h
index 7f74964d..7c549a32 100644
--- a/pjsip/src/test-pjsip/test.h
+++ b/pjsip/src/test-pjsip/test.h
@@ -29,6 +29,7 @@ extern pjsip_endpoint *endpt;
/* The tests */
int uri_test(void);
int msg_test(void);
+int msg_err_test(void);
int txdata_test(void);
int transport_udp_test(void);
int transport_loop_test(void);
diff --git a/pjsip/src/test-pjsip/transport_test.c b/pjsip/src/test-pjsip/transport_test.c
index df6f55eb..0cd0d225 100644
--- a/pjsip/src/test-pjsip/transport_test.c
+++ b/pjsip/src/test-pjsip/transport_test.c
@@ -100,7 +100,6 @@ static pjsip_module my_module =
{ "Transport-Test", 14}, /* Name. */
-1, /* Id */
PJSIP_MOD_PRIORITY_TSX_LAYER-1, /* Priority */
- NULL, /* User data. */
NULL, /* load() */
NULL, /* start() */
NULL, /* stop() */
@@ -302,7 +301,6 @@ static pjsip_module rt_module =
{ "Transport-RT-Test", 17}, /* Name. */
-1, /* Id */
PJSIP_MOD_PRIORITY_TSX_LAYER-1, /* Priority */
- NULL, /* User data. */
NULL, /* load() */
NULL, /* start() */
NULL, /* stop() */
diff --git a/pjsip/src/test-pjsip/tsx_uac_test.c b/pjsip/src/test-pjsip/tsx_uac_test.c
index c699bc54..262e5ce2 100644
--- a/pjsip/src/test-pjsip/tsx_uac_test.c
+++ b/pjsip/src/test-pjsip/tsx_uac_test.c
@@ -102,7 +102,6 @@ static pjsip_module tsx_user =
{ "Tsx-UAC-User", 12}, /* Name. */
-1, /* Id */
PJSIP_MOD_PRIORITY_APPLICATION-1, /* Priority */
- NULL, /* User data. */
NULL, /* load() */
NULL, /* start() */
NULL, /* stop() */
@@ -121,7 +120,6 @@ static pjsip_module msg_receiver =
{ "Msg-Receiver", 12}, /* Name. */
-1, /* Id */
PJSIP_MOD_PRIORITY_APPLICATION-1, /* Priority */
- NULL, /* User data. */
NULL, /* load() */
NULL, /* start() */
NULL, /* stop() */
diff --git a/pjsip/src/test-pjsip/tsx_uas_test.c b/pjsip/src/test-pjsip/tsx_uas_test.c
index 326f2256..632950f2 100644
--- a/pjsip/src/test-pjsip/tsx_uas_test.c
+++ b/pjsip/src/test-pjsip/tsx_uas_test.c
@@ -141,7 +141,6 @@ static pjsip_module tsx_user =
{ "Tsx-UAS-User", 12}, /* Name. */
-1, /* Id */
PJSIP_MOD_PRIORITY_APPLICATION-1, /* Priority */
- NULL, /* User data. */
NULL, /* load() */
NULL, /* start() */
NULL, /* stop() */
@@ -160,7 +159,6 @@ static pjsip_module msg_sender =
{ "Msg-Sender", 10}, /* Name. */
-1, /* Id */
PJSIP_MOD_PRIORITY_APPLICATION-1, /* Priority */
- NULL, /* User data. */
NULL, /* load() */
NULL, /* start() */
NULL, /* stop() */