|
|
|
|
@ -5,6 +5,7 @@
|
|
|
|
|
#include "../lib/mem.h" |
|
|
|
|
#include "../lib/socket_compat.h" |
|
|
|
|
#include "../lib/platform_compat.h" |
|
|
|
|
#include "test_clock.h" |
|
|
|
|
#include <stdio.h> |
|
|
|
|
#include <string.h> |
|
|
|
|
#include <stdlib.h> |
|
|
|
|
@ -315,7 +316,7 @@ static int run_dial(struct UASYNC *ua, struct socks_cfg *cfg, const char *target
|
|
|
|
|
void *h = socks_dial(ua, cfg, target, tport, dial_cb, NULL, 0); |
|
|
|
|
if (!h) return -1; |
|
|
|
|
int ticks = 0; |
|
|
|
|
while (!g_done && ticks < 20000) { uasync_poll(ua, 10); ticks++; } |
|
|
|
|
while (!g_done && ticks < 20000) { test_clock_poll(ua, 10); ticks++; } |
|
|
|
|
if (!g_done) return -1; |
|
|
|
|
return g_err; |
|
|
|
|
} |
|
|
|
|
@ -337,7 +338,7 @@ static int test1_noauth_v4(void) {
|
|
|
|
|
uint8_t x = 'A'; |
|
|
|
|
send(g_sock, &x, 1, 0); |
|
|
|
|
int ticks = 0; |
|
|
|
|
while (got == 0 && ticks < 5000) { uasync_poll(ua, 10); ticks++; } |
|
|
|
|
while (got == 0 && ticks < 5000) { test_clock_poll(ua, 10); ticks++; } |
|
|
|
|
TASSERT(got == 'A'); |
|
|
|
|
|
|
|
|
|
uasync_remove_socket_t(ua, g_sock); |
|
|
|
|
@ -401,7 +402,7 @@ static int test4_udp_associate(void) {
|
|
|
|
|
TASSERT(su != NULL); |
|
|
|
|
|
|
|
|
|
int ticks = 0; |
|
|
|
|
while (g_su_ready == 0 && ticks < 20000) { uasync_poll(ua, 10); ticks++; } |
|
|
|
|
while (g_su_ready == 0 && ticks < 20000) { test_clock_poll(ua, 10); ticks++; } |
|
|
|
|
TASSERT(g_su_ready == 1); |
|
|
|
|
TASSERT(g_su_err == 0); |
|
|
|
|
TASSERT(m.got_associate == 1); |
|
|
|
|
@ -420,7 +421,7 @@ static int test4_udp_associate(void) {
|
|
|
|
|
while (ticks < 5000) { |
|
|
|
|
got = recvfrom(lfd, raw, sizeof(raw), 0, (struct sockaddr *)&from, &fl); |
|
|
|
|
if (got > 0) break; |
|
|
|
|
uasync_poll(ua, 10); ticks++; |
|
|
|
|
test_clock_poll(ua, 10); ticks++; |
|
|
|
|
} |
|
|
|
|
TASSERT(got > 0); |
|
|
|
|
|
|
|
|
|
@ -459,7 +460,7 @@ static int test5_udp_reassociate(void) {
|
|
|
|
|
TASSERT(su != NULL); |
|
|
|
|
|
|
|
|
|
int ticks = 0; |
|
|
|
|
while (g_su_ready == 0 && ticks < 20000) { uasync_poll(ua, 10); ticks++; } |
|
|
|
|
while (g_su_ready == 0 && ticks < 20000) { test_clock_poll(ua, 10); ticks++; } |
|
|
|
|
TASSERT(g_su_ready == 1); |
|
|
|
|
TASSERT(m.got_associate == 1); |
|
|
|
|
|
|
|
|
|
@ -469,7 +470,7 @@ static int test5_udp_reassociate(void) {
|
|
|
|
|
|
|
|
|
|
int ready_before = g_su_ready; |
|
|
|
|
ticks = 0; |
|
|
|
|
while (g_su_ready == ready_before && ticks < 50000) { uasync_poll(ua, 10); ticks++; } // backoff ~1с
|
|
|
|
|
while (g_su_ready == ready_before && ticks < 50000) { test_clock_poll(ua, 10); ticks++; } // backoff ~1с
|
|
|
|
|
TASSERT(g_su_ready > ready_before); |
|
|
|
|
TASSERT(m.got_associate >= 2); |
|
|
|
|
|
|
|
|
|
@ -486,7 +487,7 @@ static int test5_udp_reassociate(void) {
|
|
|
|
|
while (ticks < 5000) { |
|
|
|
|
got = recvfrom(lfd, raw, sizeof(raw), 0, (struct sockaddr *)&from, &fl); |
|
|
|
|
if (got > 0) break; |
|
|
|
|
uasync_poll(ua, 10); ticks++; |
|
|
|
|
test_clock_poll(ua, 10); ticks++; |
|
|
|
|
} |
|
|
|
|
TASSERT(got > 0); |
|
|
|
|
uint8_t payload[256]; |
|
|
|
|
@ -503,7 +504,9 @@ static int test5_udp_reassociate(void) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int main(void) { |
|
|
|
|
debug_config_init(); |
|
|
|
|
debug_set_level(DEBUG_LEVEL_ERROR); |
|
|
|
|
test_clock_init(1000); |
|
|
|
|
socket_platform_init(); |
|
|
|
|
|
|
|
|
|
struct { const char *name; int (*fn)(void); } tests[] = { |
|
|
|
|
@ -523,5 +526,6 @@ int main(void) {
|
|
|
|
|
} |
|
|
|
|
socket_platform_cleanup(); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "Results: %d/%d passed", passed, n); |
|
|
|
|
test_clock_finish(); |
|
|
|
|
return passed == n ? 0 : 1; |
|
|
|
|
} |
|
|
|
|
|