diff options
| author | hathach <[email protected]> | 2013-05-13 00:54:43 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-05-13 00:54:43 +0700 |
| commit | f540a90f8a1c3651a64db70bd7fa6445cf68e943 (patch) | |
| tree | b685d55fedd9fa51a8cbda8bcf18122be6674506 /tests | |
| parent | 4dd38f0df6d03869caa4cf47d0e16f8e2a5b4db5 (diff) | |
change ceedling ignore plugin to default : ignore arg & calls
continue on refractoring tests
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/project.yml | 2 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_ehci_usbh_hcd_integration.c | 31 | ||||
| -rw-r--r-- | tests/test/host/hid/test_hidh_keyboard.c | 5 | ||||
| -rw-r--r-- | tests/test/host/hid/test_hidh_mouse.c | 3 | ||||
| -rw-r--r-- | tests/test/host/usbh/test_usbh.c | 51 |
5 files changed, 39 insertions, 53 deletions
diff --git a/tests/project.yml b/tests/project.yml index 6671e056b..8aed8b07a 100644 --- a/tests/project.yml +++ b/tests/project.yml @@ -73,7 +73,7 @@ - :ignore - :callback - :array - :ignore: :args_only + #:ignore: :args_only # :unity_helper_path: test/support/type_helper.h :treat_as: uint8: HEX8 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 520de73d5..c3bda8137 100644 --- a/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c +++ b/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c @@ -52,7 +52,6 @@ #include "ehci.h" #include "ehci_controller_fake.h" -usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; static uint8_t const control_max_packet_size = 64; static uint8_t hub_addr; static uint8_t hub_port; @@ -62,17 +61,27 @@ static ehci_registers_t * regs; static ehci_qhd_t *async_head; static ehci_qhd_t *period_head_arr; -void setUp(void) +void class_init_expect(void) { - ehci_controller_init(); - memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); + hidh_init_Expect(); + + //TODO update more classes +} +void setUp(void) +{ hub_addr = hub_port = 0; dev_addr = 1; - hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - hcd_init(); + ehci_controller_init(); + + osal_semaphore_create_IgnoreAndReturn( (osal_semaphore_handle_t) 0x1234); + osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE); + osal_queue_create_IgnoreAndReturn( (osal_queue_handle_t) 0x4566 ); + class_init_expect(); + + usbh_init(); for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) { @@ -83,10 +92,10 @@ void setUp(void) usbh_devices[i].state = i ? TUSB_DEVICE_STATE_CONFIGURED : TUSB_DEVICE_STATE_UNPLUG; } - regs = get_operational_register(hostid); - async_head = get_async_head( hostid ); - period_head_arr = get_period_head( hostid, 1 ); - regs->usb_sts = 0; // hcd_init clear usb_sts by writing 1s + regs = get_operational_register(hostid); + async_head = get_async_head( hostid ); + period_head_arr = (ehci_qhd_t*) get_period_head( hostid, 1 ); + regs->usb_sts = 0; // hcd_init clear usb_sts by writing 1s } void tearDown(void) @@ -110,7 +119,7 @@ void test_addr0_control_close(void) //------------- Code Under Test -------------// regs->usb_sts_bit.port_change_detect = 0; // clear port change detect - regs->usb_sts_bit.async_advance = 1; + regs->usb_sts_bit.async_advance = 1; hcd_isr(hostid); // async advance TEST_ASSERT( p_qhd->qtd_overlay.halted ); diff --git a/tests/test/host/hid/test_hidh_keyboard.c b/tests/test/host/hid/test_hidh_keyboard.c index 7fa01a4ed..da00e9266 100644 --- a/tests/test/host/hid/test_hidh_keyboard.c +++ b/tests/test/host/hid/test_hidh_keyboard.c @@ -181,15 +181,12 @@ void test_keyboard_get_report_xfer_failed_busy() void test_keyboard_get_ok() { tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); - TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, tusbh_hid_keyboard_status(dev_addr, 0)); - tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); + TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, tusbh_hid_keyboard_status(dev_addr, 0)); hcd_pipe_xfer_ExpectAndReturn(p_hidh_kbd->pipe_hdl, (uint8_t*) &report, p_hidh_kbd->report_size, true, TUSB_ERROR_NONE); //------------- Code Under TEST -------------// TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_hid_keyboard_get_report(dev_addr, 0, &report)); - - tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_BUSY, tusbh_hid_keyboard_status(dev_addr, 0)); } diff --git a/tests/test/host/hid/test_hidh_mouse.c b/tests/test/host/hid/test_hidh_mouse.c index 1b74e45ba..1496e6676 100644 --- a/tests/test/host/hid/test_hidh_mouse.c +++ b/tests/test/host/hid/test_hidh_mouse.c @@ -171,14 +171,11 @@ void test_mouse_get_ok() { tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, tusbh_hid_mouse_status(dev_addr, 0)); - - tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); hcd_pipe_xfer_ExpectAndReturn(p_hidh_mouse->pipe_hdl, (uint8_t*) &report, p_hidh_mouse->report_size, true, TUSB_ERROR_NONE); //------------- Code Under TEST -------------// TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_hid_mouse_get_report(dev_addr, 0, &report)); - tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_BUSY, tusbh_hid_mouse_status(dev_addr, 0)); } diff --git a/tests/test/host/usbh/test_usbh.c b/tests/test/host/usbh/test_usbh.c index 4f5d7082c..c1ff1007b 100644 --- a/tests/test/host/usbh/test_usbh.c +++ b/tests/test/host/usbh/test_usbh.c @@ -36,23 +36,24 @@ */ /**************************************************************************/ +#include <stdlib.h> #include "unity.h" #include "errors.h" +#include "type_helper.h" #include "mock_osal.h" #include "usbh.h" +#include "usbh_hcd.h" #include "mock_hcd.h" #include "usbh_hcd.h" #include "mock_tusb_callback.h" #include "mock_hid_host.h" -extern usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; uint8_t dev_addr; void setUp(void) { dev_addr = RANDOM(TUSB_CFG_HOST_DEVICE_MAX)+1; - memset(usbh_devices, 0, (TUSB_CFG_HOST_DEVICE_MAX+1)*sizeof(usbh_device_info_t)); } void tearDown(void) @@ -88,12 +89,7 @@ void test_usbh_init_hcd_failed(void) void test_usbh_init_enum_task_create_failed(void) { hcd_init_ExpectAndReturn(TUSB_ERROR_NONE); - for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) - { - osal_semaphore_handle_t sem_hdl_dummy = 0x2233; - osal_semaphore_create_IgnoreAndReturn(sem_hdl_dummy); - } - + osal_semaphore_create_IgnoreAndReturn( (osal_semaphore_handle_t) 0x1234); osal_task_create_IgnoreAndReturn(TUSB_ERROR_OSAL_TASK_FAILED); TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_TASK_FAILED, usbh_init()); } @@ -101,12 +97,7 @@ void test_usbh_init_enum_task_create_failed(void) void test_usbh_init_enum_queue_create_failed(void) { hcd_init_ExpectAndReturn(TUSB_ERROR_NONE); - for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) - { - osal_semaphore_handle_t sem_hdl_dummy = 0x2233; - osal_semaphore_create_IgnoreAndReturn(sem_hdl_dummy); - } - + osal_semaphore_create_IgnoreAndReturn( (osal_semaphore_handle_t) 0x1234); osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE); osal_queue_create_IgnoreAndReturn(NULL); TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_QUEUE_FAILED, usbh_init()); @@ -121,29 +112,21 @@ void class_init_expect(void) void test_usbh_init_ok(void) { - osal_queue_handle_t q_hdl_dummy = 0x1122; - - 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)); - hcd_init_ExpectAndReturn(TUSB_ERROR_NONE); - for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) - { - osal_semaphore_handle_t sem_hdl_dummy = 0x2233; - osal_semaphore_create_IgnoreAndReturn(sem_hdl_dummy); - device_info_zero[i].control.sem_hdl = sem_hdl_dummy; - } - + osal_semaphore_create_IgnoreAndReturn( (osal_semaphore_handle_t) 0x1234); osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE); - osal_queue_create_IgnoreAndReturn(q_hdl_dummy); + osal_queue_create_IgnoreAndReturn( (osal_queue_handle_t) 0x4566 ); class_init_expect(); + //------------- code under test -------------// TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, usbh_init()); - TEST_ASSERT_EQUAL_MEMORY(device_info_zero, usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); - + for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) + { + TEST_ASSERT_NOT_NULL(usbh_devices[i].control.sem_hdl); + } } void class_close_expect(void) @@ -156,7 +139,7 @@ void test_usbh_device_unplugged_isr_device_not_previously_mounted(void) { uint8_t dev_addr = 1; - usbh_devices[dev_addr].state = TUSB_DEVICE_STATE_UNPLUG; + usbh_devices[dev_addr].state = TUSB_DEVICE_STATE_UNPLUG; usbh_devices[dev_addr].core_id = 0; usbh_devices[dev_addr].hub_addr = 0; usbh_devices[dev_addr].hub_port = 0; @@ -168,10 +151,10 @@ void test_usbh_device_unplugged_isr(void) { uint8_t dev_addr = 1; - usbh_devices[dev_addr].state = TUSB_DEVICE_STATE_CONFIGURED; - usbh_devices[dev_addr].core_id = 0; - usbh_devices[dev_addr].hub_addr = 0; - usbh_devices[dev_addr].hub_port = 0; + usbh_devices[dev_addr].state = TUSB_DEVICE_STATE_CONFIGURED; + usbh_devices[dev_addr].core_id = 0; + usbh_devices[dev_addr].hub_addr = 0; + usbh_devices[dev_addr].hub_port = 0; usbh_devices[dev_addr].flag_supported_class = TUSB_CLASS_FLAG_HID; class_close_expect(); |
