diff options
author | Paul Fagerburg <pfagerburg@google.com> | 2020-08-14 17:20:04 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-08-31 17:06:13 +0000 |
commit | 33db71602297092026bb714f8b038ac0e7ac593d (patch) | |
tree | 4f40eb0fbcc63acd5d8f4387f7d2d554f80ae6b4 /common/mock/usb_pd_dpm_mock.c | |
parent | bd018841f6f2856c949dcf9b6dd462872cd18d7f (diff) | |
download | chrome-ec-33db71602297092026bb714f8b038ac0e7ac593d.tar.gz |
usb_pe_drp: new unit test with mocks
Add a new unit test for usb_pe_drp with mocks for the various
subsystems that it will use.
The fake_prl module is already essentially a mock for the PRL layer,
so just move it into the mocks directory and make it available as
mock to other tests.
BUG=b:163421994
BRANCH=None
TEST=`make runhosttests` succeeds
Signed-off-by: Paul Fagerburg <pfagerburg@google.com>
Change-Id: I2aea3fa0694e8d9e6bae1f47516cb4d5d2a1e714
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2364050
Tested-by: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
Diffstat (limited to 'common/mock/usb_pd_dpm_mock.c')
-rw-r--r-- | common/mock/usb_pd_dpm_mock.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/common/mock/usb_pd_dpm_mock.c b/common/mock/usb_pd_dpm_mock.c new file mode 100644 index 0000000000..18778c36f4 --- /dev/null +++ b/common/mock/usb_pd_dpm_mock.c @@ -0,0 +1,41 @@ +/* Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* + * Mock of Device Policy Manager implementation + * Refer to USB PD 3.0 spec, version 2.0, sections 8.2 and 8.3 + */ + +#include "usb_pd.h" +#include "mock/usb_pd_dpm_mock.h" +#include "memory.h" + +struct mock_dpm_port_t dpm[CONFIG_USB_PD_PORT_MAX_COUNT]; + +void mock_dpm_reset(void) +{ + /* Reset all values to 0. */ + memset(dpm, 0, sizeof(dpm)); +} + +void dpm_init(int port) +{ + dpm[port].mode_entry_done = false; + dpm[port].mode_exit_request = false; +} + +void dpm_vdm_acked(int port, enum tcpm_transmit_type type, int vdo_count, + uint32_t *vdm) +{ +} + +void dpm_vdm_naked(int port, enum tcpm_transmit_type type, uint16_t svid, + uint8_t vdm_cmd) +{ +} + +void dpm_run(int port) +{ +} |