github.com/JimmyHuang454/JLS-go@v0.0.0-20230831150107-90d536585ba0/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 //go:build 386 || amd64 6 7 package cpu_test 8 9 import ( 10 . "internal/cpu" 11 "internal/godebug" 12 "testing" 13 ) 14 15 func TestX86ifAVX2hasAVX(t *testing.T) { 16 if X86.HasAVX2 && !X86.HasAVX { 17 t.Fatalf("HasAVX expected true when HasAVX2 is true, got false") 18 } 19 } 20 21 func TestDisableSSE3(t *testing.T) { 22 if GetGOAMD64level() > 1 { 23 t.Skip("skipping test: can't run on GOAMD64>v1 machines") 24 } 25 runDebugOptionsTest(t, "TestSSE3DebugOption", "cpu.sse3=off") 26 } 27 28 func TestSSE3DebugOption(t *testing.T) { 29 MustHaveDebugOptionsSupport(t) 30 31 if godebug.New("cpu.sse3").Value() != "off" { 32 t.Skipf("skipping test: GODEBUG=cpu.sse3=off not set") 33 } 34 35 want := false 36 if got := X86.HasSSE3; got != want { 37 t.Errorf("X86.HasSSE3 expected %v, got %v", want, got) 38 } 39 }