summaryrefslogtreecommitdiff
path: root/testing/timer_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/timer_test.c')
-rw-r--r--testing/timer_test.c68
1 files changed, 0 insertions, 68 deletions
diff --git a/testing/timer_test.c b/testing/timer_test.c
deleted file mode 100644
index f47d4878..00000000
--- a/testing/timer_test.c
+++ /dev/null
@@ -1,68 +0,0 @@
1#include "../core/timer.h"
2#include <stdio.h>
3
4#ifdef WINDOWS
5#include <windows.h>
6#else
7#include <unistd.h>
8#endif
9
10void mssleep(int ms)
11{
12#ifdef WINDOWS
13 Sleep(ms);
14#else
15 usleep(ms * 1000);
16#endif
17}
18
19int callback(timer *t, void *arg)
20{
21 printf("%s\n", (char *)arg);
22 return 1;
23}
24
25int repeating(timer *t, void *arg)
26{
27 printf("%s\n", (char *)arg);
28 timer_start(t, 3);
29 return 0;
30}
31
32extern void timer_debug_print();
33
34int main(int argc, char **argv)
35{
36 timer_init();
37 timer_debug_print();
38
39 timer *t = new_timer();
40 timer_setup(t, &callback, "Long setup method, 4 seconds");
41 timer_start(t, 4);
42 timer_debug_print();
43
44 timer_single(&repeating, (void *)"This repeats every 3 seconds", 3);
45 timer_debug_print();
46
47 timer_single(&callback, "Short method, 4 seconds", 4);
48 timer_debug_print();
49
50 timer_single(&callback, "1 second", 1);
51 timer_debug_print();
52
53 timer_single(&callback, "15 seconds", 15);
54 timer_debug_print();
55
56 timer_single(&callback, "10 seconds", 10);
57 timer_debug_print();
58
59 timer_us(&callback, "100000us", 100000);
60 timer_us(&callback, "13s", 13 * US_PER_SECOND);
61
62 while (true) {
63 timer_poll();
64 mssleep(10);
65 }
66
67 return 0;
68}