...

Source file src/internal/cpu/cpu_x86_test.go

Documentation: internal/cpu

     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 TestX86ifAVX512FhasAVX2(t *testing.T) {
    22  	if X86.HasAVX512F && !X86.HasAVX2 {
    23  		t.Fatalf("HasAVX2 expected true when HasAVX512F is true, got false")
    24  	}
    25  }
    26  
    27  func TestX86ifAVX512BWhasAVX512F(t *testing.T) {
    28  	if X86.HasAVX512BW && !X86.HasAVX512F {
    29  		t.Fatalf("HasAVX512F expected true when HasAVX512BW is true, got false")
    30  	}
    31  }
    32  
    33  func TestX86ifAVX512VLhasAVX512F(t *testing.T) {
    34  	if X86.HasAVX512VL && !X86.HasAVX512F {
    35  		t.Fatalf("HasAVX512F expected true when HasAVX512VL is true, got false")
    36  	}
    37  }
    38  
    39  func TestDisableSSE3(t *testing.T) {
    40  	if GetGOAMD64level() > 1 {
    41  		t.Skip("skipping test: can't run on GOAMD64>v1 machines")
    42  	}
    43  	runDebugOptionsTest(t, "TestSSE3DebugOption", "cpu.sse3=off")
    44  }
    45  
    46  func TestSSE3DebugOption(t *testing.T) {
    47  	MustHaveDebugOptionsSupport(t)
    48  
    49  	if godebug.New("#cpu.sse3").Value() != "off" {
    50  		t.Skipf("skipping test: GODEBUG=cpu.sse3=off not set")
    51  	}
    52  
    53  	want := false
    54  	if got := X86.HasSSE3; got != want {
    55  		t.Errorf("X86.HasSSE3 expected %v, got %v", want, got)
    56  	}
    57  }
    58  

View as plain text