summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authorzugz (tox) <mbays+tox@sdf.org>2018-09-19 20:07:02 +0200
committerzugz (tox) <mbays+tox@sdf.org>2018-09-20 22:30:28 +0200
commite43b2eadc003179c0f14e948ce6293bffde34188 (patch)
tree39b9089ca64149b65d2906d10bc6e54b78de2e9c /auto_tests
parentd3d5b701cb940e5f6c7cb2af199428fc8224e665 (diff)
Send rejoin packets on conference disconnection
We were mistakenly not making a rejoin attempt on freezing connections due to all closest connections going down. This fixes that, and tweaks the test. I've still only done tens rather than hundreds of tests, but I'm fairly confident that the conference test now consistently passes.
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/conference_test.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c
index fb6e7ca8..824592c6 100644
--- a/auto_tests/conference_test.c
+++ b/auto_tests/conference_test.c
@@ -129,6 +129,22 @@ static bool all_connected_to_group(uint32_t tox_count, Tox **toxes)
129 return true; 129 return true;
130} 130}
131 131
132static bool names_propagated(uint32_t tox_count, Tox **toxes, State *state)
133{
134 for (uint16_t i = 0; i < tox_count; ++i) {
135 for (uint16_t j = 0; j < tox_count; ++j) {
136 const size_t len = tox_conference_peer_get_name_size(toxes[i], 0, j, nullptr);
137
138 if (len != NAMELEN) {
139 return false;
140 }
141 }
142 }
143
144 return true;
145}
146
147
132/* returns a random index at which a list of booleans is false 148/* returns a random index at which a list of booleans is false
133 * (some such index is required to exist) 149 * (some such index is required to exist)
134 * */ 150 * */
@@ -145,9 +161,9 @@ static uint32_t random_false_index(bool *list, const uint32_t length)
145 161
146static void run_conference_tests(Tox **toxes, State *state) 162static void run_conference_tests(Tox **toxes, State *state)
147{ 163{
148 /* disabling name propagation check for now, as it occasionally fails due 164 /* disabling name change propagation check for now, as it occasionally
149 * to disconnections too short to trigger freezing */ 165 * fails due to disconnections too short to trigger freezing */
150 const bool check_name_propagation = false; 166 const bool check_name_change_propagation = false;
151 167
152 printf("letting random toxes timeout\n"); 168 printf("letting random toxes timeout\n");
153 bool disconnected[NUM_GROUP_TOX] = {0}; 169 bool disconnected[NUM_GROUP_TOX] = {0};
@@ -171,7 +187,7 @@ static void run_conference_tests(Tox **toxes, State *state)
171 c_sleep(20); 187 c_sleep(20);
172 } while (!toxes_are_disconnected_from_group(NUM_GROUP_TOX, toxes, NUM_DISCONNECT, disconnected)); 188 } while (!toxes_are_disconnected_from_group(NUM_GROUP_TOX, toxes, NUM_DISCONNECT, disconnected));
173 189
174 if (check_name_propagation) { 190 if (check_name_change_propagation) {
175 printf("changing names\n"); 191 printf("changing names\n");
176 192
177 for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) { 193 for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) {
@@ -191,6 +207,8 @@ static void run_conference_tests(Tox **toxes, State *state)
191 207
192 for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) { 208 for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) {
193 tox_callback_conference_message(toxes[i], &handle_conference_message); 209 tox_callback_conference_message(toxes[i], &handle_conference_message);
210
211 iterate_all_wait(NUM_GROUP_TOX, toxes, state, ITERATION_INTERVAL);
194 } 212 }
195 213
196 TOX_ERR_CONFERENCE_SEND_MESSAGE err; 214 TOX_ERR_CONFERENCE_SEND_MESSAGE err;
@@ -208,13 +226,9 @@ static void run_conference_tests(Tox **toxes, State *state)
208 226
209 ck_assert_msg(num_recv == NUM_GROUP_TOX, "failed to recv group messages"); 227 ck_assert_msg(num_recv == NUM_GROUP_TOX, "failed to recv group messages");
210 228
211 for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) { 229 if (check_name_change_propagation) {
212 for (uint16_t j = 0; j < NUM_GROUP_TOX; ++j) { 230 for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) {
213 const size_t len = tox_conference_peer_get_name_size(toxes[i], 0, j, nullptr); 231 for (uint16_t j = 0; j < NUM_GROUP_TOX; ++j) {
214 ck_assert_msg(len == NAMELEN, "name of #%u according to #%u has incorrect length %u", state[j].index, state[i].index,
215 (unsigned int)len);
216
217 if (check_name_propagation) {
218 uint8_t name[NAMELEN]; 232 uint8_t name[NAMELEN];
219 tox_conference_peer_get_name(toxes[i], 0, j, name, nullptr); 233 tox_conference_peer_get_name(toxes[i], 0, j, name, nullptr);
220 /* Note the toxes will have been reordered */ 234 /* Note the toxes will have been reordered */
@@ -321,6 +335,12 @@ static void test_many_group(Tox **toxes, State *state)
321 ck_assert_msg(memcmp("Gentoo", title, ret) == 0, "Wrong title"); 335 ck_assert_msg(memcmp("Gentoo", title, ret) == 0, "Wrong title");
322 } 336 }
323 337
338 printf("waiting for names to propagate\n");
339
340 do {
341 iterate_all_wait(NUM_GROUP_TOX, toxes, state, ITERATION_INTERVAL);
342 } while (!names_propagated(NUM_GROUP_TOX, toxes, state));
343
324 printf("group connected, took %d seconds\n", (int)((state[0].clock - pregroup_clock) / 1000)); 344 printf("group connected, took %d seconds\n", (int)((state[0].clock - pregroup_clock) / 1000));
325 345
326 run_conference_tests(toxes, state); 346 run_conference_tests(toxes, state);