blob: e9d323e476a0232570f165d39315841887dd259f [file] [edit]
// Copyright 2026 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package androidtools
import (
"strconv"
"testing"
"go.chromium.org/infra/cros/recovery/internal/env"
"go.chromium.org/infra/cros/recovery/tlw"
)
func TestMauiSerial(t *testing.T) {
t.Parallel()
tests := []struct {
name string
dut *tlw.Dut
want string
}{
{
name: "nil dut",
dut: nil,
want: "",
},
{
name: "no servo",
dut: &tlw.Dut{},
want: "",
},
{
name: "non-maui serial",
dut: &tlw.Dut{
Chromeos: &tlw.ChromeOS{
Servo: &tlw.ServoHost{
SerialNumber: "12345",
},
},
},
want: "",
},
{
name: "maui serial",
dut: &tlw.Dut{
Chromeos: &tlw.ChromeOS{
Servo: &tlw.ServoHost{
SerialNumber: "MAUIV1012345",
},
},
},
want: "MAUIV1012345",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if got := MauiSerial(tt.dut); got != tt.want {
t.Errorf("MauiSerial() = %v, want %v", got, tt.want)
}
})
}
}
func TestADBSerial(t *testing.T) {
t.Parallel()
tests := []struct {
name string
dut *tlw.Dut
want string
}{
{
name: "maui serial",
dut: &tlw.Dut{
Name: "my-dut",
Chromeos: &tlw.ChromeOS{
Servo: &tlw.ServoHost{
SerialNumber: "MAUIV1012345",
},
},
},
want: "MAUIV1012345",
},
{
name: "tcp serial",
dut: &tlw.Dut{
Name: "my-dut",
Chromeos: &tlw.ChromeOS{
Servo: &tlw.ServoHost{
SerialNumber: "12345",
},
},
},
want: "my-dut:" + strconv.Itoa(env.ADBPort()),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if got := ADBSerial(tt.dut); got != tt.want {
t.Errorf("ADBSerial() = %v, want %v", got, tt.want)
}
})
}
}