blob: 862318047918239cae9a1a52d8b07cb80fbb7ccb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#include <math.h>
#include <re.h>
#include <baresip.h>
#include "test.h"
static void timeout_handler(void *arg)
{
int *err = arg;
warning("selftest: re_main() loop timed out -- test hung..\n");
*err = ETIMEDOUT;
re_cancel();
}
static void signal_handler(int sig)
{
re_fprintf(stderr, "test interrupted by signal %d\n", sig);
re_cancel();
}
int re_main_timeout(uint32_t timeout_ms)
{
struct tmr tmr;
int err = 0;
tmr_init(&tmr);
tmr_start(&tmr, timeout_ms, timeout_handler, &err);
re_main(signal_handler);
tmr_cancel(&tmr);
return err;
}
bool test_cmp_double(double a, double b, double precision)
{
return fabs(a - b) < precision;
}
|