summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Massey <aaronmassey@google.com>2022-09-13 17:25:36 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-14 21:22:43 +0000
commit24a1cee59942b595f459d69c2aa2f97d37b268df (patch)
tree3e076fd651de3dfd8f9828eabde3126b0e2b911f
parent552e01998d8808c9fde69ccf8376084bb7244c4b (diff)
downloadchrome-ec-stabilize-15117.48.B-main.tar.gz
Verify that the EC can still determine if the AP is bootable on a low battery capacity while there is a charger connected. Also verify that the EC thinks it can't boot when it's on low battery without a charger connected. BRANCH=none BUG=b:246335162 TEST=twister --coverage --clobber -i -s zephyr/test/drivers/drivers.default Signed-off-by: Aaron Massey <aaronmassey@google.com> Change-Id: I02be9616fe3bee9fedd716f46ccb862b2f1ef0e3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3892500 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c
index 49716e55c3..4d89e8c0d3 100644
--- a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c
+++ b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c
@@ -9,6 +9,7 @@
#include "emul/emul_isl923x.h"
#include "emul/emul_smart_battery.h"
#include "emul/tcpc/emul_tcpci_partner_src.h"
+#include "system.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
#include "usb_pd.h"
@@ -205,3 +206,43 @@ ZTEST_F(usb_attach_5v_3a_pd_source, test_disconnect_power_info)
"Expected the PD current limit to be >= 0, but got %dmA",
power_info.meas.current_lim);
}
+
+ZTEST(usb_attach_5v_3a_pd_source,
+ test_ap_can_boot_on_low_battery_while_charging)
+{
+ const struct emul *smart_batt_emul = EMUL_DT_GET(DT_NODELABEL(battery));
+ struct sbat_emul_bat_data *batt_data =
+ sbat_emul_get_bat_data(smart_batt_emul);
+
+ /* Set capacity to what gives a charge percentage less than required
+ * for booting the AP
+ *
+ * Capacaity is reset by emulator's ZTEST_RULE
+ */
+ batt_data->cap = (CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON *
+ batt_data->design_cap / 100) -
+ 1;
+
+ zassert_true(system_can_boot_ap(), NULL);
+}
+
+ZTEST_F(usb_attach_5v_3a_pd_source,
+ test_ap_fails_to_boot_on_low_battery_while_not_charging)
+{
+ const struct emul *smart_batt_emul = EMUL_DT_GET(DT_NODELABEL(battery));
+ struct sbat_emul_bat_data *batt_data =
+ sbat_emul_get_bat_data(smart_batt_emul);
+
+ /* Set capacity to what gives a charge percentage less than required
+ * for booting the AP
+ *
+ * Capacaity is reset by emulator's ZTEST_RULE
+ */
+ batt_data->cap = (CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON *
+ batt_data->design_cap / 100) -
+ 1;
+
+ disconnect_source_from_port(fixture->tcpci_emul, fixture->charger_emul);
+
+ zassert_false(system_can_boot_ap(), NULL);
+}