diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-07-17 01:18:04 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-07-22 02:34:30 +0000 |
commit | f627a26a7b1c3619ba66f84b87092ff8ba7a95b6 (patch) | |
tree | c72c950fab473dc9bec4b5329d251b790e55443d /auto_tests/tox_many_test.c | |
parent | 7245ac11ef9be2420c8356c12acc79f93ea211bb (diff) |
Run Clang global static analysis on Travis.
This uses a single .cc file containing almost all the code in the
repository to perform whole program analysis.
Diffstat (limited to 'auto_tests/tox_many_test.c')
-rw-r--r-- | auto_tests/tox_many_test.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/auto_tests/tox_many_test.c b/auto_tests/tox_many_test.c index ff217e87..49933234 100644 --- a/auto_tests/tox_many_test.c +++ b/auto_tests/tox_many_test.c | |||
@@ -24,16 +24,16 @@ static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8 | |||
24 | } | 24 | } |
25 | 25 | ||
26 | 26 | ||
27 | #define NUM_TOXES 90 | 27 | #define TCP_TEST_NUM_TOXES 90 |
28 | #define NUM_FRIENDS 50 | 28 | #define TCP_TEST_NUM_FRIENDS 50 |
29 | 29 | ||
30 | static void test_many_clients(void) | 30 | static void test_many_clients(void) |
31 | { | 31 | { |
32 | time_t cur_time = time(nullptr); | 32 | time_t cur_time = time(nullptr); |
33 | Tox *toxes[NUM_TOXES]; | 33 | Tox *toxes[TCP_TEST_NUM_TOXES]; |
34 | uint32_t index[NUM_TOXES]; | 34 | uint32_t index[TCP_TEST_NUM_TOXES]; |
35 | 35 | ||
36 | for (uint32_t i = 0; i < NUM_TOXES; ++i) { | 36 | for (uint32_t i = 0; i < TCP_TEST_NUM_TOXES; ++i) { |
37 | index[i] = i + 1; | 37 | index[i] = i + 1; |
38 | toxes[i] = tox_new_log(nullptr, nullptr, &index[i]); | 38 | toxes[i] = tox_new_log(nullptr, nullptr, &index[i]); |
39 | ck_assert_msg(toxes[i] != nullptr, "failed to create tox instances %u", i); | 39 | ck_assert_msg(toxes[i] != nullptr, "failed to create tox instances %u", i); |
@@ -43,22 +43,22 @@ static void test_many_clients(void) | |||
43 | struct { | 43 | struct { |
44 | uint16_t tox1; | 44 | uint16_t tox1; |
45 | uint16_t tox2; | 45 | uint16_t tox2; |
46 | } pairs[NUM_FRIENDS]; | 46 | } pairs[TCP_TEST_NUM_FRIENDS]; |
47 | 47 | ||
48 | uint8_t address[TOX_ADDRESS_SIZE]; | 48 | uint8_t address[TOX_ADDRESS_SIZE]; |
49 | 49 | ||
50 | uint32_t num_f = 0; | 50 | uint32_t num_f = 0; |
51 | 51 | ||
52 | for (uint32_t i = 0; i < NUM_TOXES; ++i) { | 52 | for (uint32_t i = 0; i < TCP_TEST_NUM_TOXES; ++i) { |
53 | num_f += tox_self_get_friend_list_size(toxes[i]); | 53 | num_f += tox_self_get_friend_list_size(toxes[i]); |
54 | } | 54 | } |
55 | 55 | ||
56 | ck_assert_msg(num_f == 0, "bad num friends: %u", num_f); | 56 | ck_assert_msg(num_f == 0, "bad num friends: %u", num_f); |
57 | 57 | ||
58 | for (uint32_t i = 0; i < NUM_FRIENDS; ++i) { | 58 | for (uint32_t i = 0; i < TCP_TEST_NUM_FRIENDS; ++i) { |
59 | loop_top: | 59 | loop_top: |
60 | pairs[i].tox1 = random_u32() % NUM_TOXES; | 60 | pairs[i].tox1 = random_u32() % TCP_TEST_NUM_TOXES; |
61 | pairs[i].tox2 = (pairs[i].tox1 + random_u32() % (NUM_TOXES - 1) + 1) % NUM_TOXES; | 61 | pairs[i].tox2 = (pairs[i].tox1 + random_u32() % (TCP_TEST_NUM_TOXES - 1) + 1) % TCP_TEST_NUM_TOXES; |
62 | 62 | ||
63 | for (uint32_t j = 0; j < i; ++j) { | 63 | for (uint32_t j = 0; j < i; ++j) { |
64 | if (pairs[j].tox2 == pairs[i].tox1 && pairs[j].tox1 == pairs[i].tox2) { | 64 | if (pairs[j].tox2 == pairs[i].tox1 && pairs[j].tox1 == pairs[i].tox2) { |
@@ -84,18 +84,18 @@ loop_top: | |||
84 | ck_assert_msg(num != UINT32_MAX && test == TOX_ERR_FRIEND_ADD_OK, "failed to add friend error code: %i", test); | 84 | ck_assert_msg(num != UINT32_MAX && test == TOX_ERR_FRIEND_ADD_OK, "failed to add friend error code: %i", test); |
85 | } | 85 | } |
86 | 86 | ||
87 | for (uint32_t i = 0; i < NUM_TOXES; ++i) { | 87 | for (uint32_t i = 0; i < TCP_TEST_NUM_TOXES; ++i) { |
88 | num_f += tox_self_get_friend_list_size(toxes[i]); | 88 | num_f += tox_self_get_friend_list_size(toxes[i]); |
89 | } | 89 | } |
90 | 90 | ||
91 | ck_assert_msg(num_f == NUM_FRIENDS, "bad num friends: %u", num_f); | 91 | ck_assert_msg(num_f == TCP_TEST_NUM_FRIENDS, "bad num friends: %u", num_f); |
92 | 92 | ||
93 | uint16_t last_count = 0; | 93 | uint16_t last_count = 0; |
94 | 94 | ||
95 | while (1) { | 95 | while (1) { |
96 | uint16_t counter = 0; | 96 | uint16_t counter = 0; |
97 | 97 | ||
98 | for (uint32_t i = 0; i < NUM_TOXES; ++i) { | 98 | for (uint32_t i = 0; i < TCP_TEST_NUM_TOXES; ++i) { |
99 | for (uint32_t j = 0; j < tox_self_get_friend_list_size(toxes[i]); ++j) { | 99 | for (uint32_t j = 0; j < tox_self_get_friend_list_size(toxes[i]); ++j) { |
100 | if (tox_friend_get_connection_status(toxes[i], j, nullptr) == TOX_CONNECTION_UDP) { | 100 | if (tox_friend_get_connection_status(toxes[i], j, nullptr) == TOX_CONNECTION_UDP) { |
101 | ++counter; | 101 | ++counter; |
@@ -108,18 +108,18 @@ loop_top: | |||
108 | last_count = counter; | 108 | last_count = counter; |
109 | } | 109 | } |
110 | 110 | ||
111 | if (counter == NUM_FRIENDS * 2) { | 111 | if (counter == TCP_TEST_NUM_FRIENDS * 2) { |
112 | break; | 112 | break; |
113 | } | 113 | } |
114 | 114 | ||
115 | for (uint32_t i = 0; i < NUM_TOXES; ++i) { | 115 | for (uint32_t i = 0; i < TCP_TEST_NUM_TOXES; ++i) { |
116 | tox_iterate(toxes[i], nullptr); | 116 | tox_iterate(toxes[i], nullptr); |
117 | } | 117 | } |
118 | 118 | ||
119 | c_sleep(50); | 119 | c_sleep(50); |
120 | } | 120 | } |
121 | 121 | ||
122 | for (uint32_t i = 0; i < NUM_TOXES; ++i) { | 122 | for (uint32_t i = 0; i < TCP_TEST_NUM_TOXES; ++i) { |
123 | tox_kill(toxes[i]); | 123 | tox_kill(toxes[i]); |
124 | } | 124 | } |
125 | 125 | ||