diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2014-08-11 23:26:36 +0200 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2014-08-11 23:26:36 +0200 |
commit | 5d8801d4687035ae45143f0f3bc3eeaf75dc17ec (patch) | |
tree | bf4395fd5938eb1865ba90b6e52e169d727d9404 /jni/iodine/tests/user.c | |
parent | 1251ce0d7cf2619f9b41637dcb88bebb66e54fb3 (diff) | |
download | andiodine-5d8801d4687035ae45143f0f3bc3eeaf75dc17ec.tar.gz andiodine-5d8801d4687035ae45143f0f3bc3eeaf75dc17ec.zip |
Upgrade code to iodine 0.7.0 and improve logging
Diffstat (limited to 'jni/iodine/tests/user.c')
-rw-r--r-- | jni/iodine/tests/user.c | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/jni/iodine/tests/user.c b/jni/iodine/tests/user.c index afd61ca..2e4f36d 100644 --- a/jni/iodine/tests/user.c +++ b/jni/iodine/tests/user.c @@ -1,5 +1,6 @@ /* - * Copyright (c) 2006-2009 Bjorn Andersson <flex@kryo.se>, Erik Ekman <yarrick@kryo.se> + * Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>, + * 2006-2009 Bjorn Andersson <flex@kryo.se> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -19,8 +20,8 @@ #include <string.h> #include <time.h> #include <sys/socket.h> -#include <arpa/inet.h> #include <netinet/in.h> +#include <arpa/inet.h> #include "common.h" #include "encoding.h" @@ -32,10 +33,11 @@ START_TEST(test_init_users) in_addr_t ip; char givenip[16]; int i; + int count; ip = inet_addr("127.0.0.1"); - init_users(ip, 27); - for (i = 0; i < USERS; i++) { + count = init_users(ip, 27); + for (i = 0; i < count; i++) { fail_unless(users[i].id == i); fail_unless(users[i].q.id == 0); fail_unless(users[i].inpacket.len == 0); @@ -60,12 +62,12 @@ START_TEST(test_users_waiting) fail_unless(users_waiting_on_reply() == 0); users[3].last_pkt = time(NULL); - + fail_unless(users_waiting_on_reply() == 0); - + users[3].conn = CONN_DNS_NULL; users[3].q.id = 1; - + fail_unless(users_waiting_on_reply() == 1); } END_TEST @@ -81,17 +83,22 @@ START_TEST(test_find_user_by_ip) testip = (unsigned int) inet_addr("10.0.0.1"); fail_unless(find_user_by_ip(testip) == -1); - + testip = (unsigned int) inet_addr("127.0.0.2"); fail_unless(find_user_by_ip(testip) == -1); - + users[0].active = 1; - + testip = (unsigned int) inet_addr("127.0.0.2"); fail_unless(find_user_by_ip(testip) == -1); - + users[0].last_pkt = time(NULL); - + + testip = (unsigned int) inet_addr("127.0.0.2"); + fail_unless(find_user_by_ip(testip) == -1); + + users[0].authenticated = 1; + testip = (unsigned int) inet_addr("127.0.0.2"); fail_unless(find_user_by_ip(testip) == 0); } @@ -105,15 +112,15 @@ START_TEST(test_all_users_waiting_to_send) init_users(ip, 27); fail_unless(all_users_waiting_to_send() == 1); - + users[0].conn = CONN_DNS_NULL; users[0].active = 1; - + fail_unless(all_users_waiting_to_send() == 1); - + users[0].last_pkt = time(NULL); users[0].outpacket.len = 0; - + fail_unless(all_users_waiting_to_send() == 0); #ifdef OUTPACKETQ_LEN @@ -121,7 +128,7 @@ START_TEST(test_all_users_waiting_to_send) #else users[0].outpacket.len = 44; #endif - + fail_unless(all_users_waiting_to_send() == 1); } END_TEST @@ -135,7 +142,11 @@ START_TEST(test_find_available_user) init_users(ip, 27); for (i = 0; i < USERS; i++) { + users[i].authenticated = 1; + users[i].authenticated_raw = 1; fail_unless(find_available_user() == i); + fail_if(users[i].authenticated); + fail_if(users[i].authenticated_raw); } for (i = 0; i < USERS; i++) { @@ -148,7 +159,7 @@ START_TEST(test_find_available_user) fail_unless(find_available_user() == -1); users[3].last_pkt = 55; - + fail_unless(find_available_user() == 3); fail_unless(find_available_user() == -1); } @@ -176,7 +187,7 @@ START_TEST(test_find_available_user_small_net) fail_unless(find_available_user() == -1); users[3].last_pkt = 55; - + fail_unless(find_available_user() == 3); fail_unless(find_available_user() == -1); } |