| 30 | } |
| 31 | |
| 32 | int main(void) |
| 33 | { |
| 34 | struct timers_with_counters tc; |
| 35 | struct timer t[64]; |
| 36 | const struct timemono epoch = { { 0, 0 } }; |
| 37 | |
| 38 | tc.num_alloc = tc.num_free = 0; |
| 39 | plan_tests(12); |
| 40 | |
| 41 | timers_set_allocator(test_alloc, test_free); |
| 42 | timers_init(&tc.timers, epoch); |
| 43 | timer_init(&t[0]); |
| 44 | |
| 45 | timer_addmono(&tc.timers, &t[0], |
| 46 | timemono_from_nsec(TIMER_GRANULARITY << TIMER_LEVEL_BITS)); |
| 47 | timers_expire(&tc.timers, timemono_from_nsec(1)); |
| 48 | ok1(tc.num_alloc == 1); |
| 49 | ok1(tc.num_free == 0); |
| 50 | timer_del(&tc.timers, &t[0]); |
| 51 | ok1(tc.num_alloc == 1); |
| 52 | ok1(tc.num_free == 0); |
| 53 | timers_cleanup(&tc.timers); |
| 54 | ok1(tc.num_alloc == 1); |
| 55 | ok1(tc.num_free == 1); |
| 56 | |
| 57 | /* Should restore defaults */ |
| 58 | timers_set_allocator(NULL, NULL); |
| 59 | ok1(timer_alloc == timer_default_alloc); |
| 60 | ok1(timer_free == timer_default_free); |
| 61 | |
| 62 | timers_init(&tc.timers, epoch); |
| 63 | timer_addmono(&tc.timers, &t[0], |
| 64 | timemono_from_nsec(TIMER_GRANULARITY << TIMER_LEVEL_BITS)); |
| 65 | ok1(tc.num_alloc == 1); |
| 66 | ok1(tc.num_free == 1); |
| 67 | timers_cleanup(&tc.timers); |
| 68 | ok1(tc.num_alloc == 1); |
| 69 | ok1(tc.num_free == 1); |
| 70 | |
| 71 | /* This exits depending on whether all tests passed */ |
| 72 | return exit_status(); |
| 73 | } |
nothing calls this directly
no test coverage detected