github.com/primecitizens/pcz/std@v0.2.1/core/cpu/cpu_x86_test.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  //
     4  // Copyright 2018 The Go Authors. All rights reserved.
     5  // Use of this source code is governed by a BSD-style
     6  // license that can be found in the LICENSE file.
     7  
     8  //go:build 386 || amd64
     9  
    10  package cpu_test
    11  
    12  import (
    13  	"internal/godebug"
    14  	"testing"
    15  
    16  	. "github.com/primecitizens/pcz/std/core/cpu"
    17  )
    18  
    19  func TestX86ifAVX2hasAVX(t *testing.T) {
    20  	if X86.HasAll(X86Feature_avx2) && !X86.HasAll(X86Feature_avx2) {
    21  		t.Fatalf("HasAVX expected true when HasAVX2 is true, got false")
    22  	}
    23  }
    24  
    25  func TestDisableSSE3(t *testing.T) {
    26  	// if GOAMD64() > 1 {
    27  	// 	t.Skip("skipping test: can't run on GOAMD64>v1 machines")
    28  	// }
    29  	// runDebugOptionsTest(t, "TestSSE3DebugOption", "cpu.sse3=off")
    30  }
    31  
    32  func TestSSE3DebugOption(t *testing.T) {
    33  	MustHaveDebugOptionsSupport(t)
    34  
    35  	if godebug.Get("cpu.sse3") != "off" {
    36  		t.Skipf("skipping test: GODEBUG=cpu.sse3=off not set")
    37  	}
    38  
    39  	want := false
    40  	if got := X86.HasAll(X86Feature_sse3); got != want {
    41  		t.Errorf("X86.HasSSE3 expected %v, got %v", want, got)
    42  	}
    43  }