diff options
| author | hathach <[email protected]> | 2013-05-13 22:57:54 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-05-13 22:57:54 +0700 |
| commit | 706523ebff31ab1cbc0494bf331e8d9c5577a6c7 (patch) | |
| tree | 34800007487cdfe5a618c344361fb43ba9d613da /tests/test/host | |
| parent | e0aa3c1fca1b9da31c89bc8b7ff6bdbe0ef6817e (diff) | |
refractor test code using host_helper
Diffstat (limited to 'tests/test/host')
| -rw-r--r-- | tests/test/host/ehci/test_ehci_init.c | 9 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_pipe_bulk_open.c | 14 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_pipe_bulk_xfer.c | 15 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_pipe_control_open.c | 13 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_pipe_control_xfer.c | 15 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_pipe_interrupt_open.c | 7 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_pipe_interrupt_xfer.c | 7 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_pipe_isochronous_open.c | 11 | ||||
| -rw-r--r-- | tests/test/host/hid/test_hidh_mouse.c | 1 |
9 files changed, 26 insertions, 66 deletions
diff --git a/tests/test/host/ehci/test_ehci_init.c b/tests/test/host/ehci/test_ehci_init.c index e311c7c7c..09e7e7f1b 100644 --- a/tests/test/host/ehci/test_ehci_init.c +++ b/tests/test/host/ehci/test_ehci_init.c @@ -53,7 +53,6 @@ usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; -static uint8_t dev_addr; static uint8_t hostid; //--------------------------------------------------------------------+ @@ -64,15 +63,7 @@ void setUp(void) ehci_controller_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; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) - { - usbh_devices[i].core_id = hostid; - usbh_devices[i].hub_addr = 0; - usbh_devices[i].hub_port = 0; - usbh_devices[i].speed = TUSB_SPEED_HIGH; - } } void tearDown(void) diff --git a/tests/test/host/ehci/test_pipe_bulk_open.c b/tests/test/host/ehci/test_pipe_bulk_open.c index 34d88e0ed..902aabfcc 100644 --- a/tests/test/host/ehci/test_pipe_bulk_open.c +++ b/tests/test/host/ehci/test_pipe_bulk_open.c @@ -48,6 +48,7 @@ #include "mock_usbh_hcd.h" #include "ehci.h" #include "ehci_controller_fake.h" +#include "host_helper.h" usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; @@ -63,17 +64,14 @@ static ehci_qhd_t *async_head; //--------------------------------------------------------------------+ void setUp(void) { - memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); - - hcd_init(); + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_init() ); dev_addr = 1; - hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - usbh_devices[dev_addr].core_id = hostid; - usbh_devices[dev_addr].hub_addr = hub_addr; - usbh_devices[dev_addr].hub_port = hub_port; - usbh_devices[dev_addr].speed = TUSB_SPEED_HIGH; + + memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); + helper_usbh_device_emulate(dev_addr, hub_addr, hub_port, hostid, TUSB_SPEED_HIGH); async_head = get_async_head( hostid ); } diff --git a/tests/test/host/ehci/test_pipe_bulk_xfer.c b/tests/test/host/ehci/test_pipe_bulk_xfer.c index 3ab12fb0e..18cca68c5 100644 --- a/tests/test/host/ehci/test_pipe_bulk_xfer.c +++ b/tests/test/host/ehci/test_pipe_bulk_xfer.c @@ -48,11 +48,12 @@ #include "mock_usbh_hcd.h" #include "ehci.h" #include "ehci_controller_fake.h" +#include "host_helper.h" usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; -static uint8_t const hub_addr = 2; -static uint8_t const hub_port = 2; +static uint8_t hub_addr = 2; +static uint8_t hub_port = 2; static uint8_t dev_addr; static uint8_t hostid; static uint8_t xfer_data [18000]; // 18K to test buffer pointer list @@ -88,21 +89,15 @@ tusb_descriptor_endpoint_t const desc_ept_bulk_out = void setUp(void) { ehci_controller_init(); - - memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); memclr_(xfer_data, sizeof(xfer_data)); + memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, hcd_init() ); dev_addr = 1; - hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - - usbh_devices[dev_addr].core_id = hostid; - usbh_devices[dev_addr].hub_addr = hub_addr; - usbh_devices[dev_addr].hub_port = hub_port; - usbh_devices[dev_addr].speed = TUSB_SPEED_HIGH; + helper_usbh_device_emulate(dev_addr, hub_addr, hub_port, hostid, TUSB_SPEED_HIGH); async_head = get_async_head( hostid ); diff --git a/tests/test/host/ehci/test_pipe_control_open.c b/tests/test/host/ehci/test_pipe_control_open.c index b07974200..6a933da06 100644 --- a/tests/test/host/ehci/test_pipe_control_open.c +++ b/tests/test/host/ehci/test_pipe_control_open.c @@ -48,6 +48,7 @@ #include "mock_usbh_hcd.h" #include "ehci.h" #include "ehci_controller_fake.h" +#include "host_helper.h" usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; @@ -71,18 +72,10 @@ void setUp(void) hcd_init() ); dev_addr = 1; - hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - usbh_devices[0].core_id = hostid; - usbh_devices[0].hub_addr = hub_addr; - usbh_devices[0].hub_port = hub_port; - usbh_devices[0].speed = TUSB_SPEED_HIGH; - - usbh_devices[dev_addr].core_id = hostid; - usbh_devices[dev_addr].hub_addr = hub_addr; - usbh_devices[dev_addr].hub_port = hub_port; - usbh_devices[dev_addr].speed = TUSB_SPEED_HIGH; + helper_usbh_device_emulate(0, hub_addr, hub_port, hostid, TUSB_SPEED_HIGH); + helper_usbh_device_emulate(dev_addr, hub_addr, hub_port, hostid, TUSB_SPEED_HIGH); async_head = get_async_head( hostid ); p_control_qhd = &ehci_data.device[dev_addr-1].control.qhd; diff --git a/tests/test/host/ehci/test_pipe_control_xfer.c b/tests/test/host/ehci/test_pipe_control_xfer.c index 1d2da41b8..476a5d8ed 100644 --- a/tests/test/host/ehci/test_pipe_control_xfer.c +++ b/tests/test/host/ehci/test_pipe_control_xfer.c @@ -48,6 +48,7 @@ #include "mock_usbh_hcd.h" #include "ehci.h" #include "ehci_controller_fake.h" +#include "host_helper.h" usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; @@ -79,18 +80,10 @@ void setUp(void) hcd_init() ); dev_addr = 1; + hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - - usbh_devices[0].core_id = hostid; - usbh_devices[0].hub_addr = hub_addr; - usbh_devices[0].hub_port = hub_port; - usbh_devices[0].speed = TUSB_SPEED_HIGH; - - usbh_devices[dev_addr].core_id = hostid; - usbh_devices[dev_addr].hub_addr = hub_addr; - usbh_devices[dev_addr].hub_port = hub_port; - usbh_devices[dev_addr].speed = TUSB_SPEED_HIGH; + helper_usbh_device_emulate(0 , hub_addr, hub_port, hostid, TUSB_SPEED_HIGH); + helper_usbh_device_emulate(dev_addr , hub_addr, hub_port, hostid, TUSB_SPEED_HIGH); async_head = get_async_head( hostid ); diff --git a/tests/test/host/ehci/test_pipe_interrupt_open.c b/tests/test/host/ehci/test_pipe_interrupt_open.c index 6e596b312..0b84440e0 100644 --- a/tests/test/host/ehci/test_pipe_interrupt_open.c +++ b/tests/test/host/ehci/test_pipe_interrupt_open.c @@ -47,6 +47,7 @@ #include "mock_usbh_hcd.h" #include "ehci.h" #include "ehci_controller_fake.h" +#include "host_helper.h" usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; @@ -70,13 +71,9 @@ void setUp(void) hcd_init(); dev_addr = 1; - hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - usbh_devices[dev_addr].core_id = hostid; - usbh_devices[dev_addr].hub_addr = hub_addr; - usbh_devices[dev_addr].hub_port = hub_port; - usbh_devices[dev_addr].speed = TUSB_SPEED_HIGH; + helper_usbh_device_emulate(dev_addr , hub_addr, hub_port, hostid, TUSB_SPEED_HIGH); period_head_arr = get_period_head( hostid, 1 ); p_int_qhd = NULL; diff --git a/tests/test/host/ehci/test_pipe_interrupt_xfer.c b/tests/test/host/ehci/test_pipe_interrupt_xfer.c index adf6c62d0..aaa1e213d 100644 --- a/tests/test/host/ehci/test_pipe_interrupt_xfer.c +++ b/tests/test/host/ehci/test_pipe_interrupt_xfer.c @@ -48,6 +48,7 @@ #include "mock_usbh_hcd.h" #include "ehci.h" #include "ehci_controller_fake.h" +#include "host_helper.h" usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; @@ -96,13 +97,9 @@ void setUp(void) hcd_init() ); dev_addr = 1; - hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - usbh_devices[dev_addr].core_id = hostid; - usbh_devices[dev_addr].hub_addr = hub_addr; - usbh_devices[dev_addr].hub_port = hub_port; - usbh_devices[dev_addr].speed = TUSB_SPEED_HIGH; + helper_usbh_device_emulate(dev_addr , hub_addr, hub_port, hostid, TUSB_SPEED_HIGH); period_head_arr = (ehci_qhd_t*) get_period_head( hostid, 1 ); diff --git a/tests/test/host/ehci/test_pipe_isochronous_open.c b/tests/test/host/ehci/test_pipe_isochronous_open.c index 560ad06ce..df3b407fe 100644 --- a/tests/test/host/ehci/test_pipe_isochronous_open.c +++ b/tests/test/host/ehci/test_pipe_isochronous_open.c @@ -47,6 +47,7 @@ #include "mock_usbh_hcd.h" #include "ehci.h" #include "ehci_controller_fake.h" +#include "host_helper.h" usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; @@ -66,15 +67,9 @@ void setUp(void) hcd_init(); dev_addr = 1; - hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) - { - usbh_devices[i].core_id = hostid; - usbh_devices[i].hub_addr = hub_addr; - usbh_devices[i].hub_port = hub_port; - usbh_devices[i].speed = TUSB_SPEED_HIGH; - } + + helper_usbh_device_emulate(dev_addr , hub_addr, hub_port, hostid, TUSB_SPEED_HIGH); period_head_arr = get_period_head( hostid, 1 ); } diff --git a/tests/test/host/hid/test_hidh_mouse.c b/tests/test/host/hid/test_hidh_mouse.c index 1496e6676..c169a6099 100644 --- a/tests/test/host/hid/test_hidh_mouse.c +++ b/tests/test/host/hid/test_hidh_mouse.c @@ -41,6 +41,7 @@ #include "type_helper.h" #include "errors.h" #include "common/common.h" + #include "hid_host.h" #include "mock_osal.h" #include "mock_usbh.h" |
