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
This diff is collapsed.
......@@ -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