diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-08-25 12:16:54 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-08-25 15:25:33 +0000 |
commit | 94b06818fbd7a93387ff4c155b6eff711651aea9 (patch) | |
tree | 63365adeb88705c5c2f0cdb4d2afd00a4bd8b43c /auto_tests/toxav_many_test.c | |
parent | 0935aab92760a7c9c547faa86c29dcd0d1e03f24 (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/toxav_many_test.c')
-rw-r--r-- | auto_tests/toxav_many_test.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c index a8ed1c80..1cdc0733 100644 --- a/auto_tests/toxav_many_test.c +++ b/auto_tests/toxav_many_test.c | |||
@@ -116,9 +116,9 @@ static void *call_thread(void *pd) | |||
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | while (!BobCC->incoming) { | 119 | do { |
120 | c_sleep(10); | 120 | c_sleep(10); |
121 | } | 121 | } while (!BobCC->incoming); |
122 | 122 | ||
123 | { /* Answer */ | 123 | { /* Answer */ |
124 | TOXAV_ERR_ANSWER rc; | 124 | TOXAV_ERR_ANSWER rc; |
@@ -139,7 +139,7 @@ static void *call_thread(void *pd) | |||
139 | 139 | ||
140 | time_t start_time = time(nullptr); | 140 | time_t start_time = time(nullptr); |
141 | 141 | ||
142 | while (time(nullptr) - start_time < 4) { | 142 | do { |
143 | toxav_iterate(AliceAV); | 143 | toxav_iterate(AliceAV); |
144 | toxav_iterate(BobAV); | 144 | toxav_iterate(BobAV); |
145 | 145 | ||
@@ -150,7 +150,7 @@ static void *call_thread(void *pd) | |||
150 | toxav_video_send_frame(BobAV, 0, 800, 600, video_y, video_u, video_v, nullptr); | 150 | toxav_video_send_frame(BobAV, 0, 800, 600, video_y, video_u, video_v, nullptr); |
151 | 151 | ||
152 | c_sleep(10); | 152 | c_sleep(10); |
153 | } | 153 | } while (time(nullptr) - start_time < 4); |
154 | 154 | ||
155 | { /* Hangup */ | 155 | { /* Hangup */ |
156 | TOXAV_ERR_CALL_CONTROL rc; | 156 | TOXAV_ERR_CALL_CONTROL rc; |
@@ -228,7 +228,7 @@ static void test_av_three_calls(void) | |||
228 | 228 | ||
229 | uint8_t off = 1; | 229 | uint8_t off = 1; |
230 | 230 | ||
231 | while (1) { | 231 | while (true) { |
232 | tox_iterate(bootstrap, nullptr); | 232 | tox_iterate(bootstrap, nullptr); |
233 | tox_iterate(Alice, nullptr); | 233 | tox_iterate(Alice, nullptr); |
234 | tox_iterate(Bobs[0], nullptr); | 234 | tox_iterate(Bobs[0], nullptr); |
@@ -290,14 +290,14 @@ static void test_av_three_calls(void) | |||
290 | 290 | ||
291 | time_t start_time = time(nullptr); | 291 | time_t start_time = time(nullptr); |
292 | 292 | ||
293 | while (time(nullptr) - start_time < 5) { | 293 | do { |
294 | tox_iterate(bootstrap, nullptr); | 294 | tox_iterate(bootstrap, nullptr); |
295 | tox_iterate(Alice, nullptr); | 295 | tox_iterate(Alice, nullptr); |
296 | tox_iterate(Bobs[0], nullptr); | 296 | tox_iterate(Bobs[0], nullptr); |
297 | tox_iterate(Bobs[1], nullptr); | 297 | tox_iterate(Bobs[1], nullptr); |
298 | tox_iterate(Bobs[2], nullptr); | 298 | tox_iterate(Bobs[2], nullptr); |
299 | c_sleep(20); | 299 | c_sleep(20); |
300 | } | 300 | } while (time(nullptr) - start_time < 5); |
301 | 301 | ||
302 | ck_assert(pthread_join(tids[0], &retval) == 0); | 302 | ck_assert(pthread_join(tids[0], &retval) == 0); |
303 | ck_assert(retval == nullptr); | 303 | ck_assert(retval == nullptr); |