summaryrefslogtreecommitdiff
path: root/test/usb_prl.c
diff options
context:
space:
mode:
authorPaul Fagerburg <pfagerburg@google.com>2020-06-18 16:32:30 -0600
committerCommit Bot <commit-bot@chromium.org>2020-06-23 02:29:14 +0000
commit01705adbfa51d14e986c76605c995b9ec2d42170 (patch)
tree3d5d7f12010d90f8f1d42222bad7ef749f2100bc /test/usb_prl.c
parentae40ebba225fefeb802db2bdce843080eecae081 (diff)
downloadchrome-ec-01705adbfa51d14e986c76605c995b9ec2d42170.tar.gz
usb_prl: new unit test with mocks
Now that the old usb_prl unit test is under usb_prl_old, add a new unit test for usb_prl with mocks for the various subsystems that it will use. BUG=b:158608129 BRANCH=None TEST=`TEST_LIST_HOST="usb_prl_old usb_prl" make runhosttests` Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: Ie1bf9a4494cd933473caa4ceb594eddd97c277c7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2252662 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
Diffstat (limited to 'test/usb_prl.c')
-rw-r--r--test/usb_prl.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/usb_prl.c b/test/usb_prl.c
new file mode 100644
index 0000000000..702aa8ec64
--- /dev/null
+++ b/test/usb_prl.c
@@ -0,0 +1,46 @@
+/* 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.
+ *
+ * Test USB Protocol Layer module.
+ */
+#include "common.h"
+#include "task.h"
+#include "tcpm.h"
+#include "test_util.h"
+#include "timer.h"
+#include "usb_emsg.h"
+#include "usb_pd_test_util.h"
+#include "usb_pd.h"
+#include "usb_pe_sm.h"
+#include "usb_prl_sm.h"
+#include "usb_sm_checks.h"
+#include "usb_tc_sm.h"
+#include "util.h"
+#include "mock/tcpc_mock.h"
+
+#define PORT0 0
+
+/* Install Mock TCPC and MUX drivers */
+const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+ {
+ .drv = &mock_tcpc_driver,
+ },
+};
+
+void before_test(void)
+{
+}
+
+void run_test(int argc, char **argv)
+{
+ /* TODO add tests here */
+
+ /* Do basic state machine sanity checks last. */
+ RUN_TEST(test_prl_no_parent_cycles);
+ RUN_TEST(test_prl_no_empty_state);
+ RUN_TEST(test_prl_all_states_named);
+
+ test_print_result();
+}
+