summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2021-10-15 12:17:45 -0600
committerCommit Bot <commit-bot@chromium.org>2021-10-18 16:44:15 +0000
commitb9b62ce4677a08dd847f7f3d62b09dcf7dae09a8 (patch)
tree0244d162f2342f3832d9b30dff18ea69738cc266
parent5afc756fc190224e533ed90c4e3cf574fad6af33 (diff)
downloadchrome-ec-b9b62ce4677a08dd847f7f3d62b09dcf7dae09a8.tar.gz
zephyr test: ppc: Add sleep TODOs
This test currently sleeps to give the driver time to handle interrupts. The test should instead schedule the driver immediately and simulate the passage of time to the driver. Add TODOs to track sleeps that should be replaced. BUG=b:201420132 TEST=zmake configure --test zephyr/test/drivers BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I179dcdd92c04e543a2f2ec0da6ec70bd4aa36ccb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3227260 Reviewed-by: Yuval Peress <peress@google.com>
-rw-r--r--zephyr/test/drivers/src/ppc.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/zephyr/test/drivers/src/ppc.c b/zephyr/test/drivers/src/ppc.c
index 82b0aeb6c9..d8d5550f56 100644
--- a/zephyr/test/drivers/src/ppc.c
+++ b/zephyr/test/drivers/src/ppc.c
@@ -48,11 +48,13 @@ static void test_ppc_syv682x_interrupt(void)
/* An OC event less than 100 ms should not cause VBUS to turn off. */
syv682x_emul_set_status(emul, SYV682X_STATUS_OC_5V);
syv682x_interrupt(syv682x_port);
+ /* TODO(b/201420132): Simulate passage of time instead of sleeping. */
msleep(50);
syv682x_interrupt(syv682x_port);
zassert_true(ppc_is_sourcing_vbus(syv682x_port),
"PPC is not sourcing VBUS after 50 ms OC");
/* But one greater than 100 ms should. */
+ /* TODO(b/201420132): Simulate passage of time instead of sleeping. */
msleep(60);
syv682x_interrupt(syv682x_port);
zassert_false(ppc_is_sourcing_vbus(syv682x_port),
@@ -76,6 +78,7 @@ static void test_ppc_syv682x_interrupt(void)
"Source enable failed");
syv682x_emul_set_status(emul, SYV682X_STATUS_TSD);
syv682x_interrupt(syv682x_port);
+ /* TODO(b/201420132): Simulate passage of time instead of sleeping. */
msleep(1);
zassert_false(ppc_is_sourcing_vbus(syv682x_port),
"PPC is sourcing power after TSD");
@@ -86,6 +89,7 @@ static void test_ppc_syv682x_interrupt(void)
"Source enable failed");
syv682x_emul_set_status(emul, SYV682X_STATUS_OVP);
syv682x_interrupt(syv682x_port);
+ /* TODO(b/201420132): Simulate passage of time instead of sleeping. */
msleep(1);
zassert_false(ppc_is_sourcing_vbus(syv682x_port),
"PPC is sourcing power after OVP");
@@ -100,6 +104,7 @@ static void test_ppc_syv682x_interrupt(void)
"Sink enable failed");
syv682x_emul_set_status(emul, SYV682X_STATUS_OC_HV);
syv682x_interrupt(syv682x_port);
+ /* TODO(b/201420132): Simulate passage of time instead of sleeping. */
msleep(1);
zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_1_REG, &reg),
"Reading CONTROL_1 failed");
@@ -107,6 +112,7 @@ static void test_ppc_syv682x_interrupt(void)
"Power path disabled after HV_OC handled");
syv682x_emul_set_status(emul, SYV682X_STATUS_OC_HV);
syv682x_interrupt(syv682x_port);
+ /* TODO(b/201420132): Simulate passage of time instead of sleeping. */
msleep(1);
zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_1_REG, &reg),
"Reading CONTROL_1 failed");
@@ -114,6 +120,7 @@ static void test_ppc_syv682x_interrupt(void)
"Power path disabled after HV_OC handled");
syv682x_emul_set_status(emul, SYV682X_STATUS_OC_HV);
syv682x_interrupt(syv682x_port);
+ /* TODO(b/201420132): Simulate passage of time instead of sleeping. */
msleep(1);
zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_1_REG, &reg),
"Reading CONTROL_1 failed");
@@ -129,14 +136,17 @@ static void test_ppc_syv682x_interrupt(void)
ppc_set_vconn(syv682x_port, true);
syv682x_emul_set_control_4(emul, SYV682X_CONTROL_4_VCONN_OCP);
syv682x_interrupt(syv682x_port);
+ /* TODO(b/201420132): Simulate passage of time instead of sleeping. */
msleep(1);
zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_4_REG, &reg),
"Reading CONTROL_4 failed");
zassert_true(reg &
(SYV682X_CONTROL_4_VCONN1 | SYV682X_CONTROL_4_VCONN2),
"VCONN disabled after initial VCONN OC");
+ /* TODO(b/201420132): Simulate passage of time instead of sleeping. */
msleep(50);
syv682x_interrupt(syv682x_port);
+ /* TODO(b/201420132): Simulate passage of time instead of sleeping. */
msleep(1);
zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_4_REG, &reg),
"Reading CONTROL_4 failed");
@@ -147,8 +157,10 @@ static void test_ppc_syv682x_interrupt(void)
* But if the event keeps going for over 100 ms continuously, the driver
* should turn VCONN off.
*/
+ /* TODO(b/201420132): Simulate passage of time instead of sleeping. */
msleep(60);
syv682x_interrupt(syv682x_port);
+ /* TODO(b/201420132): Simulate passage of time instead of sleeping. */
msleep(1);
zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_4_REG, &reg),
"Reading CONTROL_4 failed");