github.com/elijahmorg/goternal@v1.18.0/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  	"testing"
    11  
    12  	. "github.com/elijahmorg/goternal/cpu"
    13  	"github.com/elijahmorg/goternal/godebug"
    14  )
    15  
    16  func TestX86ifAVX2hasAVX(t *testing.T) {
    17  	if X86.HasAVX2 && !X86.HasAVX {
    18  		t.Fatalf("HasAVX expected true when HasAVX2 is true, got false")
    19  	}
    20  }
    21  
    22  func TestDisableSSE3(t *testing.T) {
    23  	runDebugOptionsTest(t, "TestSSE3DebugOption", "cpu.sse3=off")
    24  }
    25  
    26  func TestSSE3DebugOption(t *testing.T) {
    27  	MustHaveDebugOptionsSupport(t)
    28  
    29  	if godebug.Get("cpu.sse3") != "off" {
    30  		t.Skipf("skipping test: GODEBUG=cpu.sse3=off not set")
    31  	}
    32  
    33  	want := false
    34  	if got := X86.HasSSE3; got != want {
    35  		t.Errorf("X86.HasSSE3 expected %v, got %v", want, got)
    36  	}
    37  }