| 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 |
runDebugOptionsTest(t, "TestSSE3DebugOption", "cpu.sse3=off") |
| 23 |
} |
| 24 |
|
| 25 |
func TestSSE3DebugOption(t *testing.T) { |
| 26 |
MustHaveDebugOptionsSupport(t) |
| 27 |
|
| 28 |
if godebug.Get("cpu.sse3") != "off" { |
| 29 |
t.Skipf("skipping test: GODEBUG=cpu.sse3=off not set") |
| 30 |
} |
| 31 |
|
| 32 |
want := false |
| 33 |
if got := X86.HasSSE3; got != want { |
| 34 |
t.Errorf("X86.HasSSE3 expected %v, got %v", want, got) |
| 35 |
} |
| 36 |
} |