Commit bfa5b926 authored by Ghislain MARY's avatar Ghislain MARY

Lower timeout for resolver timeout test.

parent d5f56712
......@@ -43,20 +43,22 @@ BELLESIP_EXPORT belle_sip_stack_t * belle_sip_stack_new(const char *properties);
BELLESIP_EXPORT belle_sip_listening_point_t *belle_sip_stack_create_listening_point(belle_sip_stack_t *s, const char *ipaddress, int port, const char *transport);
void belle_sip_stack_delete_listening_point(belle_sip_stack_t *s, belle_sip_listening_point_t *lp);
BELLESIP_EXPORT void belle_sip_stack_delete_listening_point(belle_sip_stack_t *s, belle_sip_listening_point_t *lp);
BELLESIP_EXPORT belle_sip_provider_t *belle_sip_stack_create_provider(belle_sip_stack_t *s, belle_sip_listening_point_t *lp);
BELLESIP_EXPORT belle_sip_main_loop_t* belle_sip_stack_get_main_loop(belle_sip_stack_t *stack);
void belle_sip_stack_main(belle_sip_stack_t *stack);
BELLESIP_EXPORT void belle_sip_stack_main(belle_sip_stack_t *stack);
BELLESIP_EXPORT void belle_sip_stack_sleep(belle_sip_stack_t *stack, unsigned int milliseconds);
int belle_sip_stack_get_transport_timeout(const belle_sip_stack_t *stack);
BELLESIP_EXPORT int belle_sip_stack_get_transport_timeout(const belle_sip_stack_t *stack);
BELLESIP_EXPORT int belle_sip_stack_get_dns_timeout(const belle_sip_stack_t *stack);
BELLESIP_EXPORT void belle_sip_stack_set_dns_timeout(belle_sip_stack_t *stack, int timeout);
void belle_sip_hop_free(belle_sip_hop_t *hop);
/**
......
......@@ -50,6 +50,10 @@ int belle_sip_stack_get_dns_timeout(const belle_sip_stack_t *stack) {
return stack->dns_timeout;
}
void belle_sip_stack_set_dns_timeout(belle_sip_stack_t *stack, int timeout) {
stack->dns_timeout = timeout;
}
belle_sip_listening_point_t *belle_sip_stack_create_listening_point(belle_sip_stack_t *s, const char *ipaddress, int port, const char *transport){
belle_sip_listening_point_t *lp=NULL;
if (strcasecmp(transport,"UDP")==0) {
......
......@@ -38,9 +38,11 @@ typedef struct endpoint {
} endpoint_t;
static unsigned int wait_for(belle_sip_stack_t *stack, int *current_value, int expected_value, int timeout) {
int retry = 0;
#define ITER 100
while ((*current_value != expected_value) && (retry++ < (timeout / ITER))) {
uint64_t begin, end;
begin = belle_sip_time_ms();
end = begin + timeout;
while ((*current_value != expected_value) && (belle_sip_time_ms() < end)) {
if (stack) belle_sip_stack_sleep(stack, ITER);
}
if (*current_value != expected_value) return FALSE;
......@@ -134,15 +136,15 @@ static void ipv4_a_query_send_failure(void) {
/* IPv4 A query timeout */
static void ipv4_a_query_timeout(void) {
int timeout;
int timeout = 500;
endpoint_t *client = create_endpoint();
CU_ASSERT_PTR_NOT_NULL_FATAL(client);
timeout = belle_sip_stack_get_dns_timeout(client->stack);
belle_sip_stack_set_resolver_tx_delay(client->stack, timeout + 4000);
belle_sip_stack_set_dns_timeout(client->stack, timeout);
belle_sip_stack_set_resolver_tx_delay(client->stack, timeout * 4);
client->resolver_id = belle_sip_resolve(client->stack, IPV4_SIP_DOMAIN, SIP_PORT, AF_INET, resolve_done, client, belle_sip_stack_get_main_loop(client->stack));
CU_ASSERT_NOT_EQUAL(client->resolver_id, 0);
CU_ASSERT_FALSE(wait_for(client->stack, &client->resolve_done, 1, timeout + 2000));
CU_ASSERT_FALSE(wait_for(client->stack, &client->resolve_done, 1, timeout * 2));
CU_ASSERT_PTR_EQUAL(client->result, NULL);
belle_sip_stack_set_resolver_tx_delay(client->stack, 0);
......
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