summaryrefslogtreecommitdiff
path: root/common/mock/dp_alt_mode_mock.c
diff options
context:
space:
mode:
authorPaul Fagerburg <pfagerburg@google.com>2020-08-14 17:20:04 -0600
committerCommit Bot <commit-bot@chromium.org>2020-08-31 17:06:13 +0000
commit33db71602297092026bb714f8b038ac0e7ac593d (patch)
tree4f40eb0fbcc63acd5d8f4387f7d2d554f80ae6b4 /common/mock/dp_alt_mode_mock.c
parentbd018841f6f2856c949dcf9b6dd462872cd18d7f (diff)
downloadchrome-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/dp_alt_mode_mock.c')
-rw-r--r--common/mock/dp_alt_mode_mock.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/common/mock/dp_alt_mode_mock.c b/common/mock/dp_alt_mode_mock.c
new file mode 100644
index 0000000000..bc67d57a31
--- /dev/null
+++ b/common/mock/dp_alt_mode_mock.c
@@ -0,0 +1,37 @@
+/* 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 for DisplayPort alternate mode support
+ * Refer to VESA DisplayPort Alt Mode on USB Type-C Standard, version 2.0,
+ * section 5.2
+ */
+
+#include "usb_dp_alt_mode.h"
+#include "mock/dp_alt_mode_mock.h"
+
+#ifdef CONFIG_COMMON_RUNTIME
+#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args)
+#else
+#define CPRINTF(format, args...)
+#define CPRINTS(format, args...)
+#endif
+
+void mock_dp_alt_mode_reset(void)
+{
+ /* Nothing to do right now, but in the future ... */
+}
+
+void dp_init(int port)
+{
+ CPRINTS("C%d: DP init", port);
+}
+
+void dp_teardown(int port)
+{
+ CPRINTS("C%d: DP teardown", port);
+}
+