X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftimer%2Ftest%2Frun-ff.c;h=148b7f7922e4ddd8d952c66b9d155833c96a601c;hp=c40e3b104d92744587af0ae74a6db9125933ab67;hb=fe6bc8c530795a6c718f7e8fd1a6643d9f3024a1;hpb=606cca7b0ed5236d1df1c4436ca79db6e3fd5321 diff --git a/ccan/timer/test/run-ff.c b/ccan/timer/test/run-ff.c index c40e3b10..148b7f79 100644 --- a/ccan/timer/test/run-ff.c +++ b/ccan/timer/test/run-ff.c @@ -3,23 +3,26 @@ #include #include +static struct timeabs timeabs_from_usec(unsigned long long usec) +{ + struct timeabs epoch = { { 0, 0 } }; + return timeabs_add(epoch, time_from_usec(usec)); +} + int main(void) { struct timers timers; - struct timer t; - struct list_head expired; + struct timer t, *expired; /* This is how many tests you plan to run */ plan_tests(3); - timers_init(&timers, time_from_usec(1364726722653919ULL)); - timer_add(&timers, &t, time_from_usec(1364726722703919ULL)); - timers_expire(&timers, time_from_usec(1364726722653920ULL), &expired); - ok1(list_empty(&expired)); - timers_expire(&timers, time_from_usec(1364726725454187ULL), &expired); - ok1(!list_empty(&expired)); - ok1(list_top(&expired, struct timer, list) == &t); - + timers_init(&timers, timeabs_from_usec(1364726722653919ULL)); + timer_add(&timers, &t, timeabs_from_usec(1364726722703919ULL)); + ok1(!timers_expire(&timers, timeabs_from_usec(1364726722653920ULL))); + expired = timers_expire(&timers, timeabs_from_usec(1364726725454187ULL)); + ok1(expired == &t); + ok1(!timers_expire(&timers, timeabs_from_usec(1364726725454187ULL))); timers_cleanup(&timers); /* This exits depending on whether all tests passed */