From 6354f4bb4dce3d2389ca0aeb11066b4e5af789fc Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 12 May 2013 20:06:55 +0700 Subject: [PATCH] tired of refractoring tests (wanting to do some production code) --- tests/test/host/ehci/test_ehci_isr.c | 1 - tests/test/host/ehci/test_pipe_bulk_open.c | 12 ++++---- tests/test/host/ehci/test_pipe_bulk_xfer.c | 32 +++++++++++++--------- tests/test/support/ehci_controller_fake.h | 2 ++ tests/test/support/tusb_config.h | 3 +- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/tests/test/host/ehci/test_ehci_isr.c b/tests/test/host/ehci/test_ehci_isr.c index 51346568..93a33041 100644 --- a/tests/test/host/ehci/test_ehci_isr.c +++ b/tests/test/host/ehci/test_ehci_isr.c @@ -43,7 +43,6 @@ #include "binary.h" #include "hal.h" -#include "hcd.h" #include "ehci.h" #include "ehci_controller_fake.h" diff --git a/tests/test/host/ehci/test_pipe_bulk_open.c b/tests/test/host/ehci/test_pipe_bulk_open.c index 7669f18f..34d88e0e 100644 --- a/tests/test/host/ehci/test_pipe_bulk_open.c +++ b/tests/test/host/ehci/test_pipe_bulk_open.c @@ -36,6 +36,7 @@ */ /**************************************************************************/ +#include #include "unity.h" #include "tusb_option.h" #include "errors.h" @@ -69,13 +70,10 @@ void setUp(void) dev_addr = 1; hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; - for (uint8_t i=0; ip_qtd_list_head; TEST_ASSERT(p_qtd->pingstate_err); @@ -163,7 +162,8 @@ void test_bulk_xfer_hs_ping_out(void) void test_bulk_xfer(void) { //------------- Code Under Test -------------// - hcd_pipe_xfer(pipe_hdl_bulk, xfer_data, sizeof(xfer_data), true); + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_pipe_xfer(pipe_hdl_bulk, xfer_data, sizeof(xfer_data), true) ); ehci_qtd_t* p_qtd = p_qhd_bulk->p_qtd_list_head; TEST_ASSERT_NOT_NULL(p_qtd); @@ -178,8 +178,11 @@ void test_bulk_xfer(void) void test_bulk_xfer_double(void) { //------------- Code Under Test -------------// - hcd_pipe_xfer(pipe_hdl_bulk, xfer_data, sizeof(xfer_data), false); - hcd_pipe_xfer(pipe_hdl_bulk, data2, sizeof(data2), true); + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_pipe_xfer(pipe_hdl_bulk, xfer_data, sizeof(xfer_data), false) ); + + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_pipe_xfer(pipe_hdl_bulk, data2, sizeof(data2), true) ); ehci_qtd_t* p_head = p_qhd_bulk->p_qtd_list_head; ehci_qtd_t* p_tail = p_qhd_bulk->p_qtd_list_tail; @@ -203,8 +206,11 @@ void test_bulk_xfer_double(void) void test_bulk_xfer_complete_isr(void) { - hcd_pipe_xfer(pipe_hdl_bulk, xfer_data, sizeof(xfer_data), false); - hcd_pipe_xfer(pipe_hdl_bulk, data2, sizeof(data2), true); + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_pipe_xfer(pipe_hdl_bulk, xfer_data, sizeof(xfer_data), false) ); + + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, + hcd_pipe_xfer(pipe_hdl_bulk, data2, sizeof(data2), true) ); ehci_qtd_t* p_head = p_qhd_bulk->p_qtd_list_head; ehci_qtd_t* p_tail = p_qhd_bulk->p_qtd_list_tail; diff --git a/tests/test/support/ehci_controller_fake.h b/tests/test/support/ehci_controller_fake.h index 7c8b0c27..d5b82c6e 100644 --- a/tests/test/support/ehci_controller_fake.h +++ b/tests/test/support/ehci_controller_fake.h @@ -52,6 +52,8 @@ #ifndef _TUSB_EHCI_CONTROLLER_H_ #define _TUSB_EHCI_CONTROLLER_H_ +#include "host/hcd.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/tests/test/support/tusb_config.h b/tests/test/support/tusb_config.h index d91033c5..fe881551 100644 --- a/tests/test/support/tusb_config.h +++ b/tests/test/support/tusb_config.h @@ -80,7 +80,8 @@ //#define HOST_HCD_XFER_ISOCHRONOUS // Test support -#define TEST_CONTROLLER_HOST_START_INDEX ( ((CONTROLLER_HOST_NUMBER == 1) && (TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_HOST)) ? 1 : 0) +#define TEST_CONTROLLER_HOST_START_INDEX \ + ( ((CONTROLLER_HOST_NUMBER == 1) && (TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_HOST)) ? 1 : 0) //--------------------------------------------------------------------+ // DEVICE CONFIGURATION