summaryrefslogtreecommitdiff
path: root/tests/test
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-03-22 17:08:51 +0700
committerhathach <[email protected]>2013-03-22 17:08:51 +0700
commitdbaf6c0d30657ec1659ddb13269edc4ae28b7bc2 (patch)
tree59685ec0d0e0eea4b29cbff5d308e1befe4a8dd6 /tests/test
parentcd2915e78cdd261713f1b0aa4ebe0441f99f9456 (diff)
- fix bug when unplugged unmounted-already device (mostly plugged when power on)
- add hal_debugger_is_attached & hal_debugger_breakpoint - assert will suspend (place breakpoint) if the condition is failed and debugger is attached. Otherwise, a message to uart is printed - fix get control qhd function when dev_addr is not zero (shifted 1) - fix wrong logic for unsupported class
Diffstat (limited to 'tests/test')
-rw-r--r--tests/test/host/ehci/test_ehci_pipe_open.c6
-rw-r--r--tests/test/host/ehci/test_ehci_pipe_xfer_control.c6
-rw-r--r--tests/test/host/ehci/test_ehci_usbh_hcd_integration.c15
-rw-r--r--tests/test/host/test_usbh.c13
4 files changed, 34 insertions, 6 deletions
diff --git a/tests/test/host/ehci/test_ehci_pipe_open.c b/tests/test/host/ehci/test_ehci_pipe_open.c
index a097da367..918595d34 100644
--- a/tests/test/host/ehci/test_ehci_pipe_open.c
+++ b/tests/test/host/ehci/test_ehci_pipe_open.c
@@ -142,7 +142,7 @@ void test_control_open_addr0_qhd_data(void)
void test_control_open_qhd_data(void)
{
- ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].control.qhd;
+ ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr-1].control.qhd;
//------------- Code Under TEST -------------//
hcd_pipe_control_open(dev_addr, control_max_packet_size);
@@ -170,7 +170,7 @@ void test_control_open_highspeed(void)
void test_control_open_non_highspeed(void)
{
- ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].control.qhd;
+ ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr-1].control.qhd;
usbh_device_info_pool[dev_addr].speed = TUSB_SPEED_FULL;
@@ -195,7 +195,7 @@ void test_control_addr0_close(void)
void test_control_close(void)
{
- ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].control.qhd;
+ ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr-1].control.qhd;
hcd_pipe_control_open(dev_addr, control_max_packet_size);
diff --git a/tests/test/host/ehci/test_ehci_pipe_xfer_control.c b/tests/test/host/ehci/test_ehci_pipe_xfer_control.c
index 4a3649a8a..666637f84 100644
--- a/tests/test/host/ehci/test_ehci_pipe_xfer_control.c
+++ b/tests/test/host/ehci/test_ehci_pipe_xfer_control.c
@@ -164,7 +164,7 @@ void test_control_addr0_xfer_get_check_qhd_qtd_mapping(void)
void test_control_xfer_get(void)
{
- ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].control.qhd;
+ ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr-1].control.qhd;
hcd_pipe_control_open(dev_addr, control_max_packet_size);
//------------- Code Under TEST -------------//
@@ -209,7 +209,7 @@ void test_control_xfer_set(void)
.wValue = 3
};
- ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].control.qhd;
+ ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr-1].control.qhd;
hcd_pipe_control_open(dev_addr, control_max_packet_size);
//------------- Code Under TEST -------------//
@@ -233,7 +233,7 @@ void test_control_xfer_set(void)
void test_control_xfer_isr(void)
{
- ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].control.qhd;
+ ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr-1].control.qhd;
hcd_pipe_control_open(dev_addr, control_max_packet_size);
hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data);
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 edde08cbf..a830f9509 100644
--- a/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c
+++ b/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c
@@ -78,6 +78,7 @@ void setUp(void)
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].status = TUSB_DEVICE_STATUS_READY;
}
regs = get_operational_register(hostid);
@@ -178,3 +179,17 @@ void test_bulk_pipe_close(void)
TEST_ASSERT_FALSE(p_qtd_head->used);
TEST_ASSERT_FALSE(p_qtd_tail->used);
}
+
+void test_device_unplugged_status(void)
+{
+ ehci_controller_device_unplug(hostid);
+ hcd_isr(hostid);
+
+ regs->usb_sts_bit.async_advance = 1;
+ hcd_isr(hostid); // async advance
+
+ //------------- Code Under Test -------------//
+
+ TEST_ASSERT_EQUAL(TUSB_DEVICE_STATUS_REMOVING, usbh_device_info_pool[dev_addr].status);
+
+}
diff --git a/tests/test/host/test_usbh.c b/tests/test/host/test_usbh.c
index fa35a22e7..f9f1c5ac8 100644
--- a/tests/test/host/test_usbh.c
+++ b/tests/test/host/test_usbh.c
@@ -162,6 +162,19 @@ void class_close_expect(void)
hidh_close_Expect(1);
}
+// device is not mounted before, even the control pipe is not open, do nothing
+void test_usbh_device_unplugged_isr_device_not_previously_mounted(void)
+{
+ uint8_t dev_addr = 1;
+
+ usbh_device_info_pool[dev_addr].status = TUSB_DEVICE_STATUS_UNPLUG;
+ usbh_device_info_pool[dev_addr].core_id = 0;
+ usbh_device_info_pool[dev_addr].hub_addr = 0;
+ usbh_device_info_pool[dev_addr].hub_port = 0;
+
+ usbh_device_unplugged_isr(0);
+}
+
void test_usbh_device_unplugged_isr(void)
{
uint8_t dev_addr = 1;