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/conference_simple_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/conference_simple_test.c')
-rw-r--r-- | auto_tests/conference_simple_test.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/auto_tests/conference_simple_test.c b/auto_tests/conference_simple_test.c index 20e4ec8b..c9d24dad 100644 --- a/auto_tests/conference_simple_test.c +++ b/auto_tests/conference_simple_test.c | |||
@@ -165,26 +165,26 @@ int main(void) | |||
165 | // Wait for self connection. | 165 | // Wait for self connection. |
166 | fprintf(stderr, "Waiting for toxes to come online\n"); | 166 | fprintf(stderr, "Waiting for toxes to come online\n"); |
167 | 167 | ||
168 | while (!state1.self_online || !state2.self_online || !state3.self_online) { | 168 | do { |
169 | tox_iterate(tox1, &state1); | 169 | tox_iterate(tox1, &state1); |
170 | tox_iterate(tox2, &state2); | 170 | tox_iterate(tox2, &state2); |
171 | tox_iterate(tox3, &state3); | 171 | tox_iterate(tox3, &state3); |
172 | 172 | ||
173 | c_sleep(100); | 173 | c_sleep(100); |
174 | } | 174 | } while (!state1.self_online || !state2.self_online || !state3.self_online); |
175 | 175 | ||
176 | fprintf(stderr, "Toxes are online\n"); | 176 | fprintf(stderr, "Toxes are online\n"); |
177 | 177 | ||
178 | // Wait for friend connection. | 178 | // Wait for friend connection. |
179 | fprintf(stderr, "Waiting for friends to connect\n"); | 179 | fprintf(stderr, "Waiting for friends to connect\n"); |
180 | 180 | ||
181 | while (!state1.friend_online || !state2.friend_online || !state3.friend_online) { | 181 | do { |
182 | tox_iterate(tox1, &state1); | 182 | tox_iterate(tox1, &state1); |
183 | tox_iterate(tox2, &state2); | 183 | tox_iterate(tox2, &state2); |
184 | tox_iterate(tox3, &state3); | 184 | tox_iterate(tox3, &state3); |
185 | 185 | ||
186 | c_sleep(100); | 186 | c_sleep(100); |
187 | } | 187 | } while (!state1.friend_online || !state2.friend_online || !state3.friend_online); |
188 | 188 | ||
189 | fprintf(stderr, "Friends are connected\n"); | 189 | fprintf(stderr, "Friends are connected\n"); |
190 | 190 | ||
@@ -208,25 +208,25 @@ int main(void) | |||
208 | 208 | ||
209 | fprintf(stderr, "Waiting for invitation to arrive\n"); | 209 | fprintf(stderr, "Waiting for invitation to arrive\n"); |
210 | 210 | ||
211 | while (!state1.joined || !state2.joined || !state3.joined) { | 211 | do { |
212 | tox_iterate(tox1, &state1); | 212 | tox_iterate(tox1, &state1); |
213 | tox_iterate(tox2, &state2); | 213 | tox_iterate(tox2, &state2); |
214 | tox_iterate(tox3, &state3); | 214 | tox_iterate(tox3, &state3); |
215 | 215 | ||
216 | c_sleep(100); | 216 | c_sleep(100); |
217 | } | 217 | } while (!state1.joined || !state2.joined || !state3.joined); |
218 | 218 | ||
219 | fprintf(stderr, "Invitations accepted\n"); | 219 | fprintf(stderr, "Invitations accepted\n"); |
220 | 220 | ||
221 | fprintf(stderr, "Waiting for peers to come online\n"); | 221 | fprintf(stderr, "Waiting for peers to come online\n"); |
222 | 222 | ||
223 | while (state1.peers == 0 || state2.peers == 0 || state3.peers == 0) { | 223 | do { |
224 | tox_iterate(tox1, &state1); | 224 | tox_iterate(tox1, &state1); |
225 | tox_iterate(tox2, &state2); | 225 | tox_iterate(tox2, &state2); |
226 | tox_iterate(tox3, &state3); | 226 | tox_iterate(tox3, &state3); |
227 | 227 | ||
228 | c_sleep(100); | 228 | c_sleep(100); |
229 | } | 229 | } while (state1.peers == 0 || state2.peers == 0 || state3.peers == 0); |
230 | 230 | ||
231 | fprintf(stderr, "All peers are online\n"); | 231 | fprintf(stderr, "All peers are online\n"); |
232 | 232 | ||
@@ -244,13 +244,13 @@ int main(void) | |||
244 | 244 | ||
245 | fprintf(stderr, "Waiting for messages to arrive\n"); | 245 | fprintf(stderr, "Waiting for messages to arrive\n"); |
246 | 246 | ||
247 | while (!state2.received || !state3.received) { | 247 | do { |
248 | tox_iterate(tox1, &state1); | 248 | tox_iterate(tox1, &state1); |
249 | tox_iterate(tox2, &state2); | 249 | tox_iterate(tox2, &state2); |
250 | tox_iterate(tox3, &state3); | 250 | tox_iterate(tox3, &state3); |
251 | 251 | ||
252 | c_sleep(100); | 252 | c_sleep(100); |
253 | } | 253 | } while (!state2.received || !state3.received); |
254 | 254 | ||
255 | fprintf(stderr, "Messages received. Test complete.\n"); | 255 | fprintf(stderr, "Messages received. Test complete.\n"); |
256 | 256 | ||