summaryrefslogtreecommitdiff
path: root/test/usb_tcpmv2_td_pd_src_e1.c
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@google.com>2020-12-29 10:34:45 -0700
committerCommit Bot <commit-bot@chromium.org>2020-12-30 22:34:04 +0000
commitc7641168a60cae345bddc5566bd7bf7aedd4d1ed (patch)
tree3fad97e4d5a874d048876ffddcb4803afdca94b2 /test/usb_tcpmv2_td_pd_src_e1.c
parent1b6965649a91fdcd150dabdd306584ce469126ac (diff)
downloadchrome-ec-c7641168a60cae345bddc5566bd7bf7aedd4d1ed.tar.gz
TCPMv2: Compliance Unit Test - TD.PD.SRC.E1
BUG=none BRANCH=none TEST=make buildall Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I79ff608bdcbe754d109543e507674df8524b4f67 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2606566 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'test/usb_tcpmv2_td_pd_src_e1.c')
-rw-r--r--test/usb_tcpmv2_td_pd_src_e1.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/usb_tcpmv2_td_pd_src_e1.c b/test/usb_tcpmv2_td_pd_src_e1.c
new file mode 100644
index 0000000000..06ca702b79
--- /dev/null
+++ b/test/usb_tcpmv2_td_pd_src_e1.c
@@ -0,0 +1,47 @@
+/* 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.
+ */
+
+#include "mock/tcpci_i2c_mock.h"
+#include "task.h"
+#include "tcpci.h"
+#include "test_util.h"
+#include "timer.h"
+#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
+
+/*****************************************************************************
+ * TD.PD.SRC.E1 Source Capabilities sent timely
+ *
+ * Description:
+ * As Consumer (UFP), the Tester verifies a Source Capabilities message
+ * from the Provider (DFP, UUT) is received timely
+ */
+int test_td_pd_src_e1(void)
+{
+ partner_set_pd_rev(PD_REV20);
+
+ TEST_EQ(tcpci_startup(), EC_SUCCESS, "%d");
+
+ /*
+ * a) Run PROC.PD.E1 Bring-up according to the UUT role.
+ *
+ * NOTE: Calling PROC.PD.E1 with INITIAL_ATTACH will stop just before
+ * the PD_DATA_SOURCE_CAP is verified. We need to stop the process
+ * there to use the timeout verify.
+ */
+ TEST_EQ(proc_pd_e1(PD_ROLE_DFP, INITIAL_ATTACH), EC_SUCCESS, "%d");
+
+ /*
+ * b) The test fails if the first bit of a Source Capabilities message
+ * is not received from the Provider within 250 ms (tFirstSourceCap
+ * max) after VBus present.
+ */
+ TEST_EQ(verify_tcpci_tx_timeout(TCPC_TX_SOP, 0,
+ PD_DATA_SOURCE_CAP,
+ 250 * MSEC),
+ EC_SUCCESS, "%d");
+
+ return EC_SUCCESS;
+}