mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-25 02:55:15 +00:00
Updated user and window tests
This commit is contained in:
parent
49b3232874
commit
e61b38b9a3
16
tests/user.c
16
tests/user.c
@ -28,6 +28,8 @@
|
|||||||
#include "user.h"
|
#include "user.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
|
int debug = 0;
|
||||||
|
|
||||||
START_TEST(test_init_users)
|
START_TEST(test_init_users)
|
||||||
{
|
{
|
||||||
in_addr_t ip;
|
in_addr_t ip;
|
||||||
@ -39,9 +41,9 @@ START_TEST(test_init_users)
|
|||||||
count = init_users(ip, 27);
|
count = init_users(ip, 27);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
fail_unless(users[i].id == i);
|
fail_unless(users[i].id == i);
|
||||||
fail_unless(users[i].q.id == 0);
|
|
||||||
snprintf(givenip, sizeof(givenip), "127.0.0.%d", i + 2);
|
snprintf(givenip, sizeof(givenip), "127.0.0.%d", i + 2);
|
||||||
fail_unless(users[i].tun_ip == inet_addr(givenip));
|
fail_unless(users[i].tun_ip == inet_addr(givenip));
|
||||||
|
fail_if(user_active(i), "user_active true for new users");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
@ -78,28 +80,24 @@ START_TEST(test_find_user_by_ip)
|
|||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
extern unsigned usercount;
|
|
||||||
START_TEST(test_all_users_waiting_to_send)
|
START_TEST(test_all_users_waiting_to_send)
|
||||||
{
|
{
|
||||||
in_addr_t ip;
|
in_addr_t ip;
|
||||||
|
|
||||||
ip = inet_addr("127.0.0.1");
|
ip = inet_addr("127.0.0.1");
|
||||||
init_users(ip, 27);
|
init_users(ip, 27);
|
||||||
for (int i = 0; i < usercount; i++) users[i].outgoing = window_buffer_init(10, 1, 10, WINDOW_SENDING);
|
|
||||||
|
|
||||||
fail_if(all_users_waiting_to_send() == 1);
|
fail_unless(all_users_waiting_to_send() == 0, "empty user list all waiting to send");
|
||||||
|
|
||||||
users[0].conn = CONN_DNS_NULL;
|
users[0].conn = CONN_DNS_NULL;
|
||||||
users[0].active = 1;
|
users[0].active = 1;
|
||||||
|
|
||||||
fail_if(all_users_waiting_to_send() == 1);
|
fail_unless(all_users_waiting_to_send() == 0, "single user with empty buffer waiting to send");
|
||||||
|
|
||||||
users[0].last_pkt = time(NULL);
|
users[0].last_pkt = time(NULL);
|
||||||
|
|
||||||
fail_unless(all_users_waiting_to_send() == 0);
|
fail_unless(all_users_waiting_to_send() == 0, "single active user with empty buffer waiting to send");
|
||||||
|
|
||||||
|
|
||||||
fail_unless(all_users_waiting_to_send() == 1);
|
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
@ -171,7 +169,7 @@ test_user_create_tests()
|
|||||||
tc = tcase_create("User");
|
tc = tcase_create("User");
|
||||||
tcase_add_test(tc, test_init_users);
|
tcase_add_test(tc, test_init_users);
|
||||||
tcase_add_test(tc, test_find_user_by_ip);
|
tcase_add_test(tc, test_find_user_by_ip);
|
||||||
// tcase_add_test(tc, test_all_users_waiting_to_send);
|
tcase_add_test(tc, test_all_users_waiting_to_send);
|
||||||
tcase_add_test(tc, test_find_available_user);
|
tcase_add_test(tc, test_find_available_user);
|
||||||
tcase_add_test(tc, test_find_available_user_small_net);
|
tcase_add_test(tc, test_find_available_user_small_net);
|
||||||
|
|
||||||
|
@ -50,12 +50,12 @@ START_TEST(test_window_everything)
|
|||||||
// warnx("Nothing to send.");
|
// warnx("Nothing to send.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fail_if(!window_process_incoming_fragment(in, f), "Incoming fragment failed!");
|
fail_if((a = window_process_incoming_fragment(in, f)) != f->seqID, "Did not ACK last seqId!");
|
||||||
// warnx("Received fragment with seqid %u, remaining space %lu.", f->seqID, window_buffer_available(in));
|
// warnx("Received fragment with seqid %u, remaining space %lu.", f->seqID, window_buffer_available(in));
|
||||||
int a = window_get_next_ack(in);
|
|
||||||
window_tick(in);
|
window_tick(in);
|
||||||
window_ack(out, a);
|
window_ack(out, a);
|
||||||
window_tick(out);
|
window_tick(out);
|
||||||
|
fail_if(out->start_seq_id != in->start_seq_id, "in/out windows have different start IDs!");
|
||||||
}
|
}
|
||||||
// warnx("Added %lu fragments, reassembling into data.", in->numitems);
|
// warnx("Added %lu fragments, reassembling into data.", in->numitems);
|
||||||
uint8_t data[100];
|
uint8_t data[100];
|
||||||
@ -72,7 +72,7 @@ START_TEST(test_window_everything)
|
|||||||
// printf("%c", data[i]);
|
// printf("%c", data[i]);
|
||||||
// }
|
// }
|
||||||
// printf("'\n");
|
// printf("'\n");
|
||||||
strncat((char *)newdata, data, len);
|
strncat((char *)newdata, (char *)data, len);
|
||||||
if (in->numitems <= 0) break;
|
if (in->numitems <= 0) break;
|
||||||
}
|
}
|
||||||
// printf("New data: '%s' (%lu)\n", newdata, strlen((char *)newdata));
|
// printf("New data: '%s' (%lu)\n", newdata, strlen((char *)newdata));
|
||||||
|
Loading…
Reference in New Issue
Block a user