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/lossy_packet_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/lossy_packet_test.c')
-rw-r--r-- | auto_tests/lossy_packet_test.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/auto_tests/lossy_packet_test.c b/auto_tests/lossy_packet_test.c index ef4ff7bf..51081a39 100644 --- a/auto_tests/lossy_packet_test.c +++ b/auto_tests/lossy_packet_test.c | |||
@@ -46,11 +46,11 @@ static void test_lossy_packet(Tox **toxes, State *state) | |||
46 | ret = tox_friend_send_lossy_packet(toxes[0], 0, packet, TOX_MAX_CUSTOM_PACKET_SIZE, nullptr); | 46 | ret = tox_friend_send_lossy_packet(toxes[0], 0, packet, TOX_MAX_CUSTOM_PACKET_SIZE, nullptr); |
47 | ck_assert_msg(ret == true, "tox_friend_send_lossy_packet fail %i", ret); | 47 | ck_assert_msg(ret == true, "tox_friend_send_lossy_packet fail %i", ret); |
48 | 48 | ||
49 | while (!state[1].custom_packet_received) { | 49 | do { |
50 | tox_iterate(toxes[0], nullptr); | 50 | tox_iterate(toxes[0], nullptr); |
51 | tox_iterate(toxes[1], &state[1]); | 51 | tox_iterate(toxes[1], &state[1]); |
52 | c_sleep(ITERATION_INTERVAL); | 52 | c_sleep(ITERATION_INTERVAL); |
53 | } | 53 | } while (!state[1].custom_packet_received); |
54 | } | 54 | } |
55 | 55 | ||
56 | int main(void) | 56 | int main(void) |