summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authorzugz <mbays+tox@sdf.org>2017-01-19 18:51:14 +0100
committerzugz <mbays+tox@sdf.org>2017-01-21 22:08:52 +0100
commitb630121f2f659027e1c9f00cd97087ef34e95677 (patch)
tree7972d498fa05b0955c684c83b79bf12000cb7cf2 /auto_tests
parentf185834e9afe83a2bb06e015a3e41b4ac97b48c3 (diff)
reduce thread-unsafe use of static variables
- rework ip_ntoa() to avoid use of static variables - rework sort_client_list() to avoid use of static variables - move static 'lastdump' into Messenger struct - rework ID2String() to avoid use of static variables; rename to id_to_string() - fetch_broadcast_info(): attempt to mitigate risks from concurrent execution - current_time_monotonic(): attempt to mitigate risks from concurrent execution - comment on non-thread-safety of unix_time_update
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/network_test.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/auto_tests/network_test.c b/auto_tests/network_test.c
index ca918778..2ce6d0b5 100644
--- a/auto_tests/network_test.c
+++ b/auto_tests/network_test.c
@@ -36,7 +36,8 @@ START_TEST(test_addr_resolv_localhost)
36 36
37 if (res > 0) { 37 if (res > 0) {
38 ck_assert_msg(ip.family == AF_INET, "Expected family AF_INET, got %u.", ip.family); 38 ck_assert_msg(ip.family == AF_INET, "Expected family AF_INET, got %u.", ip.family);
39 ck_assert_msg(ip.ip4.uint32 == htonl(0x7F000001), "Expected 127.0.0.1, got %s.", inet_ntoa(ip.ip4.in_addr)); 39 ck_assert_msg(ip.ip4.uint32 == htonl(0x7F000001), "Expected 127.0.0.1, got %s.",
40 inet_ntoa(ip.ip4.in_addr));
40 } 41 }
41 42
42 ip_init(&ip, 1); // ipv6enabled = 1 43 ip_init(&ip, 1); // ipv6enabled = 1
@@ -50,8 +51,10 @@ START_TEST(test_addr_resolv_localhost)
50 ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); 51 ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno));
51 52
52 if (res > 0) { 53 if (res > 0) {
54 char ip_str[IP_NTOA_LEN];
53 ck_assert_msg(ip.family == AF_INET6, "Expected family AF_INET6 (%u), got %u.", AF_INET6, ip.family); 55 ck_assert_msg(ip.family == AF_INET6, "Expected family AF_INET6 (%u), got %u.", AF_INET6, ip.family);
54 ck_assert_msg(!memcmp(&ip.ip6, &in6addr_loopback, sizeof(IP6)), "Expected ::1, got %s.", ip_ntoa(&ip)); 56 ck_assert_msg(!memcmp(&ip.ip6, &in6addr_loopback, sizeof(IP6)), "Expected ::1, got %s.",
57 ip_ntoa(&ip, ip_str, sizeof(ip_str)));
55 } 58 }
56 59
57 if (!localhost_split) { 60 if (!localhost_split) {
@@ -63,8 +66,10 @@ START_TEST(test_addr_resolv_localhost)
63 ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); 66 ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno));
64 67
65 if (res > 0) { 68 if (res > 0) {
69 char ip_str[IP_NTOA_LEN];
66 ck_assert_msg(ip.family == AF_INET6, "Expected family AF_INET6 (%u), got %u.", AF_INET6, ip.family); 70 ck_assert_msg(ip.family == AF_INET6, "Expected family AF_INET6 (%u), got %u.", AF_INET6, ip.family);
67 ck_assert_msg(!memcmp(&ip.ip6, &in6addr_loopback, sizeof(IP6)), "Expected ::1, got %s.", ip_ntoa(&ip)); 71 ck_assert_msg(!memcmp(&ip.ip6, &in6addr_loopback, sizeof(IP6)), "Expected ::1, got %s.",
72 ip_ntoa(&ip, ip_str, sizeof(ip_str)));
68 73
69 ck_assert_msg(extra.family == AF_INET, "Expected family AF_INET (%u), got %u.", AF_INET, extra.family); 74 ck_assert_msg(extra.family == AF_INET, "Expected family AF_INET (%u), got %u.", AF_INET, extra.family);
70 ck_assert_msg(extra.ip4.uint32 == htonl(0x7F000001), "Expected 127.0.0.1, got %s.", inet_ntoa(extra.ip4.in_addr)); 75 ck_assert_msg(extra.ip4.uint32 == htonl(0x7F000001), "Expected 127.0.0.1, got %s.", inet_ntoa(extra.ip4.in_addr));