mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
94b06818fb
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).
37 lines
962 B
C
37 lines
962 B
C
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "../testing/misc_tools.h"
|
|
#include "../toxcore/ccompat.h"
|
|
|
|
int main(void)
|
|
{
|
|
setvbuf(stdout, nullptr, _IONBF, 0);
|
|
Tox *tox1 = tox_new_log_lan(nullptr, nullptr, nullptr, /* lan_discovery */true);
|
|
Tox *tox2 = tox_new_log_lan(nullptr, nullptr, nullptr, /* lan_discovery */true);
|
|
|
|
printf("Waiting for LAN discovery. This loop will attempt to run until successful.");
|
|
|
|
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),
|
|
tox_self_get_connection_status(tox2));
|
|
|
|
tox_kill(tox2);
|
|
tox_kill(tox1);
|
|
return 0;
|
|
}
|