From 4dd38f0df6d03869caa4cf47d0e16f8e2a5b4db5 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 12 May 2013 22:29:02 +0700 Subject: [PATCH] test again --- tests/test/host/ehci/test_pipe_bulk_xfer.c | 6 ++- tests/test/host/ehci/test_pipe_control_xfer.c | 49 ++++++++++++------- .../test/host/ehci/test_pipe_interrupt_open.c | 12 ++--- .../test/host/ehci/test_pipe_interrupt_xfer.c | 40 +++++++++------ tests/test/support/ehci_controller_fake.h | 1 + 5 files changed, 68 insertions(+), 40 deletions(-) diff --git a/tests/test/host/ehci/test_pipe_bulk_xfer.c b/tests/test/host/ehci/test_pipe_bulk_xfer.c index aec2fcbb2..3ab12fb0e 100644 --- a/tests/test/host/ehci/test_pipe_bulk_xfer.c +++ b/tests/test/host/ehci/test_pipe_bulk_xfer.c @@ -36,6 +36,7 @@ */ /**************************************************************************/ +#include #include "unity.h" #include "tusb_option.h" #include "errors.h" @@ -91,7 +92,8 @@ void setUp(void) memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); memclr_(xfer_data, sizeof(xfer_data)); - hcd_init(); + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_init() ); dev_addr = 1; @@ -103,6 +105,8 @@ void setUp(void) usbh_devices[dev_addr].speed = TUSB_SPEED_HIGH; async_head = get_async_head( hostid ); + + //------------- pipe open -------------// pipe_hdl_bulk = hcd_pipe_open(dev_addr, &desc_ept_bulk_in, TUSB_CLASS_MSC); TEST_ASSERT_EQUAL(dev_addr, pipe_hdl_bulk.dev_addr); diff --git a/tests/test/host/ehci/test_pipe_control_xfer.c b/tests/test/host/ehci/test_pipe_control_xfer.c index f62b72ba6..1d2da41b8 100644 --- a/tests/test/host/ehci/test_pipe_control_xfer.c +++ b/tests/test/host/ehci/test_pipe_control_xfer.c @@ -36,6 +36,7 @@ */ /**************************************************************************/ +#include #include "unity.h" #include "tusb_option.h" #include "errors.h" @@ -74,22 +75,28 @@ void setUp(void) memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); memclr_(xfer_data, sizeof(xfer_data)); - hcd_init(); + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_init() ); dev_addr = 1; hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - for (uint8_t i=0; inext.address ); TEST_ASSERT_TRUE( p_status->next.terminate ); - verify_qtd(p_setup, &request_get_dev_desc, 8); + verify_qtd(p_setup, (uint8_t*) &request_get_dev_desc, 8); } //--------------------------------------------------------------------+ @@ -171,7 +180,8 @@ void test_control_addr0_xfer_get_check_qhd_qtd_mapping(void) void test_control_xfer_get(void) { //------------- Code Under TEST -------------// - hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data); + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data) ); TEST_ASSERT_EQUAL_HEX( p_setup, p_control_qhd->qtd_overlay.next.address ); TEST_ASSERT_EQUAL_HEX( p_setup , p_control_qhd->p_qtd_list_head); @@ -180,7 +190,7 @@ void test_control_xfer_get(void) TEST_ASSERT_TRUE( p_status->next.terminate ); //------------- SETUP -------------// - verify_qtd(p_setup, &request_get_dev_desc, 8); + verify_qtd(p_setup, (uint8_t*) &request_get_dev_desc, 8); TEST_ASSERT_FALSE(p_setup->int_on_complete); TEST_ASSERT_FALSE(p_setup->data_toggle); @@ -206,7 +216,8 @@ void test_control_xfer_get(void) void test_control_xfer_set(void) { //------------- Code Under TEST -------------// - hcd_pipe_control_xfer(dev_addr, &request_set_dev_addr, xfer_data); + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_pipe_control_xfer(dev_addr, &request_set_dev_addr, xfer_data) ); TEST_ASSERT_EQUAL_HEX( p_setup, p_control_qhd->qtd_overlay.next.address ); TEST_ASSERT_EQUAL_HEX( p_setup , p_control_qhd->p_qtd_list_head); @@ -226,7 +237,9 @@ void test_control_xfer_set(void) void test_control_xfer_complete_isr(void) { - hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data); + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data) ); + usbh_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, TUSB_EVENT_XFER_COMPLETE); //------------- Code Under TEST -------------// @@ -243,7 +256,9 @@ void test_control_xfer_complete_isr(void) void test_control_xfer_error_isr(void) { - hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data); + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data) ); + usbh_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, TUSB_EVENT_XFER_ERROR); //------------- Code Under TEST -------------// diff --git a/tests/test/host/ehci/test_pipe_interrupt_open.c b/tests/test/host/ehci/test_pipe_interrupt_open.c index 8b180a224..6e596b312 100644 --- a/tests/test/host/ehci/test_pipe_interrupt_open.c +++ b/tests/test/host/ehci/test_pipe_interrupt_open.c @@ -72,13 +72,11 @@ void setUp(void) dev_addr = 1; hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - for (uint8_t i=0; i #include "unity.h" #include "tusb_option.h" #include "errors.h" @@ -91,20 +92,21 @@ void setUp(void) memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); memclr_(xfer_data, sizeof(xfer_data)); - hcd_init(); + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_init() ); dev_addr = 1; hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - for (uint8_t i=0; ip_qtd_list_head; TEST_ASSERT_NOT_NULL(p_qtd); @@ -164,8 +167,11 @@ void test_interrupt_xfer(void) void test_interrupt_xfer_double(void) { //------------- Code Under Test -------------// - hcd_pipe_xfer(pipe_hdl_interrupt, xfer_data, sizeof(xfer_data), false); - hcd_pipe_xfer(pipe_hdl_interrupt, data2, sizeof(data2), true); + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_pipe_xfer(pipe_hdl_interrupt, xfer_data, sizeof(xfer_data), false) ); + + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_pipe_xfer(pipe_hdl_interrupt, data2, sizeof(data2), true) ); ehci_qtd_t* p_head = p_qhd_interrupt->p_qtd_list_head; ehci_qtd_t* p_tail = p_qhd_interrupt->p_qtd_list_tail; @@ -196,8 +202,11 @@ void check_qhd_after_complete(ehci_qhd_t *p_qhd) void test_interrupt_xfer_complete_isr_interval_less_than_1ms(void) { - hcd_pipe_xfer(pipe_hdl_interrupt, xfer_data, sizeof(xfer_data), false); - hcd_pipe_xfer(pipe_hdl_interrupt, data2, sizeof(data2), true); + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_pipe_xfer(pipe_hdl_interrupt, xfer_data, sizeof(xfer_data), false) ); + + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_pipe_xfer(pipe_hdl_interrupt, data2, sizeof(data2), true) ); usbh_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, TUSB_EVENT_XFER_COMPLETE); @@ -220,7 +229,8 @@ void test_interrupt_xfer_complete_isr_interval_2ms(void) pipe_handle_t pipe_hdl_2ms = hcd_pipe_open(dev_addr, &desc_endpoint_2ms, TUSB_CLASS_HID); ehci_qhd_t * p_qhd_2ms = &ehci_data.device[ dev_addr -1].qhd[ pipe_hdl_2ms.index ]; - hcd_pipe_xfer(pipe_hdl_2ms, xfer_data, sizeof(xfer_data), false); + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_pipe_xfer(pipe_hdl_2ms, xfer_data, sizeof(xfer_data), false) ); ehci_qtd_t* p_head = p_qhd_2ms->p_qtd_list_head; ehci_qtd_t* p_tail = p_qhd_2ms->p_qtd_list_tail; diff --git a/tests/test/support/ehci_controller_fake.h b/tests/test/support/ehci_controller_fake.h index d5b82c6ee..a71beaf03 100644 --- a/tests/test/support/ehci_controller_fake.h +++ b/tests/test/support/ehci_controller_fake.h @@ -62,6 +62,7 @@ extern ehci_data_t ehci_data; void ehci_controller_init(void); void ehci_controller_run(uint8_t hostid); +void ehci_controller_run_error(uint8_t hostid); void ehci_controller_control_xfer_proceed(uint8_t dev_addr, uint8_t p_data[]); void ehci_controller_device_plug(uint8_t hostid, tusb_speed_t speed); void ehci_controller_device_unplug(uint8_t hostid);