X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Ftimer_test.c;h=22b18761d2e9e84b3d15c55e750ff5e994a745a2;hb=42e61240ce8a55e92fe0942fecbee3abe371c507;hp=5fc4257041924542cada51f8a521a3b07933f264;hpb=60d54449c12ed139911df35a9983c14019262d37;p=bertos.git diff --git a/bertos/drv/timer_test.c b/bertos/drv/timer_test.c index 5fc42570..22b18761 100644 --- a/bertos/drv/timer_test.c +++ b/bertos/drv/timer_test.c @@ -33,7 +33,7 @@ * \brief Hardware independent timer driver (implementation) * * \version $Id$ - * \author Bernardo Innocenti + * \author Bernie Innocenti */ #include @@ -43,6 +43,7 @@ #include +#include static void timer_test_constants(void) { @@ -65,7 +66,7 @@ static void timer_test_constants(void) kprintf("ticks_to_us(100)=%lu\n", ticks_to_us(100)); kprintf("ticks_to_us(10000)=%lu\n", ticks_to_us(10000)); kprintf("\n"); - kprintf("hptime_to_us(100)=%lu\n", hptime_to_us(100)); + kprintf("hptime_to_us(100)=%ld\n", hptime_to_us(100)); kprintf("hptime_to_us(10000)=%lu\n", hptime_to_us(10000)); kprintf("us_to_hptime(100)=%lu\n", us_to_hptime(100)); kprintf("us_to_hptime(10000)=%lu\n", us_to_hptime(10000)); @@ -92,10 +93,11 @@ static void timer_test_hook(iptr_t _timer) timer_add(timer); } +static Timer test_timers[5]; +static const mtime_t test_delays[5] = { 170, 50, 310, 1500, 310 }; + static void timer_test_async(void) { - static Timer test_timers[5]; - static const mtime_t test_delays[5] = { 170, 50, 310, 1500, 310 }; size_t i; for (i = 0; i < countof(test_timers); ++i) @@ -126,21 +128,38 @@ static void timer_test_poll(void) } } -#ifdef _TEST - -#include "timer.c" -#include "mware/event.c" -#include "os/hptime.c" - -int main(void) +int timer_testSetup(void) { + IRQ_ENABLE; wdt_init(7); timer_init(); + kdbg_init(); + return 0; +} + +int timer_testRun(void) +{ timer_test_constants(); timer_test_delay(); timer_test_async(); timer_test_poll(); return 0; } -#endif + +int timer_testTearDown(void) +{ + unsigned i; + for (i = 0; i < countof(test_timers); ++i) + timer_abort(&test_timers[i]); + return 0; +} + +#include TEST_ONLY(drv/timer.c) +#include TEST_ONLY(drv/kdebug.c) +#include TEST_ONLY(mware/event.c) +#include TEST_ONLY(mware/formatwr.c) +#include TEST_ONLY(mware/hex.c) +#include TEST_ONLY(os/hptime.c) + +TEST_MAIN(timer);