blob: 3eac2ca5e9b866b9ad98c5edd4f78b33844d6ac9 [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"
"go.chromium.org/tast-tests/cros/common/servo"
"go.chromium.org/tast/core/testing"
"go.chromium.org/tast/core/testing/hwdep"
)
func init() {
testing.AddTest(&testing.Test{
Func: CodelabServoLocal,
Desc: "Demonstrates using servo package in local tests",
Contacts: []string{
"me@chromium.org", // Test author
"my-team@chromium.org", // Backup mailing list
},
Attr: []string{"group:mainline", "informational"},
HardwareDeps: hwdep.D(hwdep.ChromeEC()),
Vars: []string{"servo"},
})
}
// CodelabServoLocal demonstrates finding out DUT ECBoard via Servo.
func CodelabServoLocal(ctx context.Context, s *testing.State) {
// Set up Servo in local tests
servoSpec, _ := s.Var("servo")
srvo, err := servo.NewDirect(ctx, servoSpec)
if err != nil {
s.Fatal("Failed to connect to servo: ", err)
}
defer srvo.Close(ctx)
// srvo is the Servo object that we created earlier through NewDirect constructor.
ecBoard, err := srvo.GetString(ctx, servo.ECBoard)
if err != nil {
s.Fatal("Getting ec_board control from servo: ", err)
}
s.Log("EC Board: ", ecBoard)
}