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/run_auto_test.h | |
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/run_auto_test.h')
-rw-r--r-- | auto_tests/run_auto_test.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/auto_tests/run_auto_test.h b/auto_tests/run_auto_test.h index 04d24791..ad89992a 100644 --- a/auto_tests/run_auto_test.h +++ b/auto_tests/run_auto_test.h | |||
@@ -72,19 +72,19 @@ static void run_auto_test(uint32_t tox_count, void test(Tox **toxes, State *stat | |||
72 | tox_bootstrap(toxes[i], "localhost", dht_port, dht_key, nullptr); | 72 | tox_bootstrap(toxes[i], "localhost", dht_port, dht_key, nullptr); |
73 | } | 73 | } |
74 | 74 | ||
75 | while (!all_connected(tox_count, toxes)) { | 75 | do { |
76 | iterate_all(tox_count, toxes, state); | 76 | iterate_all(tox_count, toxes, state); |
77 | 77 | ||
78 | c_sleep(ITERATION_INTERVAL); | 78 | c_sleep(ITERATION_INTERVAL); |
79 | } | 79 | } while (!all_connected(tox_count, toxes)); |
80 | 80 | ||
81 | printf("toxes are online\n"); | 81 | printf("toxes are online\n"); |
82 | 82 | ||
83 | while (!all_friends_connected(tox_count, toxes)) { | 83 | do { |
84 | iterate_all(tox_count, toxes, state); | 84 | iterate_all(tox_count, toxes, state); |
85 | 85 | ||
86 | c_sleep(ITERATION_INTERVAL); | 86 | c_sleep(ITERATION_INTERVAL); |
87 | } | 87 | } while (!all_friends_connected(tox_count, toxes)); |
88 | 88 | ||
89 | printf("tox clients connected\n"); | 89 | printf("tox clients connected\n"); |
90 | 90 | ||