Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cpuinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,14 @@ func parseCPUInfoARM(info []byte) ([]CPUInfo, error) {
featuresLine = line
case "model name":
cpuinfo[i].ModelName = field[1]
case "CPU implementer":
cpuinfo[i].VendorID = field[1]
case "CPU variant":
cpuinfo[i].CPUFamily = field[1]
case "CPU part":
cpuinfo[i].Model = field[1]
case "CPU revision":
cpuinfo[i].Stepping = field[1]
}
}
fields := strings.SplitN(featuresLine, ": ", 2)
Expand Down
44 changes: 44 additions & 0 deletions cpuinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,3 +478,47 @@ func TestCPUInfoParseLoong64(t *testing.T) {
t.Errorf("want CPUFamily '%v', have '%v'", want, have)
}
}

const cpuinfoArm64Identity = `processor : 0
BogoMIPS : 100.00
Features : fp asimd aes sha1 sha2 crc32
CPU implementer : 0x41
CPU variant : 0x1
CPU part : 0xd40
CPU revision : 0

processor : 1
BogoMIPS : 100.00
Features : fp asimd aes sha1 sha2 crc32
CPU implementer : 0x41
CPU variant : 0x1
CPU part : 0xd40
CPU revision : 0
`

func TestParseCPUInfoARM64IdentityFields(t *testing.T) {
parsed, err := parseCPUInfoARM([]byte(cpuinfoArm64Identity))
if err != nil {
t.Fatalf("parseCPUInfoARM returned an error: %v", err)
}
if len(parsed) != 2 {
t.Fatalf("expected 2 CPUs, got %d", len(parsed))
}
for i, cpu := range parsed {
// arm64 kernels have no "model name" line; the implementer/variant/
// part/revision fields are the only CPU identity available and must
// not be dropped by the parser.
if cpu.VendorID != "0x41" {
t.Errorf("cpu %d: VendorID = %q, want %q", i, cpu.VendorID, "0x41")
}
if cpu.CPUFamily != "0x1" {
t.Errorf("cpu %d: CPUFamily = %q, want %q", i, cpu.CPUFamily, "0x1")
}
if cpu.Model != "0xd40" {
t.Errorf("cpu %d: Model = %q, want %q", i, cpu.Model, "0xd40")
}
if cpu.Stepping != "0" {
t.Errorf("cpu %d: Stepping = %q, want %q", i, cpu.Stepping, "0")
}
}
}