blob: 014b24d829a9305f9fdb04c36da6a3bd918db3c3 [file] [log] [blame]
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package firmware
import (
"context"
"github.com/golang/protobuf/ptypes/empty"
fwCommon "go.chromium.org/tast-tests/cros/common/firmware"
"go.chromium.org/tast-tests/cros/remote/firmware/fixture"
"go.chromium.org/tast-tests/cros/common/servo"
"go.chromium.org/tast-tests/cros/common/tbdep"
"go.chromium.org/tast/core/testing"
"go.chromium.org/tast/core/testing/hwdep"
)
func init() {
testing.AddTest(&testing.Test{
Func: CodelabFixt,
Desc: "Demonstrates common functionality for remote firmware tests",
Contacts: []string{
"chromeos-faft@google.com", // Owning team list
"me@chromium.org", // Test author
},
BugComponent: "b:792402", // ChromeOS > Platform > Enablement > Firmware > FAFT
// TODO(b/427195218): Add servo-exists + servo_state:WORKING after bug resolved.
TestBedDeps: []string{tbdep.ServoPresent},
// TODO: When stable, change firmware_unstable to a different attr.
Attr: []string{"group:firmware", "firmware_unstable"},
HardwareDeps: hwdep.D(hwdep.ChromeEC()),
Fixture: fixture.NormalMode,
ServiceDeps: []string{"tast.cros.firmware.BiosService"},
})
}
// CodelabFixt demonstrates using a fixture to ensure that the DUT is in an expected state at the start and end of a test.
func CodelabFixt(ctx context.Context, s *testing.State) {
h := s.FixtValue().(*fixture.Value).Helper
r := h.Reporter
board, err := r.Board(ctx)
if err != nil {
s.Fatal("Failed to report board: ", err)
}
model, err := r.Model(ctx)
if err != nil {
s.Fatal("Failed to report model: ", err)
}
s.Logf("Reported board=%s, model=%s", board, model)
if err := h.RequireConfig(ctx); err != nil {
s.Fatal("Failed to create config: ", err)
}
s.Log("This DUT's mode-switcher type is: ", h.Config.ModeSwitcherType)
// Get the DUT's ec_board via Servo
if err := h.RequireServo(ctx); err != nil {
s.Fatal("Failed to connect to servo: ", err)
}
ecBoard, err := h.Servo.GetString(ctx, servo.ECBoard)
if err != nil {
s.Fatal("Getting ec_board control from servo: ", err)
}
s.Log("EC Board: ", ecBoard)
// Get current GBB flags via RPC
if err := h.RequireBiosServiceClient(ctx); err != nil {
s.Fatal("Failed to connect to RPC service on the DUT: ", err)
}
flags, err := h.BiosServiceClient.GetGBBFlags(ctx, &empty.Empty{})
if err != nil {
s.Fatal("Failed to get GBB flags: ", err)
}
s.Log("Clear GBB flags: ", flags.Clear)
s.Log("Set GBB flags: ", flags.Set)
// Switch to recovery mode
ms, err := firmware.NewModeSwitcher(ctx, h)
if err != nil {
s.Fatal("Failed to create mode-switcher: ", err)
}
if err := ms.RebootToMode(ctx, fwCommon.BootModeRecovery); err != nil {
s.Fatal("Failed to boot to recovery mode: ", err)
}
}