summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-02-08 12:12:10 +0700
committerhathach <[email protected]>2013-02-08 12:12:10 +0700
commit489b98cb933e1f4b164bf1172a405d22528d2b8b (patch)
treec39a7143190459979f398b13bf1a7426accf0258 /tests
parentef0e105da669c7a3d8ae781dac11a37d52c63fa0 (diff)
add TUSB_CFG_HOST_CONTROLLER_START_INDEX
update usbh_init and test code for TUSB_CFG_HOST_CONTROLLER_START_INDEX clean up some
Diffstat (limited to 'tests')
-rw-r--r--tests/test/host/test_usbh.c65
-rw-r--r--tests/test/support/tusb_config.h2
2 files changed, 41 insertions, 26 deletions
diff --git a/tests/test/host/test_usbh.c b/tests/test/host/test_usbh.c
index da435426c..59edf42e5 100644
--- a/tests/test/host/test_usbh.c
+++ b/tests/test/host/test_usbh.c
@@ -55,33 +55,62 @@ void tearDown(void)
}
//--------------------------------------------------------------------+
-// init, get_status
+// get_status
//--------------------------------------------------------------------+
+void test_usbh_status_get_fail(void)
+{
+ usbh_device_info_pool[dev_hdl].status = 0;
+
+ TEST_ASSERT_EQUAL( 0, tusbh_device_status_get(TUSB_CFG_HOST_DEVICE_MAX+1) );
+ TEST_ASSERT_EQUAL( TUSB_DEVICE_STATUS_UNPLUG, tusbh_device_status_get(dev_hdl) );
+}
+
+void test_usbh_status_get_succeed(void)
+{
+ usbh_device_info_pool[dev_hdl].status = TUSB_DEVICE_STATUS_READY;
+ TEST_ASSERT_EQUAL( TUSB_DEVICE_STATUS_READY, tusbh_device_status_get(dev_hdl) );
+}
+
+//--------------------------------------------------------------------+
+// Init
+//--------------------------------------------------------------------+
+void hcd_init_expect(void)
+{
+ for(uint32_t i=0; i<TUSB_CFG_HOST_CONTROLLER_NUM; i++)
+ hcd_init_ExpectAndReturn(TUSB_CFG_HOST_CONTROLLER_START_INDEX+i, TUSB_ERROR_NONE);
+}
+
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)
+void test_usbh_init_enum_task_create_failed(void)
{
- for(uint32_t i=0; i<TUSB_CFG_HOST_CONTROLLER_NUM; i++)
- hcd_init_ExpectAndReturn(i, TUSB_ERROR_NONE);
-
+ hcd_init_expect();
osal_task_create_IgnoreAndReturn(TUSB_ERROR_OSAL_TASK_FAILED);
TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_TASK_FAILED, usbh_init());
}
-void test_usbh_init_queue_create_failed(void)
+void test_usbh_init_enum_queue_create_failed(void)
{
- for(uint32_t i=0; i<TUSB_CFG_HOST_CONTROLLER_NUM; i++)
- hcd_init_ExpectAndReturn(i, TUSB_ERROR_NONE);
-
+ hcd_init_expect();
osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE);
osal_queue_create_IgnoreAndReturn(NULL);
TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_QUEUE_FAILED, usbh_init());
}
+void test_usbh_init_reporter_taks_create_failed(void)
+{
+ TEST_IGNORE();
+}
+
+void test_usbh_init_reporter_queue_create_failed(void)
+{
+ TEST_IGNORE();
+}
+
void test_usbh_init_ok(void)
{
uint32_t dummy;
@@ -89,9 +118,7 @@ void test_usbh_init_ok(void)
usbh_device_info_t device_info_zero[TUSB_CFG_HOST_DEVICE_MAX+1];
memclr_(device_info_zero, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1));
- for(uint32_t i=0; i<TUSB_CFG_HOST_CONTROLLER_NUM; i++)
- hcd_init_ExpectAndReturn(i, TUSB_ERROR_NONE);
-
+ hcd_init_expect();
osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE);
osal_queue_create_IgnoreAndReturn((osal_queue_handle_t)(&dummy));
@@ -99,17 +126,3 @@ void test_usbh_init_ok(void)
TEST_ASSERT_EQUAL_MEMORY(device_info_zero, usbh_device_info_pool, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1));
}
-
-void test_usbh_status_get_fail(void)
-{
- usbh_device_info_pool[dev_hdl].status = 0;
-
- TEST_ASSERT_EQUAL( 0, tusbh_device_status_get(TUSB_CFG_HOST_DEVICE_MAX+1) );
- TEST_ASSERT_EQUAL( TUSB_DEVICE_STATUS_UNPLUG, tusbh_device_status_get(dev_hdl) );
-}
-
-void test_usbh_status_get_succeed(void)
-{
- usbh_device_info_pool[dev_hdl].status = TUSB_DEVICE_STATUS_READY;
- TEST_ASSERT_EQUAL( TUSB_DEVICE_STATUS_READY, tusbh_device_status_get(dev_hdl) );
-}
diff --git a/tests/test/support/tusb_config.h b/tests/test/support/tusb_config.h
index 8850cce45..c9012afd7 100644
--- a/tests/test/support/tusb_config.h
+++ b/tests/test/support/tusb_config.h
@@ -62,6 +62,8 @@
//------------- CORE/CONTROLLER -------------//
#define TUSB_CFG_HOST_CONTROLLER_NUM 2
+#define TUSB_CFG_HOST_CONTROLLER_START_INDEX 1
+
#define TUSB_CFG_HOST_DEVICE_MAX 2
#define TUSB_CFG_CONFIGURATION_MAX 2