Source file
src/internal/cpu/cpu_x86_test.go
1
2
3
4
5
6
7
8 package cpu_test
9
10 import (
11 . "internal/cpu"
12 "os"
13 "runtime"
14 "testing"
15 )
16
17 func TestX86ifAVX2hasAVX(t *testing.T) {
18 if X86.HasAVX2 && !X86.HasAVX {
19 t.Fatalf("HasAVX expected true when HasAVX2 is true, got false")
20 }
21 }
22
23 func TestDisableSSE2(t *testing.T) {
24 runDebugOptionsTest(t, "TestSSE2DebugOption", "cpu.sse2=off")
25 }
26
27 func TestSSE2DebugOption(t *testing.T) {
28 MustHaveDebugOptionsSupport(t)
29
30 if os.Getenv("GODEBUG") != "cpu.sse2=off" {
31 t.Skipf("skipping test: GODEBUG=cpu.sse2=off not set")
32 }
33
34 want := runtime.GOARCH != "386"
35 if got := X86.HasSSE2; got != want {
36 t.Errorf("X86.HasSSE2 on %s expected %v, got %v", runtime.GOARCH, want, got)
37 }
38 }
39
40 func TestDisableSSE3(t *testing.T) {
41 runDebugOptionsTest(t, "TestSSE3DebugOption", "cpu.sse3=off")
42 }
43
44 func TestSSE3DebugOption(t *testing.T) {
45 MustHaveDebugOptionsSupport(t)
46
47 if os.Getenv("GODEBUG") != "cpu.sse3=off" {
48 t.Skipf("skipping test: GODEBUG=cpu.sse3=off not set")
49 }
50
51 want := false
52 if got := X86.HasSSE3; got != want {
53 t.Errorf("X86.HasSSE3 expected %v, got %v", want, got)
54 }
55 }
56
View as plain text