blob: 43d6b211ea4cf5a64f8008df10c659d6797f4031 [file] [log] [blame]
Martin Möhrmannf045ddc2018-01-26 12:14:27 +01001// 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
Russ Coxd4b26382021-02-19 18:35:10 -05005//go:build 386 || amd64
Martin Möhrmannf045ddc2018-01-26 12:14:27 +01006
7package cpu_test
8
9import (
10 . "internal/cpu"
Brad Fitzpatrick4633b2d2021-11-01 20:25:48 -070011 "internal/godebug"
Martin Möhrmannf045ddc2018-01-26 12:14:27 +010012 "testing"
13)
14
Martin Möhrmannf045ddc2018-01-26 12:14:27 +010015func 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
Martin Möhrmann3e0227f2018-10-12 19:17:21 +020021func TestDisableSSE3(t *testing.T) {
Keith Randall9b112ce2022-03-15 08:56:07 -070022 if GetGOAMD64level() > 1 {
23 t.Skip("skipping test: can't run on GOAMD64>v1 machines")
24 }
Martin Möhrmann2de53902018-11-14 20:48:40 +010025 runDebugOptionsTest(t, "TestSSE3DebugOption", "cpu.sse3=off")
Martin Möhrmann3e0227f2018-10-12 19:17:21 +020026}
27
28func TestSSE3DebugOption(t *testing.T) {
29 MustHaveDebugOptionsSupport(t)
30
Brad Fitzpatrick4633b2d2021-11-01 20:25:48 -070031 if godebug.Get("cpu.sse3") != "off" {
Martin Möhrmann2de53902018-11-14 20:48:40 +010032 t.Skipf("skipping test: GODEBUG=cpu.sse3=off not set")
Martin Möhrmann3e0227f2018-10-12 19:17:21 +020033 }
34
35 want := false
36 if got := X86.HasSSE3; got != want {
37 t.Errorf("X86.HasSSE3 expected %v, got %v", want, got)
38 }
39}