update packaging
[platform/core/system/edge-orchestration.git] / vendor / golang.org / x / sys / cpu / cpu_test.go
1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package cpu_test
6
7 import (
8         "runtime"
9         "testing"
10
11         "golang.org/x/sys/cpu"
12 )
13
14 func TestAMD64minimalFeatures(t *testing.T) {
15         if runtime.GOARCH == "amd64" {
16                 if !cpu.Initialized {
17                         t.Fatal("Initialized expected true, got false")
18                 }
19                 if !cpu.X86.HasSSE2 {
20                         t.Fatal("HasSSE2 expected true, got false")
21                 }
22         }
23 }
24
25 func TestAVX2hasAVX(t *testing.T) {
26         if runtime.GOARCH == "amd64" {
27                 if cpu.X86.HasAVX2 && !cpu.X86.HasAVX {
28                         t.Fatal("HasAVX expected true, got false")
29                 }
30         }
31 }
32
33 func TestARM64minimalFeatures(t *testing.T) {
34         if runtime.GOARCH != "arm64" || runtime.GOOS != "linux" {
35                 return
36         }
37         if !cpu.ARM64.HasASIMD {
38                 t.Fatal("HasASIMD expected true, got false")
39         }
40         if !cpu.ARM64.HasFP {
41                 t.Fatal("HasFP expected true, got false")
42         }
43 }
44
45 // On ppc64x, the ISA bit for POWER8 should always be set on POWER8 and beyond.
46 func TestPPC64minimalFeatures(t *testing.T) {
47         // Do not run this with gccgo on ppc64, as it doesn't have POWER8 as a minimum
48         // requirement.
49         if runtime.Compiler == "gccgo" && runtime.GOARCH == "ppc64" {
50                 t.Skip("gccgo does not require POWER8 on ppc64; skipping")
51         }
52         if runtime.GOARCH == "ppc64" || runtime.GOARCH == "ppc64le" {
53                 if !cpu.PPC64.IsPOWER8 {
54                         t.Fatal("IsPOWER8 expected true, got false")
55                 }
56         }
57 }
58
59 func TestS390X(t *testing.T) {
60         if runtime.GOARCH != "s390x" {
61                 return
62         }
63         if testing.Verbose() {
64                 t.Logf("%+v\n", cpu.S390X)
65         }
66         // z/Architecture is mandatory
67         if !cpu.S390X.HasZARCH {
68                 t.Error("HasZARCH expected true, got false")
69         }
70         // vector-enhancements require vector facility to be enabled
71         if cpu.S390X.HasVXE && !cpu.S390X.HasVX {
72                 t.Error("HasVX expected true, got false (VXE is true)")
73         }
74 }