diff options
| author | hathach <[email protected]> | 2013-03-23 17:31:51 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-03-23 17:31:51 +0700 |
| commit | 44e09cc397df4e7fc47c37a4d967fe17a3d82e16 (patch) | |
| tree | f8f1459fc355d174df4f1724d9dbb7f08bb137d7 /tests | |
| parent | 4adfc6a6d8a77ca9526ec04e62c83ea88ffdddd7 (diff) | |
enhance some tests
add test for usbh_isr error invoke
fix bug if device unplugged before is set to new address
- clean up & close control addr0 in usbh_device_unplugged_isr
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test/host/ehci/test_ehci_usbh_hcd_integration.c | 4 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_pipe_bulk_open.c | 2 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_pipe_bulk_xfer.c | 6 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_pipe_control_open.c | 2 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_pipe_control_xfer.c | 25 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_pipe_interrupt_open.c | 2 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_pipe_isochronous_open.c | 2 | ||||
| -rw-r--r-- | tests/test/host/test_enum_task.c | 7 | ||||
| -rw-r--r-- | tests/test/support/ehci_controller.c | 28 |
9 files changed, 56 insertions, 22 deletions
diff --git a/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c b/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c index 9ba36e4e6..3769844b6 100644 --- a/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c +++ b/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c @@ -72,13 +72,13 @@ void setUp(void) hcd_init(); - for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX; i++) + for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) { usbh_device_info_pool[i].core_id = hostid; usbh_device_info_pool[i].hub_addr = hub_addr; usbh_device_info_pool[i].hub_port = hub_port; usbh_device_info_pool[i].speed = TUSB_SPEED_HIGH; - usbh_device_info_pool[i].state = TUSB_DEVICE_STATE_CONFIGURED; + usbh_device_info_pool[i].state = i ? TUSB_DEVICE_STATE_CONFIGURED : TUSB_DEVICE_STATE_UNPLUG; } regs = get_operational_register(hostid); diff --git a/tests/test/host/ehci/test_pipe_bulk_open.c b/tests/test/host/ehci/test_pipe_bulk_open.c index 03c7d0b85..fe2ba3bef 100644 --- a/tests/test/host/ehci/test_pipe_bulk_open.c +++ b/tests/test/host/ehci/test_pipe_bulk_open.c @@ -68,7 +68,7 @@ void setUp(void) dev_addr = 1; hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX; i++) + for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) { usbh_device_info_pool[i].core_id = hostid; usbh_device_info_pool[i].hub_addr = hub_addr; diff --git a/tests/test/host/ehci/test_pipe_bulk_xfer.c b/tests/test/host/ehci/test_pipe_bulk_xfer.c index 6d3d0c4a7..98539c4a7 100644 --- a/tests/test/host/ehci/test_pipe_bulk_xfer.c +++ b/tests/test/host/ehci/test_pipe_bulk_xfer.c @@ -97,7 +97,7 @@ void setUp(void) dev_addr = 1; hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX; i++) + for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) { usbh_device_info_pool[i].core_id = hostid; usbh_device_info_pool[i].hub_addr = hub_addr; @@ -210,12 +210,10 @@ void test_bulk_xfer_complete_isr(void) ehci_qtd_t* p_head = p_qhd_bulk->p_qtd_list_head; ehci_qtd_t* p_tail = p_qhd_bulk->p_qtd_list_tail; - ehci_controller_run(hostid); - usbh_isr_Expect(pipe_hdl_bulk, TUSB_CLASS_MSC, BUS_EVENT_XFER_COMPLETE); //------------- Code Under Test -------------// - hcd_isr(hostid); + ehci_controller_run(hostid); TEST_ASSERT_TRUE(p_qhd_bulk->qtd_overlay.next.terminate); TEST_ASSERT_FALSE(p_head->used); diff --git a/tests/test/host/ehci/test_pipe_control_open.c b/tests/test/host/ehci/test_pipe_control_open.c index 7064131df..76575915f 100644 --- a/tests/test/host/ehci/test_pipe_control_open.c +++ b/tests/test/host/ehci/test_pipe_control_open.c @@ -70,7 +70,7 @@ void setUp(void) dev_addr = 1; hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX; i++) + for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) { usbh_device_info_pool[i].core_id = hostid; usbh_device_info_pool[i].hub_addr = hub_addr; diff --git a/tests/test/host/ehci/test_pipe_control_xfer.c b/tests/test/host/ehci/test_pipe_control_xfer.c index 432f5956e..fd6f79ecc 100644 --- a/tests/test/host/ehci/test_pipe_control_xfer.c +++ b/tests/test/host/ehci/test_pipe_control_xfer.c @@ -79,7 +79,7 @@ void setUp(void) dev_addr = 1; hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX; i++) + for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) { usbh_device_info_pool[i].core_id = hostid; usbh_device_info_pool[i].hub_addr = hub_addr; @@ -89,6 +89,8 @@ void setUp(void) async_head = get_async_head( hostid ); + hcd_pipe_control_open(dev_addr, control_max_packet_size); + p_control_qhd = &ehci_data.device[dev_addr-1].control.qhd; p_setup = &ehci_data.device[dev_addr-1].control.qtd[0]; @@ -168,8 +170,6 @@ void test_control_addr0_xfer_get_check_qhd_qtd_mapping(void) //--------------------------------------------------------------------+ void test_control_xfer_get(void) { - hcd_pipe_control_open(dev_addr, control_max_packet_size); - //------------- Code Under TEST -------------// hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data); @@ -205,8 +205,6 @@ void test_control_xfer_get(void) void test_control_xfer_set(void) { - hcd_pipe_control_open(dev_addr, control_max_packet_size); - //------------- Code Under TEST -------------// hcd_pipe_control_xfer(dev_addr, &request_set_dev_addr, xfer_data); @@ -228,17 +226,11 @@ void test_control_xfer_set(void) void test_control_xfer_complete_isr(void) { - hcd_pipe_control_open(dev_addr, control_max_packet_size); - hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data); - ehci_controller_run(hostid); - - TEST_ASSERT_EQUAL_HEX(async_head, get_operational_register(hostid)->async_list_base); - TEST_ASSERT_EQUAL_HEX((uint32_t) p_control_qhd, align32(async_head->next.address)); usbh_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, BUS_EVENT_XFER_COMPLETE); //------------- Code Under TEST -------------// - hcd_isr(hostid); + ehci_controller_run(hostid); TEST_ASSERT_NULL(p_control_qhd->p_qtd_list_head); TEST_ASSERT_NULL(p_control_qhd->p_qtd_list_tail); @@ -248,3 +240,12 @@ void test_control_xfer_complete_isr(void) TEST_ASSERT_FALSE(p_status->used); } + +void test_control_xfer_error_isr(void) +{ + hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data); + usbh_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, BUS_EVENT_XFER_ERROR); + + //------------- Code Under TEST -------------// + ehci_controller_run_error(hostid); +} diff --git a/tests/test/host/ehci/test_pipe_interrupt_open.c b/tests/test/host/ehci/test_pipe_interrupt_open.c index b04e68192..ecd63d20d 100644 --- a/tests/test/host/ehci/test_pipe_interrupt_open.c +++ b/tests/test/host/ehci/test_pipe_interrupt_open.c @@ -68,7 +68,7 @@ void setUp(void) dev_addr = 1; hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX; i++) + for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) { usbh_device_info_pool[i].core_id = hostid; usbh_device_info_pool[i].hub_addr = hub_addr; diff --git a/tests/test/host/ehci/test_pipe_isochronous_open.c b/tests/test/host/ehci/test_pipe_isochronous_open.c index 1b075224d..60403750d 100644 --- a/tests/test/host/ehci/test_pipe_isochronous_open.c +++ b/tests/test/host/ehci/test_pipe_isochronous_open.c @@ -67,7 +67,7 @@ void setUp(void) dev_addr = 1; hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX; i++) + for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) { usbh_device_info_pool[i].core_id = hostid; usbh_device_info_pool[i].hub_addr = hub_addr; diff --git a/tests/test/host/test_enum_task.c b/tests/test/host/test_enum_task.c index 9800e6f8e..90cc7a022 100644 --- a/tests/test/host/test_enum_task.c +++ b/tests/test/host/test_enum_task.c @@ -171,6 +171,9 @@ void test_addr0_failed_dev_desc(void) tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL); usbh_enumeration_task(); + + TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_ADDRESSED, usbh_device_info_pool[0].state); + } void test_addr0_failed_set_address(void) @@ -180,6 +183,7 @@ void test_addr0_failed_set_address(void) usbh_enumeration_task(); + TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_ADDRESSED, usbh_device_info_pool[0].state); TEST_ASSERT_EQUAL_MEMORY(&desc_device, enum_data_buffer, 8); } @@ -188,12 +192,15 @@ void test_enum_failed_get_full_dev_desc(void) osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(2)); hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE); + osal_semaphore_reset_Expect( usbh_device_info_pool[0].sem_hdl ); hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE); tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL); usbh_enumeration_task(); + TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_UNPLUG, usbh_device_info_pool[0].state); + TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_ADDRESSED, usbh_device_info_pool[1].state); TEST_ASSERT_EQUAL(TUSB_SPEED_FULL, usbh_device_info_pool[1].speed); TEST_ASSERT_EQUAL(enum_connect.core_id, usbh_device_info_pool[1].core_id); diff --git a/tests/test/support/ehci_controller.c b/tests/test/support/ehci_controller.c index 4c3ab33ff..911a075d2 100644 --- a/tests/test/support/ehci_controller.c +++ b/tests/test/support/ehci_controller.c @@ -77,6 +77,34 @@ void ehci_controller_run(uint8_t hostid) //------------- Period List -------------// regs->usb_sts = EHCI_INT_MASK_NXP_ASYNC; + hcd_isr(hostid); +} + +void ehci_controller_run_error(uint8_t hostid) +{ + //------------- Async List -------------// + ehci_registers_t* const regs = get_operational_register(hostid); + + ehci_qhd_t *p_qhd = (ehci_qhd_t*) regs->async_list_base; + do + { + if ( !p_qhd->qtd_overlay.halted ) + { + if(!p_qhd->qtd_overlay.next.terminate) + { + ehci_qtd_t* p_qtd = (ehci_qtd_t*) align32(p_qhd->qtd_overlay.next.address); + p_qtd->active = 0; + p_qtd->babble_err = p_qtd->buffer_err = p_qtd->xact_err = 1; + p_qhd->qtd_overlay = *p_qtd; + } + } + p_qhd = (ehci_qhd_t*) align32(p_qhd->next.address); + }while(p_qhd != get_async_head(hostid)); // stop if loop around + //------------- Period List -------------// + + regs->usb_sts = EHCI_INT_MASK_ERROR; + + hcd_isr(hostid); } void ehci_controller_device_plug(uint8_t hostid, tusb_speed_t speed) |
