[machine] Tolerate missing sysctl keys about CPU.
vendor in particular is missing on Apple M1s.
Change-Id: Ie08c0c12834f7583f620bd5e5030de56ef556660
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/559161
Commit-Queue: Erik Rose <erikrose@google.com>
Reviewed-by: Eric Boren <borenet@google.com>
diff --git a/machine/go/test_machine_monitor/standalone/standalone_darwin.go b/machine/go/test_machine_monitor/standalone/standalone_darwin.go
index bbd23b9..f17a27b 100644
--- a/machine/go/test_machine_monitor/standalone/standalone_darwin.go
+++ b/machine/go/test_machine_monitor/standalone/standalone_darwin.go
@@ -30,14 +30,8 @@
if err != nil {
return nil, skerr.Wrapf(err, "failed to get Mac CPU architecture")
}
- vendor, err := unix.Sysctl("machdep.cpu.vendor")
- if err != nil {
- return nil, skerr.Wrap(err)
- }
- brandString, err := unix.Sysctl("machdep.cpu.brand_string")
- if err != nil {
- return nil, skerr.Wrap(err)
- }
-
+ // It is perfectly normal for these sysctl keys to be missing sometimes:
+ vendor, _ := unix.Sysctl("machdep.cpu.vendor") // Sysctl returns "" on failure.
+ brandString, _ := unix.Sysctl("machdep.cpu.brand_string")
return cpusCore(arch, vendor, brandString)
}
diff --git a/machine/go/test_machine_monitor/standalone/standalone_test.go b/machine/go/test_machine_monitor/standalone/standalone_test.go
index fde5fd8..852ee1f 100644
--- a/machine/go/test_machine_monitor/standalone/standalone_test.go
+++ b/machine/go/test_machine_monitor/standalone/standalone_test.go
@@ -46,6 +46,22 @@
[]string{"arm64", "arm64-64"},
"aarch64 should be recognized as arm64 ISA, and an unrecognizable Intel brand string should result in no third element.",
)
+ assertCpuDimensions(
+ t,
+ "arm64",
+ "",
+ "",
+ []string{"arm64", "arm64-64"},
+ "Empty vendor and brand string should result in no third element.",
+ )
+ assertCpuDimensions(
+ t,
+ "arm64",
+ "",
+ "Wackadoo ALU",
+ []string{"arm64", "arm64-64", "arm64-64-Wackadoo_ALU"},
+ "Empty vendor and full brand string should result in smooshed brand string for third element.",
+ )
}
func TestCpusCore_UnrecognizedArch_ReturnsError(t *testing.T) {