Fixed pjsip-test and added msg_err_test.c for testing parsing errors
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@547 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
e6956991ea
commit
733c67a090
|
@ -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
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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() */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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() */
|
||||
|
|
|
@ -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() */
|
||||
|
|
|
@ -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() */
|
||||
|
|
Loading…
Reference in New Issue