summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2022-08-23 14:25:56 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-24 22:53:52 +0000
commitee818d01adc47f1c8572295d06f8a8057796d7cd (patch)
treec6407a875a1182d5039da64954a452d20548e426
parentdab33e54016034692eefbf1118ec0de657c8d559 (diff)
downloadchrome-ec-ee818d01adc47f1c8572295d06f8a8057796d7cd.tar.gz
Test: Add test hooks for PD_CONTROL
One of the PD_CONTROL sub-commands irreversibly blocks future commands from running on a system. For the purposes of unit test stability, create a test hook which can be used to clear this state. Otherwise, a test execution order dependency would be created. BRANCH=None BUG=b:243188273 TEST=./twister -T ./zephyr/test Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ic0aacec6717e4f54dcb7f11d55fa36505fe208a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3852562 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com>
-rw-r--r--common/usb_pd_host_cmd.c11
-rw-r--r--include/usb_pd.h9
2 files changed, 19 insertions, 1 deletions
diff --git a/common/usb_pd_host_cmd.c b/common/usb_pd_host_cmd.c
index 226b6639d3..851cc34d46 100644
--- a/common/usb_pd_host_cmd.c
+++ b/common/usb_pd_host_cmd.c
@@ -494,9 +494,18 @@ DECLARE_HOST_COMMAND(EC_CMD_GET_PD_PORT_CAPS, hc_get_pd_port_caps,
EC_VER_MASK(0));
#ifdef CONFIG_HOSTCMD_PD_CONTROL
+static int pd_control_disabled[CONFIG_USB_PD_PORT_MAX_COUNT];
+
+/* Only allow port re-enable in unit tests */
+#ifdef TEST_BUILD
+void pd_control_port_enable(int port)
+{
+ pd_control_disabled[port] = 0;
+}
+#endif /* TEST_BUILD */
+
static enum ec_status pd_control(struct host_cmd_handler_args *args)
{
- static int pd_control_disabled[CONFIG_USB_PD_PORT_MAX_COUNT];
const struct ec_params_pd_control *cmd = args->params;
int enable = 0;
diff --git a/include/usb_pd.h b/include/usb_pd.h
index ab7f94b572..3cae202d60 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -2604,6 +2604,15 @@ extern const uint32_t pd_snk_pdo[];
extern const int pd_snk_pdo_cnt;
/**
+ * TEST ONLY: Set PD_CONTROL command to enabled on this port
+ *
+ * @param port USB-C port number
+ */
+#ifdef TEST_BUILD
+void pd_control_port_enable(int port);
+#endif
+
+/**
* Request that a host event be sent to notify the AP of a PD power event.
*
* Note: per-port events should be retrieved through pd_get_events(), but this