aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/host/machine_info_linux_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-10-26 10:51:06 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-10-26 15:44:28 +0100
commite6e35dba937599d098fc034eff2686e5ddc409e9 (patch)
tree802be708d0bc84dee01b9285639690a53f1f6f94 /pkg/host/machine_info_linux_test.go
parentd46bc75207fea1d7671c1277dd660cf1a4d7847b (diff)
sys/targets: add OS/Arch name consts
We use strings to identify OS/Arch. These strings are duplicated throughout the code base massively. golangci-lint points to possiblity of typos and duplication. We already had to define these names in pkg/csource and disable checking for prog package. A future change triggers such warnings in another package. Add OS/Arch name consts to sys/targets so that they can be used to refer to OS/Arch. Use the consts everywhere.
Diffstat (limited to 'pkg/host/machine_info_linux_test.go')
-rw-r--r--pkg/host/machine_info_linux_test.go28
1 files changed, 15 insertions, 13 deletions
diff --git a/pkg/host/machine_info_linux_test.go b/pkg/host/machine_info_linux_test.go
index f09666659..5075751d5 100644
--- a/pkg/host/machine_info_linux_test.go
+++ b/pkg/host/machine_info_linux_test.go
@@ -10,6 +10,8 @@ import (
"runtime"
"strings"
"testing"
+
+ "github.com/google/syzkaller/sys/targets"
)
func TestReadCPUInfoLinux(t *testing.T) {
@@ -42,14 +44,14 @@ func checkCPUInfo(t *testing.T, data []byte, arch string) {
keys[key] = true
}
importantKeys := map[string][]string{
- "ppc64le": {"cpu", "revision", "platform", "model", "machine"},
- "amd64": {"vendor_id", "model", "flags"},
- "s390x": {"vendor_id", "processor 0", "features"},
- "386": {"vendor_id", "model", "flags"},
- "arm64": {"CPU implementer", "CPU part", "Features"},
- "arm": {"CPU implementer", "CPU part", "Features"},
- "mips64le": {"system type", "cpu model", "ASEs implemented"},
- "riscv64": {"processor", "isa", "mmu"},
+ targets.PPC64LE: {"cpu", "revision", "platform", "model", "machine"},
+ targets.AMD64: {"vendor_id", "model", "flags"},
+ targets.S390x: {"vendor_id", "processor 0", "features"},
+ targets.I386: {"vendor_id", "model", "flags"},
+ targets.ARM64: {"CPU implementer", "CPU part", "Features"},
+ targets.ARM: {"CPU implementer", "CPU part", "Features"},
+ targets.MIPS64LE: {"system type", "cpu model", "ASEs implemented"},
+ targets.RiscV64: {"processor", "isa", "mmu"},
}
archKeys := importantKeys[arch]
if len(archKeys) == 0 {
@@ -149,7 +151,7 @@ type cannedTest struct {
// nolint:lll
var cpuInfoTests = []cannedTest{
{
- arch: "ppc64le",
+ arch: targets.PPC64LE,
data: `
processor : 0
cpu : POWER8 (architected), altivec supported
@@ -179,7 +181,7 @@ MMU : Hash
`,
},
{
- arch: "ppc64le",
+ arch: targets.PPC64LE,
data: `
processor : 0
cpu : POWER8 (architected), altivec supported
@@ -201,7 +203,7 @@ MMU : Hash
`,
},
{
- arch: "ppc64le",
+ arch: targets.PPC64LE,
data: `
processor : 0
cpu : POWER8E, altivec supported
@@ -242,7 +244,7 @@ MMU : Hash
`,
},
{
- arch: "amd64",
+ arch: targets.AMD64,
data: `
processor : 0
vendor_id : GenuineIntel
@@ -302,7 +304,7 @@ power management:
`,
},
{
- arch: "amd64",
+ arch: targets.AMD64,
data: `
processor : 0
vendor_id : GenuineIntel