Commit 2d4cfda0 authored by Pekka Pessi's avatar Pekka Pessi

test_nua: fixed some tests depending on delivery of responses in correct order

Reordering might happen if some messages are sent over TCP, other over UDP.

darcs-hash:20070601192208-65a35-99a3b1aaedcddda0cc2a0a1993053efd66141c9b.gz
parent 03ded311
......@@ -128,7 +128,7 @@ int test_180rel(struct context *ctx)
struct endpoint *a = &ctx->a, *b = &ctx->b;
struct call *a_call = a->call, *b_call = b->call;
struct event *e;
struct event *e, *ep, *ei;
sip_t *sip;
if (print_headings)
......@@ -193,10 +193,17 @@ int test_180rel(struct context *ctx)
TEST_1(is_answer_recv(e->data->e_tags));
TEST_1(!is_offer_sent(e->data->e_tags));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
ei = event_by_type(e->next, nua_r_invite);
ep = event_by_type(e->next, nua_r_prack);
if (!ep) {
run_a_until(ctx, -1, until_final_response);
ep = event_by_type(e->next, nua_r_prack);
}
TEST_1(e = ep); TEST_E(e->data->e_event, nua_r_prack);
TEST(e->data->e_status, 200);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
TEST_1(e = ei); TEST_E(e->data->e_event, nua_r_invite);
TEST(e->data->e_status, 200);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_content_type);
......@@ -206,7 +213,8 @@ int test_180rel(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_ready); /* READY */
TEST_1(!is_offer_answer_done(e->data->e_tags));
TEST_1(!e->next);
TEST_1(!e->next || !ep->next);
free_events_in_list(ctx, a->events);
/*
......@@ -321,13 +329,13 @@ int test_prack_auth(struct context *ctx)
struct endpoint *c = &ctx->c, *b = &ctx->b;
struct call *c_call = c->call, *b_call = b->call;
struct event *e;
struct event *e, *ep, *ei;
sip_t *sip;
sip_proxy_authenticate_t *au;
char const *md5 = NULL, *md5sess = NULL;
if (print_headings)
printf("TEST NUA-10.1.1: Call with 100rel and 180\n");
printf("TEST NUA-10.1.3: Call with 100rel and 180\n");
/* Test for authentication during 100rel
......@@ -405,8 +413,14 @@ int test_prack_auth(struct context *ctx)
TEST_1(is_answer_recv(e->data->e_tags));
TEST_1(!is_offer_sent(e->data->e_tags));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
ei = event_by_type(e->next, nua_r_invite);
ep = event_by_type(e->next, nua_r_prack);
if (!ep) {
run_a_until(ctx, -1, until_final_response);
ep = event_by_type(e->next, nua_r_prack);
}
TEST_1(e = ep); TEST_E(e->data->e_event, nua_r_prack);
if (e->data->e_status != 200 && md5 && !md5sess) {
if (e->data->e_status != 100) {
TEST(e->data->e_status, 407);
......@@ -419,16 +433,15 @@ int test_prack_auth(struct context *ctx)
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
}
TEST(e->data->e_status, 200);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
TEST_1(e = ei); TEST_E(e->data->e_event, nua_r_invite);
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_ready); /* READY */
TEST_1(!is_offer_answer_done(e->data->e_tags));
TEST_1(!e->next);
TEST_1(!e->next || !ep->next || (ep->data->e_status != 200 && !e->next->next->next));
free_events_in_list(ctx, c->events);
/*
......@@ -466,10 +479,10 @@ int test_prack_auth(struct context *ctx)
free_events_in_list(ctx, b->events);
if (print_headings)
printf("TEST NUA-10.1.1: PASSED\n");
printf("TEST NUA-10.1.3: PASSED\n");
if (print_headings)
printf("TEST NUA-10.1.2: terminate call\n");
printf("TEST NUA-10.1.4: terminate call\n");
BYE(b, b_call, b_call->nh, TAG_END());
run_bc_until(ctx, -1, until_terminated, -1, until_terminated);
......@@ -496,7 +509,7 @@ int test_prack_auth(struct context *ctx)
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
if (print_headings)
printf("TEST NUA-10.1.2: PASSED\n");
printf("TEST NUA-10.1.4: PASSED\n");
END();
}
......@@ -558,7 +571,7 @@ int test_183rel(struct context *ctx)
struct endpoint *a = &ctx->a, *b = &ctx->b;
struct call *a_call = a->call, *b_call = b->call;
struct event *e;
struct event *e, *ei, *ep;
if (print_headings)
printf("TEST NUA-10.2.1: Call with 100rel, 183 and 180\n");
......@@ -590,26 +603,43 @@ int test_183rel(struct context *ctx)
TEST_1(is_answer_recv(e->data->e_tags));
TEST_1(!is_offer_sent(e->data->e_tags));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
TEST(e->data->e_status, 200);
TEST_1(e = e->next);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
ep = e->data->e_event == nua_r_prack ? e : NULL;
if (ep) {
TEST(ep->data->e_status, 200); TEST_1(e = e->next);
}
TEST_E(e->data->e_event, nua_r_invite);
TEST(e->data->e_status, 180);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_proceeding);
TEST_1(!is_offer_answer_done(e->data->e_tags));
if (!ep) {
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
TEST(e->data->e_status, 200);
}
ei = event_by_type(e->next, nua_r_invite);
ep = event_by_type(e->next, nua_r_prack);
if (!ep) {
run_a_until(ctx, -1, until_final_response);
ep = event_by_type(e->next, nua_r_prack);
}
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
TEST_1(e = ep); TEST_E(e->data->e_event, nua_r_prack);
TEST(e->data->e_status, 200);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
TEST_1(e = ei); TEST_E(e->data->e_event, nua_r_invite);
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_ready); /* READY */
TEST_1(!is_offer_answer_done(e->data->e_tags));
TEST_1(!e->next);
TEST_1(!e->next || !ep->next);
free_events_in_list(ctx, a->events);
/*
......@@ -879,7 +909,7 @@ int test_preconditions(struct context *ctx)
struct endpoint *a = &ctx->a, *b = &ctx->b;
struct call *a_call = a->call, *b_call = b->call;
struct event *e;
struct event *e, *ep, *ei;
sip_t *sip;
if (print_headings)
......@@ -969,7 +999,10 @@ int test_preconditions(struct context *ctx)
TEST_1(!is_answer_recv(e->data->e_tags));
TEST_1(is_offer_sent(e->data->e_tags));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_update);
ei = event_by_type(e->next, nua_r_invite);
ep = event_by_type(e->next, nua_r_update);
TEST_1(e = ep); TEST_E(e->data->e_event, nua_r_update);
TEST(e->data->e_status, 200);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_session_expires);
......@@ -979,17 +1012,27 @@ int test_preconditions(struct context *ctx)
TEST_1(is_answer_recv(e->data->e_tags));
TEST_1(!is_offer_sent(e->data->e_tags));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
TEST_1(e = ei); TEST_E(e->data->e_event, nua_r_invite);
TEST(e->data->e_status, 180);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
TEST_1(!is_offer_answer_done(e->data->e_tags));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
if (e == ep) /* invite was responded before update */
e = ep->next->next;
ei = event_by_type(e->next, nua_r_invite);
ep = event_by_type(e->next, nua_r_prack);
if (!ep) {
run_a_until(ctx, -1, until_final_response);
ep = event_by_type(e->next, nua_r_prack);
}
TEST_1(e = ep); TEST_E(e->data->e_event, nua_r_prack);
TEST(e->data->e_status, 200);
/* Does not have effect on call state */
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
TEST_1(e = ei); TEST_E(e->data->e_event, nua_r_invite);
TEST(e->data->e_status, 200);
TEST_1(sip = sip_object(e->data->e_msg));
if (ctx->proxy_tests) {
......@@ -1001,7 +1044,7 @@ int test_preconditions(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_ready); /* READY */
TEST_1(!is_offer_answer_done(e->data->e_tags));
TEST_1(!e->next);
TEST_1(!e->next || !ep->next);
free_events_in_list(ctx, a->events);
/*
......@@ -1169,7 +1212,7 @@ int test_preconditions2(struct context *ctx)
struct endpoint *a = &ctx->a, *b = &ctx->b;
struct call *a_call = a->call, *b_call = b->call;
struct event *e;
struct event *e, *eu, *ei;
if (print_headings)
printf("TEST NUA-10.4.1: Call with preconditions and non-100rel 180\n");
......@@ -1253,22 +1296,25 @@ int test_preconditions2(struct context *ctx)
TEST_1(!is_answer_recv(e->data->e_tags));
TEST_1(is_offer_sent(e->data->e_tags));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_update);
TEST(e->data->e_status, 200);
eu = event_by_type(e->next, nua_r_update);
ei = event_by_type(e->next, nua_r_invite);
TEST_1(e = eu); TEST_E(e->data->e_event, nua_r_update);
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_proceeding);
TEST_1(is_answer_recv(e->data->e_tags));
TEST_1(!is_offer_sent(e->data->e_tags));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
TEST_1(e = ei); TEST_E(e->data->e_event, nua_r_invite);
TEST(e->data->e_status, 180);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
TEST_1(!is_offer_answer_done(e->data->e_tags));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
TEST(e->data->e_status, 200);
TEST_1(e = eu->next->next == ei ? ei->next->next : eu->next->next);
TEST_E(e->data->e_event, nua_r_invite); 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_ready); /* READY */
......@@ -1445,7 +1491,7 @@ int test_update_by_uas(struct context *ctx)
struct endpoint *a = &ctx->a, *b = &ctx->b;
struct call *a_call = a->call, *b_call = b->call;
struct event *e;
struct event *e, *ep, *ei;
sip_t *sip;
/* -------------------------------------------------------------------- */
......@@ -1563,11 +1609,18 @@ int test_update_by_uas(struct context *ctx)
TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
TEST_1(!is_offer_answer_done(e->data->e_tags));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
ei = event_by_type(e->next, nua_r_invite);
ep = event_by_type(e->next, nua_r_prack);
if (!ep) {
run_a_until(ctx, -1, until_final_response);
ep = event_by_type(e->next, nua_r_prack);
}
TEST_1(e = ep); TEST_E(e->data->e_event, nua_r_prack);
TEST(e->data->e_status, 200);
/* Does not have effect on call state */
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
TEST_1(e = ei); TEST_E(e->data->e_event, nua_r_invite);
TEST(e->data->e_status, 200);
if (ctx->proxy_tests) {
TEST_1(sip = sip_object(e->data->e_msg));
......@@ -1579,7 +1632,7 @@ int test_update_by_uas(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_ready); /* READY */
TEST_1(!is_offer_answer_done(e->data->e_tags));
TEST_1(!e->next);
TEST_1(!e->next || !ep->next);
free_events_in_list(ctx, a->events);
/*
......@@ -1846,7 +1899,7 @@ int test_180rel_cancel2(struct context *ctx)
struct endpoint *a = &ctx->a, *b = &ctx->b;
struct call *a_call = a->call, *b_call = b->call;
struct event *e;
struct event *e, *ep, *ec;
if (print_headings)
printf("TEST NUA-10.7: CANCEL after 100rel 180\n");
......@@ -1911,17 +1964,21 @@ int test_180rel_cancel2(struct context *ctx)
TEST_1(is_answer_recv(e->data->e_tags));
TEST_1(!is_offer_sent(e->data->e_tags));
#define NEXT_SKIP_PRACK_CANCEL() \
#define NEXT_SKIP(x) \
do { TEST_1(e = e->next); } \
while (e->data->e_event == nua_r_prack || e->data->e_event == nua_r_cancel)
while (x);
NEXT_SKIP_PRACK_CANCEL();
NEXT_SKIP(e->data->e_event == nua_r_prack ||
e->data->e_event == nua_r_cancel ||
e->data->e_event == nua_i_state);
TEST_E(e->data->e_event, nua_r_invite);
if (e->data->e_status == 487) {
TEST(e->data->e_status, 487);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_terminated);
if (e->next)
NEXT_SKIP(e->data->e_event == nua_r_prack || e->data->e_event == nua_r_cancel);
TEST_1(!e->next);
}
else {
......@@ -1932,7 +1989,8 @@ int test_180rel_cancel2(struct context *ctx)
BYE(a, a_call, a_call->nh, TAG_END());
run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
NEXT_SKIP_PRACK_CANCEL(); TEST_E(e->data->e_event, nua_r_bye);
NEXT_SKIP(e->data->e_event == nua_r_prack || e->data->e_event == nua_r_cancel);
TEST_E(e->data->e_event, nua_r_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 */
......@@ -1963,18 +2021,20 @@ int test_180rel_cancel2(struct context *ctx)
TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
TEST_1(is_answer_sent(e->data->e_tags));
/* 180 is PRACKed */
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_prack);
/* Does not have effect on call state */
ec = event_by_type(e->next, nua_i_cancel);
if (e->next->data->e_event == nua_i_cancel) {
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_cancel);
if (ec) {
TEST_1(e = ec); TEST_E(e->data->e_event, nua_i_cancel);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
}
else {
/* Respond with 200 OK */
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
/* 180 is PRACKed, PRACK does not have effect on call state */
ep = event_by_type(e->next, nua_i_prack);
if (ep) e = ep;
/* Responded with 200 OK */
TEST_1(e = event_by_type(e->next, nua_i_state));
TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
TEST_1(!is_offer_answer_done(e->data->e_tags));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
......
......@@ -1100,7 +1100,7 @@ int test_basic_call_5(struct context *ctx)
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
if (print_headings)
printf("TEST NUA-3.4: PASSED\n");
printf("TEST NUA-3.5: PASSED\n");
END();
}
......
......@@ -1520,7 +1520,7 @@ int test_rejects(struct context *ctx)
test_reject_302(ctx) ||
test_reject_401(ctx) ||
test_mime_negotiation(ctx) ||
test_call_timeouts(ctx) ||
test_reject_401_aka(ctx) ||
test_call_timeouts(ctx) ||
0;
}
......@@ -113,7 +113,7 @@ int test_refer0(struct context *ctx, char const *tests,
struct call *a_call = a->call, *b_call = b->call, *c_call = c->call;
struct call *a_refer, *a_c2, *b_refer;
struct eventlist *a_revents, *b_revents;
struct event *e;
struct event *e, *notify_e;
sip_t const *sip;
sip_event_t const *a_event, *b_event;
sip_refer_to_t const *refer_to;
......@@ -280,21 +280,38 @@ int test_refer0(struct context *ctx, char const *tests,
TAG_END()), 1);
TEST_1(b_event); TEST_1(b_event->o_id);
TEST_1(b_event = sip_event_dup(tmphome, b_event));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_refer);
notify_e = NULL;
TEST_1(e = e->next);
if (e->data->e_event == nua_i_notify) {
notify_e = e;
TEST_1(e = e->next);
}
TEST_E(e->data->e_event, nua_r_refer);
TEST(e->data->e_status, 202);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_SIZE(strtoul(b_event->o_id, NULL, 10), sip->sip_cseq->cs_seq);
if (a_refer != a_call) {
if (b_revents->head->next->next == NULL)
run_ab_until(ctx, -1, save_until_received, nua_i_notify, save_events);
else if (a_revents->head->next == NULL)
while (!notify_e) {
for (e = b_revents->head; e; e = e->next) {
if (e->data->e_event == nua_i_notify) {
notify_e = e;
break;
}
}
if (!notify_e)
run_ab_until(ctx, -1, save_until_received, nua_i_notify, save_events);
}
if (a_revents->head->next == NULL)
run_a_until(ctx, -1, save_until_received);
TEST_1(e = a_revents->head->next); TEST_E(e->data->e_event, nua_r_notify);
TEST_1(!e->next);
TEST_1(e = b_revents->head->next->next);
TEST_1(e = notify_e);
TEST_E(e->data->e_event, nua_i_notify);
TEST(e->data->e_status, 200);
TEST_1(sip = sip_object(e->data->e_msg));
......@@ -305,7 +322,6 @@ int test_refer0(struct context *ctx, char const *tests,
TEST_S(sip->sip_subscription_state->ss_substate, "pending");
TEST_1(sip->sip_payload && sip->sip_payload->pl_data);
TEST_S(sip->sip_payload->pl_data, "SIP/2.0 100 Trying\r\n");
TEST_1(!e->next);
}
free_events_in_list(ctx, a_revents);
......
......@@ -1194,7 +1194,7 @@ int test_subscription_timeout(struct context *ctx)
struct endpoint *a = &ctx->a, *b = &ctx->b;
struct call *a_call = a->call, *b_call = b->call;
struct event *e;
struct event *e, *en, *es;
sip_t const *sip;
tagi_t const *n_tags, *r_tags;
......@@ -1220,22 +1220,16 @@ int test_subscription_timeout(struct context *ctx)
/* Client events:
nua_method(), nua_i_notify/nua_r_method, nua_i_notify
*/
TEST_1(e = a->events->head);
if (e->data->e_event == nua_i_notify) {
TEST_E(e->data->e_event, nua_i_notify);
TEST_1(sip = sip_object(e->data->e_msg));
n_tags = e->data->e_tags;
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_subscribe);
r_tags = e->data->e_tags;
}
else {
TEST_E(e->data->e_event, nua_r_method);
TEST(e->data->e_status, 202);
r_tags = e->data->e_tags;
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
TEST_1(sip = sip_object(e->data->e_msg));
n_tags = e->data->e_tags;
}
TEST_1(en = event_by_type(a->events->head, nua_i_notify));
TEST_1(es = event_by_type(a->events->head, nua_r_method));
TEST_1(e = en); TEST_E(e->data->e_event, nua_i_notify);
TEST_1(sip = sip_object(e->data->e_msg));
n_tags = e->data->e_tags;
TEST_1(e = es); TEST_E(e->data->e_event, nua_r_method);
r_tags = e->data->e_tags;
TEST_1(sip->sip_event); TEST_S(sip->sip_event->o_type, "presence");
TEST_1(sip->sip_content_type);
TEST_S(sip->sip_content_type->c_type, "application/pidf+xml");
......@@ -1245,7 +1239,12 @@ int test_subscription_timeout(struct context *ctx)
TEST_1(tl_find(n_tags, nutag_substate));
TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_pending);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
if (es->next == en)
e = en->next;
else
e = es->next;
TEST_1(e); TEST_E(e->data->e_event, nua_i_notify);
n_tags = e->data->e_tags;
TEST_1(tl_find(n_tags, nutag_substate));
TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_terminated);
......
......@@ -89,9 +89,9 @@ int test_events(struct context *ctx)
struct endpoint *a = &ctx->a, *b = &ctx->b;
struct call *a_call = a->call, *b_call = b->call;
struct event *e;
struct event *e, *en, *es;
sip_t const *sip;
tagi_t const *n_tags, *r_tags;
tagi_t const *t, *n_tags, *r_tags;
url_t b_url[1];
nea_sub_t *sub = NULL;
......@@ -206,26 +206,25 @@ int test_events(struct context *ctx)
/* Client events:
nua_subscribe(), nua_i_notify/nua_r_subscribe
*/
TEST_1(e = a->events->head);
if (e->data->e_event == nua_i_notify) {
TEST_E(e->data->e_event, nua_i_notify);
TEST_1(sip = sip_object(e->data->e_msg));
n_tags = e->data->e_tags;
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_subscribe);
r_tags = e->data->e_tags;
TEST_1(tl_find(r_tags, nutag_substate));
TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_active);
TEST_1(en = event_by_type(a->events->head, nua_i_notify));
TEST_1(es = event_by_type(a->events->head, nua_r_subscribe));
TEST_1(e = es); TEST_E(e->data->e_event, nua_r_subscribe);
r_tags = e->data->e_tags;
TEST_1(tl_find(r_tags, nutag_substate));
if (es->next == en) {
TEST_1(200 <= e->data->e_status && e->data->e_status < 300);
TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_embryonic);
}
else {
TEST_E(e->data->e_event, nua_r_subscribe);
TEST(e->data->e_status, 202);
r_tags = e->data->e_tags;
TEST_1(tl_find(r_tags, nutag_substate));
TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_embryonic);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
TEST_1(sip = sip_object(e->data->e_msg));
n_tags = e->data->e_tags;
TEST_1(200 <= e->data->e_status && e->data->e_status < 300);
TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_active);
}
TEST_1(e = en); TEST_E(e->data->e_event, nua_i_notify);
TEST_1(sip = sip_object(e->data->e_msg));
n_tags = e->data->e_tags;
TEST_1(sip->sip_event); TEST_S(sip->sip_event->o_type, "presence");
TEST_1(sip->sip_content_type);
TEST_S(sip->sip_content_type->c_type, "application/pidf+xml");
......@@ -234,7 +233,7 @@ int test_events(struct context *ctx)
TEST_1(sip->sip_subscription_state->ss_expires);
TEST_1(tl_find(n_tags, nutag_substate));
TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_active);
TEST_1(!e->next);
TEST_1(!en->next || !es->next);
free_events_in_list(ctx, a->events);
if (print_headings)
......@@ -302,7 +301,7 @@ int test_events(struct context *ctx)
UNSUBSCRIBE(a, a_call, a_call->nh, TAG_END());
run_ab_until(ctx, -1, save_until_notified_and_responded,
run_ab_until(ctx, -1, save_until_final_response,
-1, NULL /* XXX save_until_received */);
/* Client events:
......@@ -313,26 +312,21 @@ int test_events(struct context *ctx)
TEST_E(e->data->e_event, nua_i_notify);
TEST_1(sip = sip_object(e->data->e_msg));
n_tags = e->data->e_tags;
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_unsubscribe);
TEST_1(tl_find(e->data->e_tags, nutag_substate));
TEST(tl_find(e->data->e_tags, nutag_substate)->t_value,
nua_substate_terminated);
TEST_1(sip->sip_event);
TEST_1(sip->sip_subscription_state);
TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
TEST_1(!sip->sip_subscription_state->ss_expires);
TEST_1(tl_find(n_tags, nutag_substate));
TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_terminated);
TEST_1(e = e->next);
}
else {
TEST_E(e->data->e_event, nua_r_unsubscribe);
TEST(e->data->e_status, 202);
TEST_1(tl_find(e->data->e_tags, nutag_substate));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
TEST_1(sip = sip_object(e->data->e_msg));
n_tags = e->data->e_tags;
}
TEST_1(sip->sip_event);
TEST_1(sip->sip_subscription_state);
TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
TEST_1(!sip->sip_subscription_state->ss_expires);
TEST_1(tl_find(n_tags, nutag_substate));
TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_terminated);
TEST_1(!e->next);
TEST_E(e->data->e_event, nua_r_unsubscribe);
TEST_1(tl_find(e->data->e_tags, nutag_substate));
TEST(tl_find(e->data->e_tags, nutag_substate)->t_value,
nua_substate_terminated);
/* Currently, NOTIFY is dropped after successful response to unsubscribe */
/* But we don't really care.. */
/* TEST_1(!e->next); */
free_events_in_list(ctx, a->events);
if (print_headings)
......@@ -383,26 +377,18 @@ int test_events(struct context *ctx)
/* Client events:
nua_subscribe(), nua_i_notify/nua_r_subscribe
*/
TEST_1(e = a->events->head);
if (e->data->e_event == nua_i_notify) {
TEST_E(e->data->e_event, nua_i_notify);
TEST_1(sip = sip_object(e->data->e_msg));
n_tags = e->data->e_tags;
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_subscribe);
TEST_1(tl_find(e->data->e_tags, nutag_substate));
TEST(tl_find(e->data->e_tags, nutag_substate)->t_value,
nua_substate_pending);
}
else {
TEST_E(e->data->e_event, nua_r_subscribe);
TEST(e->data->e_status, 202);
TEST_1(tl_find(e->data->e_tags, nutag_substate));
TEST(tl_find(e->data->e_tags, nutag_substate)->t_value,
nua_substate_embryonic);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
TEST_1(sip = sip_object(e->data->e_msg));
n_tags = e->data->e_tags;
}
TEST_1(en = event_by_type(a->events->head, nua_i_notify));
TEST_1(es = event_by_type(a->events->head, nua_r_subscribe));
e = es; TEST_E(e->data->e_event, nua_r_subscribe);
TEST_1(t = tl_find(e->data->e_tags, nutag_substate));
TEST_1(t->t_value == nua_substate_pending ||
t->t_value == nua_substate_embryonic);
e = en; TEST_E(e->data->e_event, nua_i_notify);
TEST_1(sip = sip_object(e->data->e_msg));
n_tags = e->data->e_tags;
TEST_1(sip->sip_event); TEST_S(sip->sip_event->o_type, "presence");
TEST_S(sip->sip_event->o_id, "1");
TEST_1(sip->sip_content_type);
......@@ -417,7 +403,7 @@ int test_events(struct context *ctx)
TEST_1(tl_find(n_tags, nutag_substate));
TEST(tl_find(n_tags, nutag_substate)->t_value,
nua_substate_pending);
TEST_1(!e->next);
TEST_1(!en->next || !es->next);
free_events_in_list(ctx, a->events);
/*
......
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