cuj: Check for battery before ectool
Check for the existence of a battery first before executing any battery
related commands (e.g. ectool).
BUG=b:417325715
TEST=tast run <DUT> ui.MeetCUJ on Karma
Change-Id: Ica4d2cb7297b7f345316e2e337ed72770c66a3c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/tast-tests/+/6598206
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Vincent Chiang <vincentchiang@chromium.org>
Tast-Review: Vincent Chiang <vincentchiang@chromium.org>
Tested-by: Vincent Chiang <vincentchiang@chromium.org>
diff --git a/src/go.chromium.org/tast-tests/cros/local/chrome/cuj/fixture.go b/src/go.chromium.org/tast-tests/cros/local/chrome/cuj/fixture.go
index ed168a3..b852cfe 100644
--- a/src/go.chromium.org/tast-tests/cros/local/chrome/cuj/fixture.go
+++ b/src/go.chromium.org/tast-tests/cros/local/chrome/cuj/fixture.go
@@ -1347,13 +1347,14 @@
// chargeBatteryCapacity allows charging of the battery for 8 minutes if battery capacity
// is not higher than a pre-defined level (minimumBatteryCapacity+lowBatteryShutdownPercent).
func chargeBatteryCapacity(ctx context.Context, minimumBatteryCapacity float64, chargeBatteryTestPollOpt *testing.PollOptions) error {
- if err := setup.AllowBatteryCharging(ctx); err != nil {
- return err
- }
+ // Check if there is a battery first.
devPath, err := pm.SysfsBatteryPath(ctx)
if err != nil {
return err
}
+ if err := setup.AllowBatteryCharging(ctx); err != nil {
+ return err
+ }
lowBatteryShutdownPercent, err := pm.LowBatteryShutdownPercent(ctx)
if err != nil {
return err