github.com/hikaru7719/go@v0.0.0-20181025140707-c8b2ac68906a/src/internal/cpu/cpu_x86_test.go (about) 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 // +build 386 amd64 amd64p32 6 7 package cpu_test 8 9 import ( 10 . "internal/cpu" 11 "os" 12 "runtime" 13 "testing" 14 ) 15 16 func TestAMD64minimalFeatures(t *testing.T) { 17 if runtime.GOARCH != "amd64" { 18 return 19 } 20 21 if !X86.HasSSE2 { 22 t.Fatalf("HasSSE2 expected true, got false") 23 } 24 } 25 26 func TestX86ifAVX2hasAVX(t *testing.T) { 27 if X86.HasAVX2 && !X86.HasAVX { 28 t.Fatalf("HasAVX expected true when HasAVX2 is true, got false") 29 } 30 } 31 32 func TestDisableSSE2(t *testing.T) { 33 runDebugOptionsTest(t, "TestSSE2DebugOption", "sse2=off") 34 } 35 36 func TestSSE2DebugOption(t *testing.T) { 37 MustHaveDebugOptionsSupport(t) 38 39 if os.Getenv("GODEBUGCPU") != "sse2=off" { 40 t.Skipf("skipping test: GODEBUGCPU=sse2=off not set") 41 } 42 43 want := runtime.GOARCH != "386" // SSE2 can only be disabled on 386. 44 if got := X86.HasSSE2; got != want { 45 t.Errorf("X86.HasSSE2 on %s expected %v, got %v", runtime.GOARCH, want, got) 46 } 47 } 48 49 func TestDisableSSE3(t *testing.T) { 50 runDebugOptionsTest(t, "TestSSE3DebugOption", "sse3=off") 51 } 52 53 func TestSSE3DebugOption(t *testing.T) { 54 MustHaveDebugOptionsSupport(t) 55 56 if os.Getenv("GODEBUGCPU") != "sse3=off" { 57 t.Skipf("skipping test: GODEBUGCPU=sse3=off not set") 58 } 59 60 want := false 61 if got := X86.HasSSE3; got != want { 62 t.Errorf("X86.HasSSE3 expected %v, got %v", want, got) 63 } 64 }