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 TestAVX512HasAVX2AndAVX(t *testing.T) {
34 if runtime.GOARCH == "amd64" {
35 if cpu.X86.HasAVX512 && !cpu.X86.HasAVX {
36 t.Fatal("HasAVX expected true, got false")
38 if cpu.X86.HasAVX512 && !cpu.X86.HasAVX2 {
39 t.Fatal("HasAVX2 expected true, got false")
44 func TestARM64minimalFeatures(t *testing.T) {
45 if runtime.GOARCH != "arm64" || (runtime.GOOS == "darwin" || runtime.GOOS == "ios") {
48 if !cpu.ARM64.HasASIMD {
49 t.Fatal("HasASIMD expected true, got false")
52 t.Fatal("HasFP expected true, got false")
56 func TestMIPS64Initialized(t *testing.T) {
57 if runtime.GOARCH == "mips64" || runtime.GOARCH == "mips64le" {
59 t.Fatal("Initialized expected true, got false")
64 // On ppc64x, the ISA bit for POWER8 should always be set on POWER8 and beyond.
65 func TestPPC64minimalFeatures(t *testing.T) {
66 // Do not run this with gccgo on ppc64, as it doesn't have POWER8 as a minimum
68 if runtime.Compiler == "gccgo" && runtime.GOARCH == "ppc64" {
69 t.Skip("gccgo does not require POWER8 on ppc64; skipping")
71 if runtime.GOARCH == "ppc64" || runtime.GOARCH == "ppc64le" {
72 if !cpu.PPC64.IsPOWER8 {
73 t.Fatal("IsPOWER8 expected true, got false")