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/lan_discovery_test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'auto_tests/lan_discovery_test.c') diff --git a/auto_tests/lan_discovery_test.c b/auto_tests/lan_discovery_test.c index 28a5ddf0..69bf8e31 100644 --- a/auto_tests/lan_discovery_test.c +++ b/auto_tests/lan_discovery_test.c @@ -16,15 +16,15 @@ int main(void) printf("Waiting for LAN discovery. This loop will attempt to run until successful."); - while (tox_self_get_connection_status(tox1) == TOX_CONNECTION_NONE || - tox_self_get_connection_status(tox2) == TOX_CONNECTION_NONE) { + do { printf("."); fflush(stdout); tox_iterate(tox1, nullptr); tox_iterate(tox2, nullptr); c_sleep(1000); - } + } while (tox_self_get_connection_status(tox1) == TOX_CONNECTION_NONE || + tox_self_get_connection_status(tox2) == TOX_CONNECTION_NONE); printf(" %d <-> %d\n", tox_self_get_connection_status(tox1), -- cgit v1.2.3