Commit b1b9bedf authored by Pekka Pessi's avatar Pekka Pessi

nua: added --loop option to nua_test, updated tests for client refactoring

darcs-hash:20070102084802-65a35-9f4de57f779ff9249f01bc7e7b5ec942483069d4.gz
parent 9738711a
......@@ -1590,5 +1590,25 @@ int test_100rel(struct context *ctx)
retval = test_preconditions2(ctx); RETURN_ON_SINGLE_FAILURE(retval);
retval = test_update_by_uas(ctx); RETURN_ON_SINGLE_FAILURE(retval);
nua_set_params(ctx->a.nua,
NUTAG_EARLY_MEDIA(0),
SIPTAG_SUPPORTED(ctx->a.supported),
TAG_END());
run_a_until(ctx, nua_r_set_params, until_final_response);
nua_set_params(ctx->b.nua,
NUTAG_EARLY_MEDIA(0),
NUTAG_ONLY183_100REL(0),
SIPTAG_SUPPORTED(ctx->b.supported),
TAG_END());
run_b_until(ctx, nua_r_set_params, until_final_response);
nua_set_params(ctx->c.nua,
NUTAG_EARLY_MEDIA(0),
NUTAG_ONLY183_100REL(0),
SIPTAG_SUPPORTED(ctx->c.supported),
TAG_END());
run_c_until(ctx, nua_r_set_params, until_final_response);
return retval;
}
......@@ -404,6 +404,7 @@ int test_basic_call_2(struct context *ctx)
INVITE(a, a_call, a_call->nh,
NUTAG_URL(b->contact->m_url),
SOATAG_USER_SDP_STR(a_call->sdp),
NUTAG_ALLOW("INFO"),
TAG_END());
run_ab_until(ctx, -1, until_ready, -1, accept_early_answer);
......@@ -466,32 +467,55 @@ int test_basic_call_2(struct context *ctx)
TEST_1(nua_handle_has_active_call(b_call->nh));
TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
INFO(b, b_call, b_call->nh, TAG_END());
BYE(b, b_call, b_call->nh, TAG_END());
INFO(b, b_call, b_call->nh, TAG_END());
run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
while (!b->events->head || /* r_info */
!b->events->head->next || /* r_bye */
!b->events->head->next->next || /* i_state */
!b->events->head->next->next->next) /* r_info */
run_ab_until(ctx, -1, save_events, -1, save_until_final_response);
/* B transitions:
nua_info()
READY --(T2)--> TERMINATING: nua_bye()
nua_r_info with 200
TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
nua_r_info with 481/900
*/
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_bye);
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_info);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_info);
TEST_1(e->data->e_status >= 900 || e->data->e_status == 481);
TEST_1(!e->next);
free_events_in_list(ctx, b->events);
TEST_1(!nua_handle_has_active_call(b_call->nh));
/* A transitions:
nua_i_info
READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
*/
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_bye);
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_info);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
TEST(e->data->e_status, 200);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
TEST_1(!e->next);
free_events_in_list(ctx, a->events);
TEST_1(!nua_handle_has_active_call(a_call->nh));
BYE(a, a_call, a_call->nh, TAG_END());
run_a_until(ctx, -1, save_until_final_response);
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_bye);
TEST_1(e->data->e_status >= 900);
TEST_1(!e->next);
free_events_in_list(ctx, a->events);
nua_handle_destroy(a_call->nh), a_call->nh = NULL;
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
......
......@@ -638,11 +638,12 @@ int test_reject_401(struct context *ctx)
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_invite);
TEST(e->data->e_status, 100);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_proxy_authorization);
/* Ensure that nua_authenticate() tags get added to the request */
TEST_1(sip->sip_subject);
TEST_S(sip->sip_subject->g_value, "Got 407");
TEST_1(sip->sip_proxy_authorization);
TEST(e->data->e_status, 100);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
TEST_1(is_offer_recv(e->data->e_tags));
......@@ -911,7 +912,7 @@ int test_mime_negotiation(struct context *ctx)
/*
Client transitions in reject-3:
INIT -(C1)-> PROCEEDING -(C6a)-> TERMINATED
INIT -(C1)-> CALLING -(C6a)-> TERMINATED
*/
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
......@@ -927,7 +928,7 @@ int test_mime_negotiation(struct context *ctx)
/* No content-encoding is supported */
TEST_S(sip->sip_accept_encoding->aa_value, "");
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* CALLING */
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
TEST_1(!e->next);
free_events_in_list(ctx, a->events);
......
......@@ -167,6 +167,13 @@ int test_extension(struct context *ctx)
free_events_in_list(ctx, b->events);
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
nua_set_params(b->nua,
SIPTAG_ALLOW(b->allow),
NUTAG_APPL_METHOD(NULL),
NUTAG_APPL_METHOD(b->appl_method),
TAG_END());
run_b_until(ctx, nua_r_set_params, until_final_response);
if (print_headings)
printf("TEST NUA-13.1: PASSED\n");
END();
......
......@@ -65,6 +65,9 @@ int test_nua_init(struct context *ctx,
struct event *e;
sip_contact_t const *m = NULL;
sip_from_t const *sipaddress = NULL;
sip_allow_t const *allow = NULL;
sip_supported_t const *supported = NULL;
char const *appl_method = NULL;
url_t const *p_uri, *a_uri; /* Proxy URI */
char const *a_bind, *a_bind2;
......@@ -225,15 +228,21 @@ int test_nua_init(struct context *ctx,
nua_get_params(ctx->a.nua, TAG_ANY(), TAG_END());
run_a_until(ctx, nua_r_get_params, save_until_final_response);
TEST_1(e = ctx->a.events->head);
TEST_1(e = ctx->a.specials->head);
TEST(tl_gets(e->data->e_tags,
NTATAG_CONTACT_REF(m),
SIPTAG_FROM_REF(sipaddress),
TAG_END()), 2); TEST_1(m);
SIPTAG_ALLOW_REF(allow),
NUTAG_APPL_METHOD_REF(appl_method),
SIPTAG_SUPPORTED_REF(supported),
TAG_END()), 5); TEST_1(m);
TEST_1(ctx->a.contact = sip_contact_dup(ctx->home, m));
TEST_1(ctx->a.to = sip_to_dup(ctx->home, sipaddress));
TEST_1(ctx->a.allow = sip_allow_dup(ctx->home, allow));
TEST_1(ctx->a.appl_method = su_strdup(ctx->home, appl_method));
TEST_1(ctx->a.supported = sip_supported_dup(ctx->home, supported));
free_events_in_list(ctx, ctx->a.events);
free_events_in_list(ctx, ctx->a.specials);
if (print_headings)
printf("TEST NUA-2.2.1: PASSED\n");
......@@ -254,14 +263,22 @@ int test_nua_init(struct context *ctx,
nua_get_params(ctx->b.nua, TAG_ANY(), TAG_END());
run_b_until(ctx, nua_r_get_params, save_until_final_response);
TEST_1(e = ctx->b.events->head);
TEST_1(e = ctx->b.specials->head);
TEST(tl_gets(e->data->e_tags,
NTATAG_CONTACT_REF(m),
SIPTAG_FROM_REF(sipaddress),
TAG_END()), 2); TEST_1(m);
SIPTAG_ALLOW_REF(allow),
NUTAG_APPL_METHOD_REF(appl_method),
SIPTAG_SUPPORTED_REF(supported),
TAG_END()), 5); TEST_1(m);
TEST_1(ctx->b.contact = sip_contact_dup(ctx->home, m));
TEST_1(ctx->b.to = sip_to_dup(ctx->home, sipaddress));
free_events_in_list(ctx, ctx->b.events);
TEST_1(ctx->b.allow = sip_allow_dup(ctx->home, allow));
TEST_1(ctx->b.appl_method = su_strdup(ctx->home, appl_method));
TEST_1(ctx->b.supported = sip_supported_dup(ctx->home, supported));
free_events_in_list(ctx, ctx->b.specials);
if (print_headings)
printf("TEST NUA-2.2.2: PASSED\n");
......@@ -282,14 +299,20 @@ int test_nua_init(struct context *ctx,
nua_get_params(ctx->c.nua, TAG_ANY(), TAG_END());
run_c_until(ctx, nua_r_get_params, save_until_final_response);
TEST_1(e = ctx->c.events->head);
TEST_1(e = ctx->c.specials->head);
TEST(tl_gets(e->data->e_tags,
NTATAG_CONTACT_REF(m),
SIPTAG_FROM_REF(sipaddress),
TAG_END()), 2); TEST_1(m);
SIPTAG_ALLOW_REF(allow),
NUTAG_APPL_METHOD_REF(appl_method),
SIPTAG_SUPPORTED_REF(supported),
TAG_END()), 5); TEST_1(m);
TEST_1(ctx->c.contact = sip_contact_dup(ctx->home, m));
TEST_1(ctx->c.to = sip_to_dup(ctx->home, sipaddress));
free_events_in_list(ctx, ctx->c.events);
TEST_1(ctx->c.allow = sip_allow_dup(ctx->home, allow));
TEST_1(ctx->c.appl_method = su_strdup(ctx->home, appl_method));
TEST_1(ctx->c.supported = sip_supported_dup(ctx->home, supported));
free_events_in_list(ctx, ctx->c.specials);
if (print_headings)
printf("TEST NUA-2.2.3: PASSED\n");
......
......@@ -72,6 +72,7 @@ static RETSIGTYPE sig_alarm(int s)
static char const options_usage[] =
" -v | --verbose be verbose\n"
" -q | --quiet be quiet\n"
" -a | --abort abort on error\n"
" -s use only single thread\n"
" -l level set logging level (0 by default)\n"
" -e | --events print nua events\n"
......@@ -83,6 +84,7 @@ static char const options_usage[] =
" --no-nat do not use internal \"nat\"\n"
" --symmetric run internal \"nat\" in symmetric mode\n"
" -N print events from internal \"nat\"\n"
" --loop loop main tests for ever\n"
" --no-alarm don't ask for guard ALARM\n"
" -p uri specify uri of outbound proxy (implies --no-proxy)\n"
" --proxy-tests run tests involving proxy, too\n"
......@@ -99,7 +101,7 @@ void usage(int exitcode)
int main(int argc, char *argv[])
{
int retval = 0;
int i, o_quiet = 0, o_attach = 0, o_alarm = 1;
int i, o_quiet = 0, o_attach = 0, o_alarm = 1, o_loop = 0;
int o_events_init = 0, o_events_a = 0, o_events_b = 0, o_events_c = 0;
int o_iproxy = 1, o_inat = 1;
int o_inat_symmetric = 0, o_inat_logging = 0, o_expensive = 0;
......@@ -199,6 +201,9 @@ int main(int argc, char *argv[])
else if (strcmp(argv[i], "--no-alarm") == 0) {
o_alarm = 0;
}
else if (strcmp(argv[i], "--loop") == 0) {
o_alarm = 0, o_loop = 1;
}
#if SU_HAVE_OSX_CF_API /* If compiled with CoreFoundation events */
else if (strcmp(argv[i], "--osx-runloop") == 0) {
ctx->osx_runloop = 1;
......@@ -279,7 +284,7 @@ int main(int argc, char *argv[])
if (retval == 0 && o_inat)
retval |= test_nat_timeout(ctx);
if (retval == 0) {
while (retval == 0) {
retval |= test_extension(ctx); SINGLE_FAILURE_CHECK();
retval |= test_basic_call(ctx); SINGLE_FAILURE_CHECK();
retval |= test_reject_a(ctx); SINGLE_FAILURE_CHECK();
......@@ -295,8 +300,10 @@ int main(int argc, char *argv[])
retval |= test_session_timer(ctx); SINGLE_FAILURE_CHECK();
retval |= test_refer(ctx); SINGLE_FAILURE_CHECK();
retval |= test_100rel(ctx); SINGLE_FAILURE_CHECK();
retval |= test_simple(ctx); SINGLE_FAILURE_CHECK();
retval |= test_events(ctx); SINGLE_FAILURE_CHECK();
retval |= test_simple(ctx); SINGLE_FAILURE_CHECK();
if (!o_loop)
break;
}
if (ctx->proxy_tests && (retval == 0 || !ctx->p))
......
......@@ -138,6 +138,10 @@ struct context
sip_contact_t *contact;
sip_from_t *to;
sip_allow_t *allow;
char const *appl_method;
sip_supported_t *supported;
printer_function *printer;
char const *instance;
......@@ -185,6 +189,9 @@ int save_event_in_list(struct context *,
struct call *);
void free_events_in_list(struct context *,
struct eventlist *);
void free_event_in_list(struct context *ctx,
struct eventlist *list,
struct event *e);
#define CONDITION_PARAMS \
nua_event_t event, \
......
......@@ -117,12 +117,12 @@ int test_nua_params(struct context *ctx)
nua_get_params(ctx->a.nua, TAG_ANY(), TAG_END());
run_a_until(ctx, nua_r_get_params, save_until_final_response);
TEST_1(e = ctx->a.events->head);
TEST_1(e = ctx->a.specials->head);
TEST_E(e->data->e_event, nua_r_get_params);
for (n = 0, t = e->data->e_tags; t; n++, t = tl_next(t))
;
TEST_1(n > 32);
free_events_in_list(ctx, ctx->a.events);
free_events_in_list(ctx, ctx->a.specials);
nh = nua_handle(ctx->a.nua, NULL, TAG_END()); TEST_1(nh);
nua_handle_unref(nh);
......@@ -291,7 +291,7 @@ int test_nua_params(struct context *ctx)
nua_get_params(ctx->a.nua, TAG_ANY(), TAG_END());
run_a_until(ctx, nua_r_get_params, save_until_final_response);
TEST_1(e = ctx->a.events->head);
TEST_1(e = ctx->a.specials->head);
TEST_E(e->data->e_event, nua_r_get_params);
n = tl_gets(e->data->e_tags,
......@@ -414,7 +414,7 @@ int test_nua_params(struct context *ctx)
TEST_S(m_features, expect_m_features); }
TEST_S(outbound, "foo");
free_events_in_list(ctx, ctx->a.events);
free_events_in_list(ctx, ctx->a.specials);
}
/* Test that only those tags that have been set per handle are returned by nua_get_hparams() */
......
......@@ -44,7 +44,7 @@
int save_events(CONDITION_PARAMS)
{
return save_event_in_list(ctx, event, ep, ep->call) == event_is_normal;
return save_event_in_list(ctx, event, ep, call) == event_is_normal;
}
int until_final_response(CONDITION_PARAMS)
......@@ -54,7 +54,7 @@ int until_final_response(CONDITION_PARAMS)
int save_until_final_response(CONDITION_PARAMS)
{
save_event_in_list(ctx, event, ep, ep->call);
save_event_in_list(ctx, event, ep, call);
return event >= nua_r_set_params && status >= 200;
}
......@@ -64,13 +64,13 @@ int save_until_final_response(CONDITION_PARAMS)
*/
int save_until_received(CONDITION_PARAMS)
{
return save_event_in_list(ctx, event, ep, ep->call) == event_is_normal;
return save_event_in_list(ctx, event, ep, call) == event_is_normal;
}
/** Save events until nua_i_outbound is received. */
int save_until_special(CONDITION_PARAMS)
{
return save_event_in_list(ctx, event, ep, ep->call) == event_is_special;
return save_event_in_list(ctx, event, ep, call) == event_is_special;
}
/* Return call state from event tag list */
......@@ -143,14 +143,30 @@ void print_event(nua_event_t event,
sip_t const *sip,
tagi_t tags[])
{
tagi_t const *t;
if (event == nua_i_state) {
fprintf(stderr, "%s.nua(%p): event %s %s\n",
ep->name, nh, nua_event_name(event),
nua_callstate_name(callstate(tags)));
}
else if ((int)event >= nua_r_set_params) {
fprintf(stderr, "%s.nua(%p): event %s status %u %s\n",
ep->name, nh, nua_event_name(event), status, phrase);
t = tl_find(tags, nutag_substate);
if (t) {
fprintf(stderr, "%s.nua(%p): event %s status %u %s (%s)\n",
ep->name, nh, nua_event_name(event), status, phrase,
nua_substate_name(t->t_value));
}
else {
fprintf(stderr, "%s.nua(%p): event %s status %u %s\n",
ep->name, nh, nua_event_name(event), status, phrase);
}
}
else if (event == nua_i_notify) {
t = tl_find(tags, nutag_substate);
fprintf(stderr, "%s.nua(%p): event %s %s (%s)\n",
ep->name, nh, nua_event_name(event), phrase,
nua_substate_name(t ? t->t_value : 0));
}
else if ((int)event >= 0) {
fprintf(stderr, "%s.nua(%p): event %s %s\n",
......@@ -161,7 +177,6 @@ void print_event(nua_event_t event,
ep->name, nh, operation, status, phrase);
}
else {
tagi_t const *t;
t = tl_find(tags, siptag_subject_str);
if (t && t->t_value) {
char const *subject = (char const *)t->t_value;
......@@ -202,10 +217,11 @@ void ep_callback(nua_event_t event,
}
}
if ((ep->next_event == -1 || ep->next_event == event) &&
(ep->next_condition == NULL ||
if ((ep->next_condition == NULL ||
ep->next_condition(event, status, phrase,
nua, ctx, ep, nh, call, sip, tags)))
nua, ctx, ep, nh, call, sip, tags))
&&
(ep->next_event == -1 || ep->next_event == event))
ep->running = 0;
ep->last_event = event;
......@@ -379,7 +395,7 @@ int RESPOND(struct endpoint *ep,
return 0;
}
/* Destroy an handle */
/* Destroy a handle */
int DESTROY(struct endpoint *ep,
struct call *call,
nua_handle_t *nh)
......@@ -450,7 +466,7 @@ int save_event_in_list(struct context *ctx,
return action;
}
/* Save nua event in endpoint list */
/* Free nua events from endpoint list */
void free_events_in_list(struct context *ctx,
struct eventlist *list)
{
......@@ -466,6 +482,21 @@ void free_events_in_list(struct context *ctx,
list->tail = &list->head;
}
void free_event_in_list(struct context *ctx,
struct eventlist *list,
struct event *e)
{
if (e) {
if ((*e->prev = e->next))
e->next->prev = e->prev;
nua_destroy_event(e->saved_event);
su_free(ctx->home, e);
if (list->head == NULL)
list->tail = &list->head;
}
}
int is_special(nua_event_t e)
{
if (e == nua_i_active || e == nua_i_terminated)
......
This diff is collapsed.
......@@ -142,6 +142,7 @@ int test_register_to_proxy(struct context *ctx)
TEST_1(sip = sip_object(e->data->e_msg));
TEST(e->data->e_status, 401);
TEST(sip->sip_status->st_status, 401);
/* Check that CSeq included in tags is actually used in the request */
TEST(sip->sip_cseq->cs_seq, 13);
TEST_1(!sip->sip_contact);
TEST_1(!e->next);
......@@ -552,7 +553,8 @@ int test_nat_timeout(struct context *ctx)
BEGIN();
struct endpoint *a = &ctx->a, *b = &ctx->b, *c = &ctx->c;
struct endpoint *a = &ctx->a, *b = &ctx->b;
struct call *a_call = a->call, *b_call = b->call;
struct event *e;
sip_t const *sip;
......@@ -586,7 +588,38 @@ int test_nat_timeout(struct context *ctx)
if (print_headings)
printf("TEST NUA-2.5.1: PASSED\n");
(void)b; (void)c; (void)sip;
if (print_headings)
printf("TEST NUA-2.5.2: OPTIONS from B to A\n");
TEST_1(b_call->nh = nua_handle(b->nua, b_call, SIPTAG_TO(a->to), TAG_END()));
OPTIONS(b, b_call, b_call->nh, TAG_END());
run_ab_until(ctx, -1, save_until_received,
-1, save_until_final_response);
/* Client events: nua_options(), nua_r_options */
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_options);
TEST(e->data->e_status, 200);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_allow); TEST_1(sip->sip_accept); TEST_1(sip->sip_supported);
/* TEST_1(sip->sip_content_type); */
/* TEST_1(sip->sip_payload); */
TEST_1(!e->next);
free_events_in_list(ctx, b->events);
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
/* Server events: nua_i_options */
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_options);
TEST(e->data->e_status, 200);
TEST_1(!e->next);
free_events_in_list(ctx, a->events);
nua_handle_destroy(a_call->nh), a_call->nh = NULL;
if (print_headings)
printf("TEST NUA-2.5.2: PASSED\n");
END();
}
......
......@@ -43,6 +43,8 @@
#define __func__ "test_simple"
#endif
extern int accept_request(CONDITION_PARAMS);
int test_message(struct context *ctx)
{
BEGIN();
......@@ -62,7 +64,7 @@ int test_message(struct context *ctx)
*/
if (print_headings)
printf("TEST NUA-11.1: MESSAGE\n");
printf("TEST NUA-11.1.1: MESSAGE\n");
if (ctx->proxy_tests)
*url = *b->to->a_url;
......@@ -76,7 +78,7 @@ int test_message(struct context *ctx)
MESSAGE(a, a_call, a_call->nh,
NUTAG_URL(url),
SIPTAG_SUBJECT_STR("NUA-11.1"),
SIPTAG_SUBJECT_STR("NUA-11.1.1"),
SIPTAG_CONTENT_TYPE_STR("text/plain"),
SIPTAG_PAYLOAD_STR("Hello hellO!\n"),
TAG_END());
......@@ -98,7 +100,64 @@ int test_message(struct context *ctx)
TEST(e->data->e_status, 200);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_subject && sip->sip_subject->g_string);
TEST_S(sip->sip_subject->g_string, "NUA-11.1");
TEST_S(sip->sip_subject->g_string, "NUA-11.1.1");
TEST_1(sip->sip_organization);
TEST_S(sip->sip_organization->g_string, "United Testers");
TEST_1(!e->next);
free_events_in_list(ctx, a->events);
nua_handle_destroy(a_call->nh), a_call->nh = NULL;
free_events_in_list(ctx, b->events);
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
if (print_headings)
printf("TEST NUA-11.1.1: PASSED\n");
/* MESSAGE as application method
A B
|-------MESSAGE----->|
|<-------202---------|
| |
*/
if (print_headings)
printf("TEST NUA-11.1.2: MESSAGE\n");
nua_set_params(b->nua, NUTAG_APPL_METHOD("MESSAGE"), TAG_END());
run_b_until(ctx, nua_r_set_params, until_final_response);
TEST_1(a_call->nh = nua_handle(a->nua, a_call, TAG_END()));
MESSAGE(a, a_call, a_call->nh,
NUTAG_URL(url),
SIPTAG_SUBJECT_STR("NUA-11.1.2"),
SIPTAG_CONTENT_TYPE_STR("text/plain"),
SIPTAG_PAYLOAD_STR("Hello hellO!\n"),
TAG_END());
run_ab_until(ctx, -1, save_until_final_response, -1, accept_request);
/* Client events:
nua_message(), nua_r_message
*/
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_message);
TEST(e->data->e_status, 202);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip_user_agent(sip));
TEST_S(sip_user_agent(sip)->g_value, "007");
TEST_1(!e->next);
/*
Server events:
nua_i_message
*/
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_message);
TEST(e->data->e_status, 100);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_subject && sip->sip_subject->g_string);
TEST_S(sip->sip_subject->g_string, "NUA-11.1.2");
TEST_1(sip->sip_organization);
TEST_S(sip->sip_organization->g_string, "United Testers");
TEST_1(!e->next);
......@@ -110,7 +169,7 @@ int test_message(struct context *ctx)
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
if (print_headings)
printf("TEST NUA-11.1: PASSED\n");
printf("TEST NUA-11.1.2: PASSED\n");
/* Message test
......@@ -131,7 +190,7 @@ int test_message(struct context *ctx)
MESSAGE(a, a_call, a_call->nh,
/* We cannot reach us by using our contact! */
NUTAG_URL(!ctx->p && !ctx->proxy_tests ? a->contact->m_url : NULL),
SIPTAG_SUBJECT_STR("NUA-11.1b"),
SIPTAG_SUBJECT_STR("NUA-11.2"),
SIPTAG_CONTENT_TYPE_STR("text/plain"),
SIPTAG_PAYLOAD_STR("Hello hellO!\n"),
TAG_END());
......@@ -141,16 +200,18 @@ int test_message(struct context *ctx)
/* Events:
nua_message(), nua_i_message, nua_r_message
*/
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_message);
TEST_1(e = a->specials->head); TEST_E(e->data->e_event, nua_i_message);
TEST(e->data->e_status, 200);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_subject && sip->sip_subject->g_string);
TEST_S(sip->sip_subject->g_string, "NUA-11.1b");
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_message);
TEST_S(sip->sip_subject->g_string, "NUA-11.2");
TEST_1(!e->next);
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_message);
TEST(e->data->e_status, 200);
TEST_1(!e->next);
free_events_in_list(ctx, a->events);
free_events_in_list(ctx, a->specials);
nua_handle_destroy(a_call->nh), a_call->nh = NULL;
if (print_headings)
......@@ -159,12 +220,32 @@ int test_message(struct context *ctx)
END();
}
int accept_request(CONDITION_PARAMS)
{
msg_t *with = nua_current_request(nua);
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
return 0;
save_event_in_list(ctx, event, ep, call);
if (status < 200) {
RESPOND(ep, call, nh, SIP_202_ACCEPTED,
NUTAG_WITH(with),
SIPTAG_USER_AGENT_STR("007"),
TAG_END());
return 1;
}
return 0;
}
int respond_with_etag(CONDITION_PARAMS)
{
msg_t *with = nua_current_request(nua);
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
return 0;
return 1;
save_event_in_list(ctx, event, ep, call);
......@@ -191,6 +272,14 @@ int respond_with_etag(CONDITION_PARAMS)
}
}
static int close_handle(CONDITION_PARAMS)
{
if (call->nh == nh)
call->nh = NULL;
nua_handle_destroy(nh);
return 1;
}
int test_publish(struct context *ctx)
{
BEGIN();
......@@ -357,8 +446,60 @@ int test_publish(struct context *ctx)
nua_handle_destroy(a_call->nh), a_call->nh = NULL;
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
/* Let server close handle without responding to PUBLISH */
PUBLISH(a, a_call, a_call->nh,
TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
SIPTAG_EVENT_STR("presence"),
SIPTAG_CONTENT_TYPE_STR("text/urllist"),