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