diff options
| author | hathach <[email protected]> | 2013-02-01 12:00:34 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-02-01 12:25:02 +0700 |
| commit | aab92b40d2e904e8ad85386e4a4f3b59e84eb844 (patch) | |
| tree | f8099f4075a1e7612b6522d1c8902d56aa13b3f7 /tests/test | |
| parent | 9e3785e7e1bd5bac3c8e24477edbde12cc09dd4b (diff) | |
change osal_timeout_t to uint32_t
implement osal_tick_get & osal_tick_tock for osal_none
implement timeout for osal_semaphore_wait
Diffstat (limited to 'tests/test')
| -rw-r--r-- | tests/test/host/test_usbd_host.c | 2 | ||||
| -rw-r--r-- | tests/test/support/tusb_config.h | 2 | ||||
| -rw-r--r-- | tests/test/test_osal_none.c | 14 |
3 files changed, 13 insertions, 5 deletions
diff --git a/tests/test/host/test_usbd_host.c b/tests/test/host/test_usbd_host.c index 7dceff7db..654178dc5 100644 --- a/tests/test/host/test_usbd_host.c +++ b/tests/test/host/test_usbd_host.c @@ -126,7 +126,7 @@ usbh_enumerate_t enum_connect = .connect_status = 1 }; -void queue_recv_stub (osal_queue_handle_t const queue_hdl, uint32_t *p_data, osal_timeout_t msec, tusb_error_t *p_error, int num_call) +void queue_recv_stub (osal_queue_handle_t const queue_hdl, uint32_t *p_data, uint32_t msec, tusb_error_t *p_error, int num_call) { TEST_ASSERT_EQUAL_PTR(enumeration_queue_hdl, queue_hdl); memcpy(p_data, &enum_connect, 4); diff --git a/tests/test/support/tusb_config.h b/tests/test/support/tusb_config.h index 87b09a9dd..aee1e3996 100644 --- a/tests/test/support/tusb_config.h +++ b/tests/test/support/tusb_config.h @@ -88,7 +88,7 @@ #define TUSB_CFG_DEBUG 3 #define TUSB_CFG_OS TUSB_OS_NONE -#define TUSB_CFG_OS_TICK_PER_SECOND 1000 // 1 ms tick +#define TUSB_CFG_OS_TICKS_PER_SECOND 1000 // 1 ms tick #ifdef __CODE_RED // make use of code red's support for ram region macros #if (MCU == MCU_LPC11UXX) || (MCU == MCU_LPC13UXX) diff --git a/tests/test/test_osal_none.c b/tests/test/test_osal_none.c index 122dc48e2..231edbef1 100644 --- a/tests/test/test_osal_none.c +++ b/tests/test/test_osal_none.c @@ -123,15 +123,18 @@ void sample_task_semaphore(void) osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_WAIT_FOREVER, &error); statements[3]++; + osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_NORMAL, &error); + statements[4]++; + TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_TIMEOUT, error); + OSAL_TASK_LOOP_END } } void test_task_with_semaphore(void) { - uint32_t i; // several invoke before sempahore is available - for(i=0; i<10; i++) + for(uint32_t i=0; i<10; i++) sample_task_semaphore(); TEST_ASSERT_EQUAL(1, statements[0]); @@ -148,7 +151,12 @@ void test_task_with_semaphore(void) TEST_ASSERT_EQUAL(1, statements[3]); // timeout - + for(uint32_t i=0; i<(OSAL_TIMEOUT_NORMAL*TUSB_CFG_OS_TICKS_PER_SECOND)/1000 ; i++) // not enough time + osal_tick_tock(); + sample_task_semaphore(); + TEST_ASSERT_EQUAL(0, statements[4]); + osal_tick_tock(); + sample_task_semaphore(); // reach end of task loop, back to beginning sample_task_semaphore(); |
