From cbc33018b3aa70a741565cc8066e4f0690e6409d Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Mon, 16 Oct 2017 16:23:36 +0800 Subject: [PATCH] ctr: Add a test file to test cpu getCpuVariant Change-Id: Id9558de2e41b08c41cf7d4b458774e99e24515a0 Signed-off-by: Wei Chen Signed-off-by: Penny Zheng --- platforms/cpuinfo_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 platforms/cpuinfo_test.go diff --git a/platforms/cpuinfo_test.go b/platforms/cpuinfo_test.go new file mode 100644 index 000000000..95911efe0 --- /dev/null +++ b/platforms/cpuinfo_test.go @@ -0,0 +1,24 @@ +package platforms + +import ( + "runtime" + "testing" +) + +func TestCPUVariant(t *testing.T) { + if !isArmArch(runtime.GOARCH) || !isLinuxOS(runtime.GOOS) { + t.Skip("only relevant on linux/arm") + } + + variants := []string{"v8", "v7", "v6", "v5", "v4", "v3"} + + p := getCPUVariant() + for _, variant := range variants { + if p == variant { + t.Logf("got valid variant as expected: %#v = %#v\n", p, variant) + return + } + } + + t.Fatalf("could not get valid variant as expected: %v\n", variants) +}