change ceedling ignore plugin to default : ignore arg & calls

continue on refractoring tests
This commit is contained in:
hathach
2013-05-13 00:54:43 +07:00
parent 4dd38f0df6
commit f540a90f8a
5 changed files with 39 additions and 53 deletions

View File

@@ -73,7 +73,7 @@
- :ignore - :ignore
- :callback - :callback
- :array - :array
:ignore: :args_only #:ignore: :args_only
# :unity_helper_path: test/support/type_helper.h # :unity_helper_path: test/support/type_helper.h
:treat_as: :treat_as:
uint8: HEX8 uint8: HEX8

View File

@@ -52,7 +52,6 @@
#include "ehci.h" #include "ehci.h"
#include "ehci_controller_fake.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 const control_max_packet_size = 64;
static uint8_t hub_addr; static uint8_t hub_addr;
static uint8_t hub_port; static uint8_t hub_port;
@@ -62,17 +61,27 @@ static ehci_registers_t * regs;
static ehci_qhd_t *async_head; static ehci_qhd_t *async_head;
static ehci_qhd_t *period_head_arr; static ehci_qhd_t *period_head_arr;
void class_init_expect(void)
{
hidh_init_Expect();
//TODO update more classes
}
void setUp(void) 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; hub_addr = hub_port = 0;
dev_addr = 1; dev_addr = 1;
hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; 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++) for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++)
{ {
@@ -85,7 +94,7 @@ void setUp(void)
regs = get_operational_register(hostid); regs = get_operational_register(hostid);
async_head = get_async_head( hostid ); async_head = get_async_head( hostid );
period_head_arr = get_period_head( hostid, 1 ); period_head_arr = (ehci_qhd_t*) get_period_head( hostid, 1 );
regs->usb_sts = 0; // hcd_init clear usb_sts by writing 1s regs->usb_sts = 0; // hcd_init clear usb_sts by writing 1s
} }

View File

@@ -181,15 +181,12 @@ void test_keyboard_get_report_xfer_failed_busy()
void test_keyboard_get_ok() void test_keyboard_get_ok()
{ {
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); 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); hcd_pipe_xfer_ExpectAndReturn(p_hidh_kbd->pipe_hdl, (uint8_t*) &report, p_hidh_kbd->report_size, true, TUSB_ERROR_NONE);
//------------- Code Under TEST -------------// //------------- Code Under TEST -------------//
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_hid_keyboard_get_report(dev_addr, 0, &report)); 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)); TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_BUSY, tusbh_hid_keyboard_status(dev_addr, 0));
} }

View File

@@ -171,14 +171,11 @@ void test_mouse_get_ok()
{ {
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, tusbh_hid_mouse_status(dev_addr, 0)); 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); hcd_pipe_xfer_ExpectAndReturn(p_hidh_mouse->pipe_hdl, (uint8_t*) &report, p_hidh_mouse->report_size, true, TUSB_ERROR_NONE);
//------------- Code Under TEST -------------// //------------- Code Under TEST -------------//
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_hid_mouse_get_report(dev_addr, 0, &report)); 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)); TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_BUSY, tusbh_hid_mouse_status(dev_addr, 0));
} }

View File

@@ -36,23 +36,24 @@
*/ */
/**************************************************************************/ /**************************************************************************/
#include <stdlib.h>
#include "unity.h" #include "unity.h"
#include "errors.h" #include "errors.h"
#include "type_helper.h"
#include "mock_osal.h" #include "mock_osal.h"
#include "usbh.h" #include "usbh.h"
#include "usbh_hcd.h"
#include "mock_hcd.h" #include "mock_hcd.h"
#include "usbh_hcd.h" #include "usbh_hcd.h"
#include "mock_tusb_callback.h" #include "mock_tusb_callback.h"
#include "mock_hid_host.h" #include "mock_hid_host.h"
extern usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
uint8_t dev_addr; uint8_t dev_addr;
void setUp(void) void setUp(void)
{ {
dev_addr = RANDOM(TUSB_CFG_HOST_DEVICE_MAX)+1; 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) void tearDown(void)
@@ -88,12 +89,7 @@ void test_usbh_init_hcd_failed(void)
void test_usbh_init_enum_task_create_failed(void) void test_usbh_init_enum_task_create_failed(void)
{ {
hcd_init_ExpectAndReturn(TUSB_ERROR_NONE); hcd_init_ExpectAndReturn(TUSB_ERROR_NONE);
for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) osal_semaphore_create_IgnoreAndReturn( (osal_semaphore_handle_t) 0x1234);
{
osal_semaphore_handle_t sem_hdl_dummy = 0x2233;
osal_semaphore_create_IgnoreAndReturn(sem_hdl_dummy);
}
osal_task_create_IgnoreAndReturn(TUSB_ERROR_OSAL_TASK_FAILED); osal_task_create_IgnoreAndReturn(TUSB_ERROR_OSAL_TASK_FAILED);
TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_TASK_FAILED, usbh_init()); 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) void test_usbh_init_enum_queue_create_failed(void)
{ {
hcd_init_ExpectAndReturn(TUSB_ERROR_NONE); hcd_init_ExpectAndReturn(TUSB_ERROR_NONE);
for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) osal_semaphore_create_IgnoreAndReturn( (osal_semaphore_handle_t) 0x1234);
{
osal_semaphore_handle_t sem_hdl_dummy = 0x2233;
osal_semaphore_create_IgnoreAndReturn(sem_hdl_dummy);
}
osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE); osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE);
osal_queue_create_IgnoreAndReturn(NULL); osal_queue_create_IgnoreAndReturn(NULL);
TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_QUEUE_FAILED, usbh_init()); 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) 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); hcd_init_ExpectAndReturn(TUSB_ERROR_NONE);
for (uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) osal_semaphore_create_IgnoreAndReturn( (osal_semaphore_handle_t) 0x1234);
{
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_task_create_IgnoreAndReturn(TUSB_ERROR_NONE); 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(); class_init_expect();
//------------- code under test -------------//
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, usbh_init()); 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) void class_close_expect(void)