summaryrefslogtreecommitdiff
path: root/test
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
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')
-rw-r--r--test/build.mk1
-rw-r--r--test/usb_tcpmv2_compliance.c1
-rw-r--r--test/usb_tcpmv2_compliance.h4
-rw-r--r--test/usb_tcpmv2_td_pd_src_e1.c47
4 files changed, 53 insertions, 0 deletions
diff --git a/test/build.mk b/test/build.mk
index fee765a5d0..d0f813adb2 100644
--- a/test/build.mk
+++ b/test/build.mk
@@ -220,6 +220,7 @@ usb_tcpmv2_compliance-y=usb_tcpmv2_compliance.o usb_tcpmv2_compliance_common.o \
usb_tcpmv2_td_pd_ll_e3.o \
usb_tcpmv2_td_pd_ll_e4.o \
usb_tcpmv2_td_pd_ll_e5.o \
+ usb_tcpmv2_td_pd_src_e1.o \
usb_tcpmv2_td_pd_src3_e26.o \
usb_tcpmv2_td_pd_snk3_e12.o \
usb_tcpmv2_td_pd_other.o
diff --git a/test/usb_tcpmv2_compliance.c b/test/usb_tcpmv2_compliance.c
index c031860c5a..f2e8924638 100644
--- a/test/usb_tcpmv2_compliance.c
+++ b/test/usb_tcpmv2_compliance.c
@@ -33,6 +33,7 @@ void run_test(int argc, char **argv)
RUN_TEST(test_td_pd_ll_e4_ufp);
RUN_TEST(test_td_pd_ll_e5_dfp);
RUN_TEST(test_td_pd_ll_e5_ufp);
+ RUN_TEST(test_td_pd_src_e1);
RUN_TEST(test_td_pd_src3_e26);
RUN_TEST(test_td_pd_snk3_e12);
diff --git a/test/usb_tcpmv2_compliance.h b/test/usb_tcpmv2_compliance.h
index 20a3c1ed66..4b57ebb11d 100644
--- a/test/usb_tcpmv2_compliance.h
+++ b/test/usb_tcpmv2_compliance.h
@@ -78,7 +78,11 @@ int test_td_pd_ll_e4_dfp(void);
int test_td_pd_ll_e4_ufp(void);
int test_td_pd_ll_e5_dfp(void);
int test_td_pd_ll_e5_ufp(void);
+
+int test_td_pd_src_e1(void);
+
int test_td_pd_src3_e26(void);
+
int test_td_pd_snk3_e12(void);
int test_connect_as_nonpd_sink(void);
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;
+}