diff options
author | Abe Levkoy <alevkoy@chromium.org> | 2020-12-07 17:39:09 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-12-15 15:39:18 +0000 |
commit | 0a561def48d4e673c834f4d01506ba8b9886cdd4 (patch) | |
tree | cbca0104ac3fe7058c0d58d14abd95decb39da6e /test | |
parent | 160208413d16840428e42ecae18457e862e6ed49 (diff) | |
download | chrome-ec-0a561def48d4e673c834f4d01506ba8b9886cdd4.tar.gz |
mock: Clean up TCPMv2 mocks
Place mock functions in the mock libraries corresponding to the layers
of the real implementations. Broadly, move towards one layer of the TCPM
stack as a UUT, with mocks for the other layers as needed. There should
be a one-to-one correspondence between real modules and mock modules.
usb_pd_mock.c does not correspond to any real implementation module or
TCPM stack layer, so remove it and move its contents to the layers
corresponding to their real implementations.
Also clean up some redundant or misplaced mocks inside tests.
BUG=b:153071799,b:173791979
TEST=make buildall
BRANCH=none
Signed-off-by: Abe Levkoy <alevkoy@chromium.org>
Change-Id: Ic44df8675de2b9f1f8c7669cd97dcdc296bf107f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2578200
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/usb_pe_drp.c | 6 | ||||
-rw-r--r-- | test/usb_pe_drp.mocklist | 1 | ||||
-rw-r--r-- | test/usb_pe_drp_noextended.mocklist | 1 | ||||
-rw-r--r-- | test/usb_prl.c | 5 | ||||
-rw-r--r-- | test/usb_prl.mocklist | 1 | ||||
-rw-r--r-- | test/usb_typec_drp_acc_trysrc.c | 13 |
6 files changed, 4 insertions, 23 deletions
diff --git a/test/usb_pe_drp.c b/test/usb_pe_drp.c index be040dff0c..10269db779 100644 --- a/test/usb_pe_drp.c +++ b/test/usb_pe_drp.c @@ -16,7 +16,6 @@ #include "mock/usb_tc_sm_mock.h" #include "mock/tcpc_mock.h" #include "mock/usb_mux_mock.h" -#include "mock/usb_pd_mock.h" #include "mock/usb_pd_dpm_mock.h" #include "mock/dp_alt_mode_mock.h" #include "mock/usb_prl_mock.h" @@ -39,7 +38,6 @@ void before_test(void) mock_tc_port_reset(); mock_tcpc_reset(); mock_usb_mux_reset(); - mock_pd_reset(); mock_dpm_reset(); mock_dp_alt_mode_reset(); mock_prl_reset(); @@ -138,7 +136,7 @@ test_static int finish_src_discovery(void) test_static int test_send_caps_error_before_connected(void) { /* Enable PE as source, expect SOURCE_CAP. */ - mock_pd_port[PORT0].power_role = PD_ROLE_SOURCE; + mock_tc_port[PORT0].power_role = PD_ROLE_SOURCE; mock_tc_port[PORT0].pd_enable = 1; mock_tc_port[PORT0].vconn_src = true; TEST_EQ(mock_prl_wait_for_tx_msg(PORT0, TCPC_TX_SOP, @@ -205,7 +203,7 @@ test_static int test_send_caps_error_before_connected(void) test_static int test_send_caps_error_when_connected(void) { /* Enable PE as source, expect SOURCE_CAP. */ - mock_pd_port[PORT0].power_role = PD_ROLE_SOURCE; + mock_tc_port[PORT0].power_role = PD_ROLE_SOURCE; mock_tc_port[PORT0].pd_enable = 1; mock_tc_port[PORT0].vconn_src = true; TEST_EQ(mock_prl_wait_for_tx_msg(PORT0, TCPC_TX_SOP, diff --git a/test/usb_pe_drp.mocklist b/test/usb_pe_drp.mocklist index b690044789..1d8e4c8a81 100644 --- a/test/usb_pe_drp.mocklist +++ b/test/usb_pe_drp.mocklist @@ -5,7 +5,6 @@ #define CONFIG_TEST_MOCK_LIST \ MOCK(USB_TC_SM) \ - MOCK(USB_PD) \ MOCK(TCPC) \ MOCK(USB_MUX) \ MOCK(USB_PD_DPM) \ diff --git a/test/usb_pe_drp_noextended.mocklist b/test/usb_pe_drp_noextended.mocklist index b690044789..1d8e4c8a81 100644 --- a/test/usb_pe_drp_noextended.mocklist +++ b/test/usb_pe_drp_noextended.mocklist @@ -5,7 +5,6 @@ #define CONFIG_TEST_MOCK_LIST \ MOCK(USB_TC_SM) \ - MOCK(USB_PD) \ MOCK(TCPC) \ MOCK(USB_MUX) \ MOCK(USB_PD_DPM) \ diff --git a/test/usb_prl.c b/test/usb_prl.c index d0f3d48322..c381295abf 100644 --- a/test/usb_prl.c +++ b/test/usb_prl.c @@ -7,7 +7,6 @@ #include "common.h" #include "mock/tcpc_mock.h" #include "mock/tcpm_mock.h" -#include "mock/usb_pd_mock.h" #include "mock/usb_pe_sm_mock.h" #include "mock/usb_tc_sm_mock.h" #include "task.h" @@ -140,8 +139,8 @@ void before_test(void) { mock_tc_port_reset(); mock_tc_port[PORT0].rev = PD_REV30; - mock_pd_port[PORT0].power_role = PD_ROLE_SOURCE; - mock_pd_port[PORT0].data_role = PD_ROLE_DFP; + mock_tc_port[PORT0].power_role = PD_ROLE_SOURCE; + mock_tc_port[PORT0].data_role = PD_ROLE_DFP; mock_tcpm_reset(); mock_pe_port_reset(); diff --git a/test/usb_prl.mocklist b/test/usb_prl.mocklist index c89e12e78b..bf5357334a 100644 --- a/test/usb_prl.mocklist +++ b/test/usb_prl.mocklist @@ -6,6 +6,5 @@ #define CONFIG_TEST_MOCK_LIST \ MOCK(TCPC) \ MOCK(TCPM) \ - MOCK(USB_PD) \ MOCK(USB_PE_SM) \ MOCK(USB_TC_SM) diff --git a/test/usb_typec_drp_acc_trysrc.c b/test/usb_typec_drp_acc_trysrc.c index 605d133934..f33c7079cf 100644 --- a/test/usb_typec_drp_acc_trysrc.c +++ b/test/usb_typec_drp_acc_trysrc.c @@ -27,19 +27,6 @@ /* Unreachable time in future */ #define TIMER_DISABLED 0xffffffffffffffff -/* TODO(b/153071799): Move these pd_* and pe_* function into mock */ -__overridable void pd_request_power_swap(int port) -{} - -void pd_set_src_caps(int port, int cnt, uint32_t *src_caps) -{ -} - -__overridable void pe_invalidate_explicit_contract(int port) -{ -} -/* End pd_ mock section */ - /* Install Mock TCPC and MUX drivers */ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { |