From 9e3785e7e1bd5bac3c8e24477edbde12cc09dd4b Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 1 Feb 2013 10:33:43 +0700 Subject: [PATCH] add std=gnu99 for test build add hcd_init to usbh_init and update test code add TUSB_CFG_OS_TICK_PER_SECOND define for TUSB_OS_NONE change osal_semaphore_wait and osal_queue_receive API to have timeout effectively --- tests/project.yml | 4 +- tests/test/host/test_usbd_host.c | 80 +++++++++++++++++----------- tests/test/support/tusb_config.h | 1 + tests/test/test_osal_none.c | 11 ++-- tinyusb/common/errors.h | 1 + tinyusb/host/hcd.c | 1 - tinyusb/host/hcd.h | 5 +- tinyusb/host/usbd_host.c | 40 +++++++++----- tinyusb/host/usbd_host.h | 1 + tinyusb/osal/osal.h | 9 +++- tinyusb/osal/osal_none.h | 2 +- tinyusb/tusb_option.h | 89 ++++++++++++++++++-------------- 12 files changed, 151 insertions(+), 93 deletions(-) diff --git a/tests/project.yml b/tests/project.yml index 039d0457..feedb7b6 100644 --- a/tests/project.yml +++ b/tests/project.yml @@ -44,14 +44,14 @@ :commmon: &common_defines [] :test: - *common_defines - - _TEST_ + - _TEST_ -std=gnu99 - MCU=MCU_LPC43XX - CORE_M4 - __CODE_RED - _TINY_USB_SOURCE_FILE_ :test_preprocess: - *common_defines - - _TEST_ + - _TEST_ -std=gnu99 - MCU=MCU_LPC43XX - CORE_M4 - __CODE_RED diff --git a/tests/test/host/test_usbd_host.c b/tests/test/host/test_usbd_host.c index 255ef3da..7dceff7d 100644 --- a/tests/test/host/test_usbd_host.c +++ b/tests/test/host/test_usbd_host.c @@ -39,6 +39,7 @@ #include "errors.h" #include "usbd_host.h" #include "mock_osal.h" +#include "mock_hcd.h" extern usbh_device_info_t device_info_pool[TUSB_CFG_HOST_DEVICE_MAX]; tusb_handle_device_t dev_hdl; @@ -55,26 +56,42 @@ void tearDown(void) //--------------------------------------------------------------------+ // init, get_status //--------------------------------------------------------------------+ +void test_usbh_init_hcd_failed(void) +{ + hcd_init_IgnoreAndReturn(TUSB_ERROR_HCD_FAILED); + TEST_ASSERT_EQUAL(TUSB_ERROR_HCD_FAILED, usbh_init()); +} + void test_usbh_init_task_create_failed(void) { + for(uint32_t i=0; i