summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-07-12 17:22:20 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-07-12 20:21:42 +0000
commitbeeb9b4335d9ca6f947a52528453753a51f194f3 (patch)
tree242cad42e2e90ebf5ed04283fd79f42f4e3afa60 /auto_tests
parentcbda01021c561bd061cb03a1c1bab58199ac2307 (diff)
Style fixes in TCP code; remove MIN and PAIR from util.h.
* Moved PAIR to toxav, where it's used (but really this should die). * Replace most MIN calls with typed `min_*` calls. Didn't replace the ones where the desired semantics are unclear. Moved the MIN macro to the one place where it's still used. * Avoid assignments in `while` loops. Instead, factored out the loop body into a separate `bool`-returning function. * Use named types for callbacks (`_cb` types). * Avoid assignments in `if` conditions. * Removed `MAKE_REALLOC` and expanded its two calls. We can't have templates in C, and this fake templating is ugly and hard to analyse and debug (it expands on a single line). * Moved epoll system include to the .c file, out of the .h file. * Avoid assignments in expressions (`a = b = c;`). * Avoid multiple declarators per struct member declaration. * Fix naming inconsistencies. * Replace `net_to_host` macro with function.
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/file_transfer_test.c6
-rw-r--r--auto_tests/monolith_test.cc3
-rw-r--r--auto_tests/network_test.c4
3 files changed, 8 insertions, 5 deletions
diff --git a/auto_tests/file_transfer_test.c b/auto_tests/file_transfer_test.c
index c861a3e0..6e8a3c53 100644
--- a/auto_tests/file_transfer_test.c
+++ b/auto_tests/file_transfer_test.c
@@ -286,7 +286,7 @@ static void file_transfer_test(void)
286 printf("after %u iterations: %.2fMiB done\n", (unsigned int)i + 1, (double)size_recv / 1024 / 1024); 286 printf("after %u iterations: %.2fMiB done\n", (unsigned int)i + 1, (double)size_recv / 1024 / 1024);
287 } 287 }
288 288
289 c_sleep(MIN(tox1_interval, MIN(tox2_interval, tox3_interval))); 289 c_sleep(min_u32(tox1_interval, min_u32(tox2_interval, tox3_interval)));
290 } 290 }
291 291
292 ck_assert_msg(file_sending_done, "file sending did not complete after %u iterations: sendf_ok:%u file_recv:%u " 292 ck_assert_msg(file_sending_done, "file sending did not complete after %u iterations: sendf_ok:%u file_recv:%u "
@@ -348,7 +348,7 @@ static void file_transfer_test(void)
348 uint32_t tox2_interval = tox_iteration_interval(tox2); 348 uint32_t tox2_interval = tox_iteration_interval(tox2);
349 uint32_t tox3_interval = tox_iteration_interval(tox3); 349 uint32_t tox3_interval = tox_iteration_interval(tox3);
350 350
351 c_sleep(MIN(tox1_interval, MIN(tox2_interval, tox3_interval))); 351 c_sleep(min_u32(tox1_interval, min_u32(tox2_interval, tox3_interval)));
352 } 352 }
353 353
354 printf("Starting file 0 transfer test.\n"); 354 printf("Starting file 0 transfer test.\n");
@@ -397,7 +397,7 @@ static void file_transfer_test(void)
397 uint32_t tox2_interval = tox_iteration_interval(tox2); 397 uint32_t tox2_interval = tox_iteration_interval(tox2);
398 uint32_t tox3_interval = tox_iteration_interval(tox3); 398 uint32_t tox3_interval = tox_iteration_interval(tox3);
399 399
400 c_sleep(MIN(tox1_interval, MIN(tox2_interval, tox3_interval))); 400 c_sleep(min_u32(tox1_interval, min_u32(tox2_interval, tox3_interval)));
401 } 401 }
402 402
403 printf("file_transfer_test succeeded, took %llu seconds\n", time(nullptr) - cur_time); 403 printf("file_transfer_test succeeded, took %llu seconds\n", time(nullptr) - cur_time);
diff --git a/auto_tests/monolith_test.cc b/auto_tests/monolith_test.cc
index 53b4982e..5c3a1cce 100644
--- a/auto_tests/monolith_test.cc
+++ b/auto_tests/monolith_test.cc
@@ -161,6 +161,9 @@ void check_size(char const *type) {
161 * switch on the PRINT_SIZE above and copy the number into this function. 161 * switch on the PRINT_SIZE above and copy the number into this function.
162 */ 162 */
163int main(int argc, char *argv[]) { 163int main(int argc, char *argv[]) {
164 static_assert(sizeof(uint64_t) >= sizeof(size_t),
165 "Assumption violated: size_t is more than 64 bits wide");
166
164#if defined(__x86_64__) && defined(__LP64__) 167#if defined(__x86_64__) && defined(__LP64__)
165 // toxcore/DHT 168 // toxcore/DHT
166 CHECK_SIZE(Client_data, 496); 169 CHECK_SIZE(Client_data, 496);
diff --git a/auto_tests/network_test.c b/auto_tests/network_test.c
index f9de94f9..dc67e0c0 100644
--- a/auto_tests/network_test.c
+++ b/auto_tests/network_test.c
@@ -144,8 +144,8 @@ START_TEST(test_ip_equal)
144 ip2.ip.v6.uint32[2] = net_htonl(0xFFFF); 144 ip2.ip.v6.uint32[2] = net_htonl(0xFFFF);
145 ip2.ip.v6.uint32[3] = net_htonl(0x7F000001); 145 ip2.ip.v6.uint32[3] = net_htonl(0x7F000001);
146 146
147 ck_assert_msg(IPV6_IPV4_IN_V6(ip2.ip.v6) != 0, 147 ck_assert_msg(ipv6_ipv4_in_v6(ip2.ip.v6) != 0,
148 "IPV6_IPV4_IN_V6(::ffff:127.0.0.1): expected != 0, got 0."); 148 "ipv6_ipv4_in_v6(::ffff:127.0.0.1): expected != 0, got 0.");
149 149
150 res = ip_equal(&ip1, &ip2); 150 res = ip_equal(&ip1, &ip2);
151 ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::ffff:127.0.0.1} ): " 151 ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::ffff:127.0.0.1} ): "