summaryrefslogtreecommitdiff
path: root/auto_tests/conference_peer_nick_test.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-08-25 12:16:54 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-08-25 15:25:33 +0000
commit94b06818fbd7a93387ff4c155b6eff711651aea9 (patch)
tree63365adeb88705c5c2f0cdb4d2afd00a4bd8b43c /auto_tests/conference_peer_nick_test.c
parent0935aab92760a7c9c547faa86c29dcd0d1e03f24 (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/conference_peer_nick_test.c')
-rw-r--r--auto_tests/conference_peer_nick_test.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/auto_tests/conference_peer_nick_test.c b/auto_tests/conference_peer_nick_test.c
index e99d3b79..14676b76 100644
--- a/auto_tests/conference_peer_nick_test.c
+++ b/auto_tests/conference_peer_nick_test.c
@@ -107,26 +107,25 @@ static void conference_peer_nick_test(Tox **toxes, State *state)
107 107
108 fprintf(stderr, "Waiting for invitation to arrive and peers to be in the group\n"); 108 fprintf(stderr, "Waiting for invitation to arrive and peers to be in the group\n");
109 109
110 while (!state[0].joined || !state[1].joined || !state[0].friend_in_group || !state[1].friend_in_group) { 110 do {
111 tox_iterate(toxes[0], &state[0]); 111 tox_iterate(toxes[0], &state[0]);
112 tox_iterate(toxes[1], &state[1]); 112 tox_iterate(toxes[1], &state[1]);
113 113
114 c_sleep(ITERATION_INTERVAL); 114 c_sleep(ITERATION_INTERVAL);
115 } 115 } while (!state[0].joined || !state[1].joined || !state[0].friend_in_group || !state[1].friend_in_group);
116 116
117 fprintf(stderr, "Running tox0, but not tox1, waiting for tox1 to drop out\n"); 117 fprintf(stderr, "Running tox0, but not tox1, waiting for tox1 to drop out\n");
118 118
119 while (state[0].friend_in_group) { 119 do {
120 tox_iterate(toxes[0], &state[0]); 120 tox_iterate(toxes[0], &state[0]);
121 121
122 // Rebuild peer list after every iteration. 122 // Rebuild peer list after every iteration.
123 rebuild_peer_list(toxes[0]); 123 rebuild_peer_list(toxes[0]);
124 124
125 c_sleep(ITERATION_INTERVAL); 125 c_sleep(ITERATION_INTERVAL);
126 } 126 } while (state[0].friend_in_group);
127 127
128 fprintf(stderr, "Invitations accepted\n"); 128 fprintf(stderr, "Invitations accepted\n");
129
130} 129}
131 130
132int main(void) 131int main(void)