start to add code for hcd_init test

change hcd_init signature (omit hostid)
This commit is contained in:
hathach 2013-02-28 17:00:51 +07:00
parent 82bd4719ce
commit 795fe7468d
7 changed files with 35 additions and 24 deletions

View File

@ -42,6 +42,9 @@
#include "mock_osal.h"
#include "ehci.h"
extern ehci_data_t ehci_data;
extern ehci_link_t period_frame_list0[EHCI_FRAMELIST_SIZE];
extern ehci_link_t period_frame_list1[EHCI_FRAMELIST_SIZE];
//--------------------------------------------------------------------+
// Setup/Teardown + helper declare
@ -281,9 +284,23 @@ void test_register_portsc(void)
//--------------------------------------------------------------------+
// EHCI Data Organization
//--------------------------------------------------------------------+
void test_(void)
void test_ehci_data(void)
{
// period fram list alignment
TEST_ASSERT_BITS_LOW(4096-1, (uint32_t)period_frame_list0 );
TEST_ASSERT_BITS_LOW(4096-1, (uint32_t)period_frame_list1 );
//
}
void test_hcd_init(void)
{
hcd_init(0);
//------------- check memory data -------------//
ehci_data_t zeroes;
memclr_(&zeroes, sizeof(ehci_data_t));
TEST_ASSERT_EQUAL_MEMORY(&zeroes, &ehci_data, sizeof(ehci_data_t));
}
//--------------------------------------------------------------------+

View File

@ -78,12 +78,6 @@ void test_usbh_status_get_succeed(void)
//--------------------------------------------------------------------+
// Init
//--------------------------------------------------------------------+
void hcd_init_expect(void)
{
for(uint32_t i=0; i<TUSB_CFG_HOST_CONTROLLER_NUM; i++)
hcd_init_ExpectAndReturn(TUSB_CFG_HOST_CONTROLLER_START_INDEX+i, TUSB_ERROR_NONE);
}
void test_usbh_init_hcd_failed(void)
{
hcd_init_IgnoreAndReturn(TUSB_ERROR_HCD_FAILED);
@ -92,14 +86,14 @@ void test_usbh_init_hcd_failed(void)
void test_usbh_init_enum_task_create_failed(void)
{
hcd_init_expect();
hcd_init_ExpectAndReturn(TUSB_ERROR_NONE);
osal_task_create_IgnoreAndReturn(TUSB_ERROR_OSAL_TASK_FAILED);
TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_TASK_FAILED, usbh_init());
}
void test_usbh_init_enum_queue_create_failed(void)
{
hcd_init_expect();
hcd_init_ExpectAndReturn(TUSB_ERROR_NONE);
osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE);
osal_queue_create_IgnoreAndReturn(NULL);
TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_QUEUE_FAILED, usbh_init());
@ -129,7 +123,7 @@ void test_usbh_init_ok(void)
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_expect();
hcd_init_ExpectAndReturn(TUSB_ERROR_NONE);
osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE);
osal_queue_create_IgnoreAndReturn(dummy);

View File

@ -76,15 +76,6 @@
#include "core/std_descriptors.h"
#include "core/std_request.h"
// TODO try to manipulate gcc cmd option instead
#ifndef _TEST_
#define STATIC_ static
#define INLINE_ inline
#else
#define STATIC_
#define INLINE_
#endif
#define STRING_(x) #x // stringify without expand
#define XSTRING_(x) STRING_(x) // expand then stringify
#define STRING_CONCAT_(a, b) a##b // concat without expand

View File

@ -51,6 +51,16 @@
#ifndef _TUSB_COMPILER_H_
#define _TUSB_COMPILER_H_
#ifdef _TEST_
#define ATTR_ALWAYS_INLINE
#define STATIC_
#define INLINE_
#else
#define STATIC_ static
#define INLINE_ inline
#endif
#if defined(__GNUC__)
#include "compiler_gcc.h"
#elif defined __ICCARM__ // IAR compiler

View File

@ -79,8 +79,10 @@
* @{
*/
#ifndef ATTR_ALWAYS_INLINE
/// Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function even if no optimization level is specified
#define ATTR_ALWAYS_INLINE __attribute__ ((always_inline))
#endif
/// The nonnull attribute specifies that some function parameters should be non-null pointers. f the compiler determines that a null pointer is passed in an argument slot marked as non-null, and the -Wnonnull option is enabled, a warning is issued. All pointer arguments are marked as non-null
#define ATTR_NON_NULL __attribute__ ((nonull))

View File

@ -66,7 +66,7 @@ typedef uint32_t pipe_handle_t;
//--------------------------------------------------------------------+
// USBH-HCD API
//--------------------------------------------------------------------+
tusb_error_t hcd_init(uint8_t hostid) ATTR_WARN_UNUSED_RESULT;
tusb_error_t hcd_init() ATTR_WARN_UNUSED_RESULT;
//--------------------------------------------------------------------+
// PIPE API

View File

@ -88,10 +88,7 @@ tusb_error_t usbh_init(void)
memclr_(usbh_device_info_pool, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1));
for(i=0; i<TUSB_CFG_HOST_CONTROLLER_NUM; i++)
{
ASSERT_STATUS( hcd_init(TUSB_CFG_HOST_CONTROLLER_START_INDEX+i) );
}
ASSERT_STATUS( hcd_init() );
//------------- Enumeration & Reporter Task init -------------//
ASSERT_STATUS( osal_task_create(&enum_task) );