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.
11 "golang.org/x/sys/cpu"
14 func TestAMD64minimalFeatures(t *testing.T) {
15 if runtime.GOARCH == "amd64" {
17 t.Fatal("Initialized expected true, got false")
20 t.Fatal("HasSSE2 expected true, got false")
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")
33 func TestARM64minimalFeatures(t *testing.T) {
34 if runtime.GOARCH != "arm64" || runtime.GOOS != "linux" {
37 if !cpu.ARM64.HasASIMD {
38 t.Fatal("HasASIMD expected true, got false")
41 t.Fatal("HasFP expected true, got false")
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
49 if runtime.Compiler == "gccgo" && runtime.GOARCH == "ppc64" {
50 t.Skip("gccgo does not require POWER8 on ppc64; skipping")
52 if runtime.GOARCH == "ppc64" || runtime.GOARCH == "ppc64le" {
53 if !cpu.PPC64.IsPOWER8 {
54 t.Fatal("IsPOWER8 expected true, got false")
59 func TestS390X(t *testing.T) {
60 if runtime.GOARCH != "s390x" {
63 if testing.Verbose() {
64 t.Logf("%+v\n", cpu.S390X)
66 // z/Architecture is mandatory
67 if !cpu.S390X.HasZARCH {
68 t.Error("HasZARCH expected true, got false")
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)")