change ceedling ignore plugin to default : ignore arg & calls
continue on refractoring tests
This commit is contained in:
@@ -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
|
||||
|
@@ -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 class_init_expect(void)
|
||||
{
|
||||
hidh_init_Expect();
|
||||
|
||||
//TODO update more classes
|
||||
}
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
ehci_controller_init();
|
||||
memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1));
|
||||
|
||||
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 );
|
||||
|
@@ -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));
|
||||
}
|
||||
|
||||
|
@@ -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));
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user