From 94b06818fbd7a93387ff4c155b6eff711651aea9 Mon Sep 17 00:00:00 2001 From: iphydf Date: Sat, 25 Aug 2018 12:16:54 +0000 Subject: 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). --- auto_tests/run_auto_test.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'auto_tests/run_auto_test.h') 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 tox_bootstrap(toxes[i], "localhost", dht_port, dht_key, nullptr); } - while (!all_connected(tox_count, toxes)) { + do { iterate_all(tox_count, toxes, state); c_sleep(ITERATION_INTERVAL); - } + } while (!all_connected(tox_count, toxes)); printf("toxes are online\n"); - while (!all_friends_connected(tox_count, toxes)) { + do { iterate_all(tox_count, toxes, state); c_sleep(ITERATION_INTERVAL); - } + } while (!all_friends_connected(tox_count, toxes)); printf("tox clients connected\n"); -- cgit v1.2.3