summaryrefslogtreecommitdiff
path: root/auto_tests/conference_test.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-08-25 12:16:54 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-08-25 15:25:33 +0000
commit94b06818fbd7a93387ff4c155b6eff711651aea9 (patch)
tree63365adeb88705c5c2f0cdb4d2afd00a4bd8b43c /auto_tests/conference_test.c
parent0935aab92760a7c9c547faa86c29dcd0d1e03f24 (diff)
Use do-while instead of while in tests.
This forces all the loop bodies to be executed at least once, which is harmless since it just means one more tox event loop iteration. This reduces the jitter we see in coverage measurements, which is partially caused by loops sometimes being entered and sometimes not (because their condition happens to randomly already be true).
Diffstat (limited to 'auto_tests/conference_test.c')
-rw-r--r--auto_tests/conference_test.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c
index 8f8f9357..235200cd 100644
--- a/auto_tests/conference_test.c
+++ b/auto_tests/conference_test.c
@@ -216,7 +216,7 @@ static void test_many_group(void)
216 printf("waiting for everyone to come online\n"); 216 printf("waiting for everyone to come online\n");
217 unsigned online_count = 0; 217 unsigned online_count = 0;
218 218
219 while (online_count != NUM_GROUP_TOX) { 219 do {
220 online_count = 0; 220 online_count = 0;
221 221
222 for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) { 222 for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) {
@@ -228,7 +228,7 @@ static void test_many_group(void)
228 fflush(stdout); 228 fflush(stdout);
229 229
230 c_sleep(1000); 230 c_sleep(1000);
231 } 231 } while (online_count != NUM_GROUP_TOX);
232 232
233 printf("friends connected, took %d seconds\n", (int)(time(nullptr) - cur_time)); 233 printf("friends connected, took %d seconds\n", (int)(time(nullptr) - cur_time));
234 234
@@ -243,7 +243,7 @@ static void test_many_group(void)
243 printf("waiting for invitations to be made\n"); 243 printf("waiting for invitations to be made\n");
244 uint16_t invited_count = 0; 244 uint16_t invited_count = 0;
245 245
246 while (invited_count != NUM_GROUP_TOX - 1) { 246 do {
247 invited_count = 0; 247 invited_count = 0;
248 248
249 for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) { 249 for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) {
@@ -252,13 +252,13 @@ static void test_many_group(void)
252 } 252 }
253 253
254 c_sleep(50); 254 c_sleep(50);
255 } 255 } while (invited_count != NUM_GROUP_TOX - 1);
256 256
257 cur_time = time(nullptr); 257 cur_time = time(nullptr);
258 printf("waiting for all toxes to be in the group\n"); 258 printf("waiting for all toxes to be in the group\n");
259 uint16_t fully_connected_count = 0; 259 uint16_t fully_connected_count = 0;
260 260
261 while (fully_connected_count != NUM_GROUP_TOX) { 261 do {
262 fully_connected_count = 0; 262 fully_connected_count = 0;
263 printf("current peer counts: ["); 263 printf("current peer counts: [");
264 264
@@ -284,7 +284,7 @@ static void test_many_group(void)
284 fflush(stdout); 284 fflush(stdout);
285 285
286 c_sleep(200); 286 c_sleep(200);
287 } 287 } while (fully_connected_count != NUM_GROUP_TOX);
288 288
289 for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) { 289 for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) {
290 uint32_t peer_count = tox_conference_peer_count(toxes[i], 0, nullptr); 290 uint32_t peer_count = tox_conference_peer_count(toxes[i], 0, nullptr);