github.com/go-xe2/third@v1.0.3/golang.org/x/sys/cpu/cpu_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  package cpu_test
     6  
     7  import (
     8  	"runtime"
     9  	"testing"
    10  
    11  	"github.com/go-xe2/third/golang.org/x/sys/cpu"
    12  )
    13  
    14  func TestAMD64minimalFeatures(t *testing.T) {
    15  	if runtime.GOARCH == "amd64" {
    16  		if !cpu.X86.HasSSE2 {
    17  			t.Fatal("HasSSE2 expected true, got false")
    18  		}
    19  	}
    20  }
    21  
    22  func TestAVX2hasAVX(t *testing.T) {
    23  	if runtime.GOARCH == "amd64" {
    24  		if cpu.X86.HasAVX2 && !cpu.X86.HasAVX {
    25  			t.Fatal("HasAVX expected true, got false")
    26  		}
    27  	}
    28  }
    29  
    30  func TestARM64minimalFeatures(t *testing.T) {
    31  	if runtime.GOARCH != "arm64" || runtime.GOOS != "linux" {
    32  		return
    33  	}
    34  	if !cpu.ARM64.HasASIMD {
    35  		t.Fatal("HasASIMD expected true, got false")
    36  	}
    37  	if !cpu.ARM64.HasFP {
    38  		t.Fatal("HasFP expected true, got false")
    39  	}
    40  }
    41  
    42  // On ppc64x, the ISA bit for POWER8 should always be set on POWER8 and beyond.
    43  func TestPPC64minimalFeatures(t *testing.T) {
    44  	// Do not run this with gccgo on ppc64, as it doesn't have POWER8 as a minimum
    45  	// requirement.
    46  	if runtime.Compiler == "gccgo" && runtime.GOARCH == "ppc64" {
    47  		t.Skip("gccgo does not require POWER8 on ppc64; skipping")
    48  	}
    49  	if runtime.GOARCH == "ppc64" || runtime.GOARCH == "ppc64le" {
    50  		if !cpu.PPC64.IsPOWER8 {
    51  			t.Fatal("IsPOWER8 expected true, got false")
    52  		}
    53  	}
    54  }