Commit d7a39a0b authored by Pekka Pessi's avatar Pekka Pessi

check_nua: updated

darcs-hash:20080512230026-db55f-85f2a0674c7ee982d796df7f40a3ab85bd52e1b2.gz
parent a2ab682a
......@@ -43,8 +43,9 @@ libnua_la_SOURCES = nua.c nua_stack.h nua_common.c nua_stack.c \
COVERAGE_INPUT = $(libnua_la_SOURCES) $(include_sofia_HEADERS)
check_nua_SOURCES = check_nua.c check_nua.h check_session.c \
s2tester.h s2tester.c
check_nua_SOURCES = check_nua.c check_nua.h \
check_session.c check_register.c \
test_s2.h test_s2.c
check_nua_LDADD = $(nua_libs) @CHECK_LIBS@
......
......@@ -36,6 +36,43 @@
#include "check_nua.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#if HAVE_FNMATCH_H
#include <fnmatch.h>
#endif
static char const * const default_patterns[] = { "*", NULL };
static char const * const *test_patterns = default_patterns;
void check_nua_tcase_add_test(TCase *tc, TFun tf, char const *name)
{
char const * const *patterns;
#if HAVE_FNMATCH_H
for (patterns = test_patterns; *patterns; patterns++) {
if (!fnmatch(*patterns, name, 0)) {
if (strcmp(*patterns, "*")) {
printf("%s: match with %s\n", name, *patterns);
}
_tcase_add_test(tc, tf, name, 0, 0, 1);
return;
}
}
#else
for (patterns = test_patterns; *patterns; patterns++) {
if (!strcmp(*patterns, name) || !strcmp(*patterns, "*")) {
if (strcmp(*patterns, "*")) {
printf("%s: match with %s\n", name, *patterns);
}
_tcase_add_test(tc, tf, name, 0, 0, 1);
return;
}
}
#endif
printf("%s: no match\n", name);
}
int main(int argc, char *argv[])
{
......@@ -44,6 +81,28 @@ int main(int argc, char *argv[])
Suite *suite = suite_create("Unit tests for Sofia-SIP UA Engine");
SRunner *runner;
if (getenv("CHECK_NUA_CASES")) {
size_t i;
char *s, **patterns;
char *cases = strdup(getenv("CHECK_NUA_CASES"));
/* Count commas */
for (i = 2, s = cases; (s = strchr(s, ',')); s++, i++);
patterns = calloc(i, sizeof *patterns);
for (i = 0, s = cases;; i++) {
patterns[i] = s;
if (s == NULL)
break;
s = strchr(s, ',');
if (s)
*s++ = '\0';
}
test_patterns = (char const * const *)patterns;
}
check_register_cases(suite);
check_session_cases(suite);
......
......@@ -2,6 +2,12 @@
#include <check.h>
#undef tcase_add_test
#define tcase_add_test(tc, tf) \
check_nua_tcase_add_test(tc, tf, "" #tf "")
void check_nua_tcase_add_test(TCase *, TFun, char const *name);
void check_session_cases(Suite *suite);
void check_register_cases(Suite *suite);
......
This diff is collapsed.
This diff is collapsed.
......@@ -36,7 +36,7 @@
#define TP_MAGIC_T struct tp_magic_s
#include <s2tester.h>
#include "test_s2.h"
#include <sofia-sip/sip_header.h>
#include <sofia-sip/sip_status.h>
......@@ -51,7 +51,7 @@
#include <limits.h>
#include <time.h>
/* -- Types ------------------------------------------------------------- */
/* -- Module types ------------------------------------------------------ */
struct tp_magic_s
{
......@@ -59,7 +59,7 @@ struct tp_magic_s
sip_contact_t *contact;
};
/* -- Prototypes -------------------------------------------------------- */
/* -- Module prototypes ------------------------------------------------- */
static msg_t *s2_msg(int flags);
static int s2_complete_response(msg_t *response,
......@@ -67,15 +67,14 @@ static int s2_complete_response(msg_t *response,
msg_t *request);
static char *s2_generate_tag(su_home_t *home);
/* -- Globals ----------------------------------------------------------- */
/* -- Module globals ---------------------------------------------------- */
struct tester *s2;
static char const *_s2case = "0.0";
static unsigned s2_tag_generator = 0;
/** UA engine under test */
nua_t *s2_nua;
/* -- Globals ----------------------------------------------------------- */
unsigned s2_default_registration_duration = 3600;
......@@ -87,6 +86,22 @@ char const s2_auth_digest_str[] =
char const s2_auth_credentials[] = "Digest:\"s2test\":abc:abc";
char const s2_auth2_digest_str[] =
"Digest realm=\"s2test2\", "
"nonce=\"fb0c093dcd98b7102dd2f0e8b11d0f600b\", "
"qop=\"auth\", "
"algorithm=\"MD5\"";
char const s2_auth2_credentials[] = "Digest:\"s2test2\":abc:abc";
char const s2_auth3_digest_str[] =
"Digest realm=\"s2test3\", "
"nonce=\"e8b11d0f600bfb0c093dcd98b7102dd2f0\", "
"qop=\"auth-int\", "
"algorithm=\"MD5-sess\"";
char const s2_auth3_credentials[] = "Digest:\"s2test3\":abc:abc";
/* -- Delay scenarios --------------------------------------------------- */
static unsigned long time_offset;
......@@ -410,7 +425,9 @@ s2_respond_to(struct message *m, struct dialog *d,
ntohs(((su_sockaddr_t *)
msg_addrinfo(m->msg)->ai_addr)->su_port));
if (sip->sip_via->v_rport && s2->server_uses_rport) {
if (s2->server_uses_rport &&
sip->sip_via->v_rport &&
sip->sip_via->v_rport[0] == '\0') {
msg_header_add_param(home, sip->sip_via->v_common, rport);
}
......@@ -701,7 +718,9 @@ s2_save_register(struct message *rm)
msg_header_free_all(s2->home, (msg_header_t *)s2->registration->contact);
tport_unref(s2->registration->tport);
memset(s2->registration, 0, sizeof *s2->registration);
s2->registration->aor = NULL;
s2->registration->contact = NULL;
s2->registration->tport = NULL;
if (rm == NULL)
return 0;
......
......@@ -103,6 +103,12 @@ extern unsigned s2_default_registration_duration;
extern char const s2_auth_digest_str[];
extern char const s2_auth_credentials[];
extern char const s2_auth2_digest_str[];
extern char const s2_auth2_credentials[];
extern char const s2_auth3_digest_str[];
extern char const s2_auth3_credentials[];
void s2_fast_forward(unsigned long seconds);
void s2_case(char const *tag,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment