1// Copyright 2017 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
5package cpu_test
6
7import (
8	"internal/cpu"
9	"runtime"
10	"testing"
11)
12
13func TestAMD64minimalFeatures(t *testing.T) {
14	if runtime.GOARCH == "amd64" {
15		if !cpu.X86.HasSSE2 {
16			t.Fatalf("HasSSE2 expected true, got false")
17		}
18	}
19}
20
21func TestAVX2hasAVX(t *testing.T) {
22	if runtime.GOARCH == "amd64" {
23		if cpu.X86.HasAVX2 && !cpu.X86.HasAVX {
24			t.Fatalf("HasAVX expected true, got false")
25		}
26	}
27}
28
29func TestPPC64minimalFeatures(t *testing.T) {
30	if runtime.GOARCH == "ppc64" || runtime.GOARCH == "ppc64le" {
31		if !cpu.PPC64.IsPOWER8 {
32			t.Fatalf("IsPOWER8 expected true, got false")
33		}
34		if !cpu.PPC64.HasVMX {
35			t.Fatalf("HasVMX expected true, got false")
36		}
37		if !cpu.PPC64.HasDFP {
38			t.Fatalf("HasDFP expected true, got false")
39		}
40		if !cpu.PPC64.HasVSX {
41			t.Fatalf("HasVSX expected true, got false")
42		}
43		if !cpu.PPC64.HasISEL {
44			t.Fatalf("HasISEL expected true, got false")
45		}
46		if !cpu.PPC64.HasVCRYPTO {
47			t.Fatalf("HasVCRYPTO expected true, got false")
48		}
49	}
50}
51