Commit df8d142e authored by Pekka Pessi's avatar Pekka Pessi

Fixed various tests on win32.

darcs-hash:20071012173951-88462-b6b864d1867da300d525cf1a339dd88d5de81d01.gz
parent ba992e45
......@@ -330,8 +330,6 @@ int main(int argc, char *argv[])
ctx->a.printer = o_events_init ? print_event : NULL;
sleep(2);
retval |= test_nua_api_errors(ctx); SINGLE_FAILURE_CHECK();
retval |= test_tag_filter(); SINGLE_FAILURE_CHECK();
......
......@@ -99,6 +99,7 @@ int test_events(struct context *ctx)
sip_t const *sip;
tagi_t const *t, *n_tags, *r_tags;
url_t b_url[1];
enum nua_substate substate;
nea_sub_t *sub = NULL;
char const open[] =
......@@ -308,7 +309,7 @@ int test_events(struct context *ctx)
UNSUBSCRIBE(a, a_call, a_call->nh, TAG_END());
run_ab_until(ctx, -1, save_until_final_response,
-1, NULL /* XXX save_until_received */);
-1, save_until_subscription);
/* Client events:
nua_unsubscribe(), nua_i_notify/nua_r_unsubscribe
......@@ -335,6 +336,19 @@ int test_events(struct context *ctx)
/* TEST_1(!e->next); */
free_events_in_list(ctx, a->events);
/* Server events: nua_i_subscription with terminated status */
TEST_1(e = b->events->head);
TEST_E(e->data->e_event, nua_i_subscription);
TEST(tl_gets(e->data->e_tags,
NEATAG_SUB_REF(sub),
NUTAG_SUBSTATE_REF(substate),
TAG_END()), 2);
TEST_1(sub);
TEST(substate, nua_substate_terminated);
TEST_1(!e->next);
free_events_in_list(ctx, b->events);
if (print_headings)
printf("TEST NUA-12.5: PASSED\n");
......
......@@ -52,7 +52,7 @@ struct pinger;
#include <assert.h>
char const name[] = "su_test";
char const name[] = "test_su";
#if HAVE_FUNC
#define enter (void)SU_DEBUG_9(("%s: %s: entering\n", name, __func__))
......@@ -64,7 +64,7 @@ char const name[] = "su_test";
#else
#define enter ((void)0)
#define nh_enter ((void)0)
#define __func__ "su_test"
#define __func__ "test_su"
#endif
struct pinger {
......
......@@ -165,6 +165,8 @@ void *suspend_resume_test_thread(void *_rt)
{
root_test_t *rt = _rt;
su_init();
pthread_mutex_lock(rt->rt_sr.mutex);
rt->rt_root = su_root_create(rt);
rt->rt_sr.done = 1;
......@@ -177,6 +179,9 @@ void *suspend_resume_test_thread(void *_rt)
su_root_destroy(rt->rt_root);
rt->rt_root = NULL;
pthread_mutex_unlock(rt->rt_sr.deinit);
su_deinit();
return NULL;
}
#endif
......@@ -192,8 +197,6 @@ int init_test(root_test_t *rt,
BEGIN();
su_init();
su_port_prefer(create, start);
#if SU_HAVE_PTHREADS
......@@ -257,8 +260,6 @@ static int deinit_test(root_test_t *rt)
TEST_VOID(su_root_destroy(rt->rt_root)); rt->rt_root = NULL;
#endif
su_deinit();
END();
}
......@@ -724,6 +725,8 @@ int main(int argc, char *argv[])
i = 0;
su_init();
do {
rt = rt1, *rt = *rt0;
......@@ -739,5 +742,7 @@ int main(int argc, char *argv[])
retval |= deinit_test(rt);
} while (prefer[++i].create);
su_deinit();
return retval;
}
......@@ -824,7 +824,7 @@ static int tcp_test(tp_test_t *tt)
BEGIN();
msg_t *msg = NULL;
int i;
int i, N;
tport_t *tp, *tp0;
char ident[16];
su_time_t started;
......@@ -853,12 +853,15 @@ static int tcp_test(tp_test_t *tt)
pending_server_close = tport_pend(tp, NULL, server_closed_callback, NULL);
TEST_1(pending_server_close > 0);
N = 0; tt->tt_received = 0;
#ifndef WIN32 /* Windows seems to be buffering too much */
/* Create a large message, just to force queueing in sending end */
TEST(new_test_msg(tt, &msg, "tcp-0", 1, 16 * 64 * 1024), 0);
test_create_md5(tt, msg);
TEST_1(tp = tport_tsend(tt->tt_tports, msg, tt->tt_tcp_name, TAG_END()));
N++;
TEST_S(tport_name(tp)->tpn_ident, "client");
TEST_P(tport_incref(tp), tp0); tport_decref(&tp);
msg_destroy(msg);
......@@ -869,6 +872,7 @@ static int tcp_test(tp_test_t *tt)
TEST(new_test_msg(tt, &msg, ident, 1, 64 * 1024), 0);
TEST_1(tp = tport_tsend(tt->tt_tports, msg, tt->tt_tcp_name, TAG_END()));
N++;
TEST_S(tport_name(tp)->tpn_ident, "client");
TEST_P(tport_incref(tp), tp0); tport_decref(&tp);
msg_destroy(msg);
......@@ -879,8 +883,6 @@ static int tcp_test(tp_test_t *tt)
TEST_1(!tport_tsend(tt->tt_tports, msg, tt->tt_tcp_name, TAG_END()));
msg_destroy(msg);
tt->tt_received = 0;
TEST(tport_test_run(tt, 60), 1);
TEST_1(!check_msg(tt, tt->tt_rmsg, "tcp-0"));
test_check_md5(tt, tt->tt_rmsg);
......@@ -892,13 +894,15 @@ static int tcp_test(tp_test_t *tt)
TEST_1(!check_msg(tt, tt->tt_rmsg, ident));
msg_destroy(tt->tt_rmsg), tt->tt_rmsg = NULL;
}
#else
(void)i; (void)ident;
#endif
/* This uses a new connection */
TEST_1(!new_test_msg(tt, &msg, "tcp-no-reuse", 1, 1024));
TEST_1(tp = tport_tsend(tt->tt_tports, msg, tt->tt_tcp_name,
TPTAG_REUSE(0), TAG_END()));
N++;
TEST_S(tport_name(tp)->tpn_ident, "client");
TEST_1(tport_incref(tp) != tp0); tport_decref(&tp);
msg_destroy(msg);
......@@ -907,12 +911,13 @@ static int tcp_test(tp_test_t *tt)
TEST_1(!new_test_msg(tt, &msg, "tcp-reuse", 1, 1024));
TEST_1(tp = tport_tsend(tt->tt_tports, msg, tt->tt_tcp_name,
TPTAG_REUSE(1), TAG_END()));
N++;
TEST_S(tport_name(tp)->tpn_ident, "client");
TEST_1(tport_incref(tp) == tp0); tport_decref(&tp);
msg_destroy(msg);
/* Receive every message from queue */
while (tt->tt_received < TPORT_QUEUESIZE + 2) {
while (tt->tt_received < N) {
TEST(tport_test_run(tt, 5), 1);
/* Validate message */
TEST_1(!check_msg(tt, tt->tt_rmsg, NULL));
......@@ -1005,7 +1010,7 @@ static int test_incomplete(tp_test_t *tt)
s = su_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
TEST_1(s != SOCKET_ERROR);
connected = connect(s, ai->ai_addr, ai->ai_addrlen);
connected = connect(s, ai->ai_addr, (socklen_t)ai->ai_addrlen);
su_root_step(tt->tt_root, 50);
......
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