github.com/Carcraftz/utls@v0.0.0-20220413235215-6b7c52fd78b6/cpu/cpu_test.go (about)

     1  // Copyright 2017 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  	"gitlab.com/yawning/utls.git/cpu"
    12  )
    13  
    14  func TestAMD64minimalFeatures(t *testing.T) {
    15  	if runtime.GOARCH == "amd64" {
    16  		if !cpu.X86.HasSSE2 {
    17  			t.Fatalf("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.Fatalf("HasAVX expected true, got false")
    26  		}
    27  	}
    28  }
    29  
    30  func TestPPC64minimalFeatures(t *testing.T) {
    31  	if runtime.GOARCH == "ppc64" || runtime.GOARCH == "ppc64le" {
    32  		if !cpu.PPC64.IsPOWER8 {
    33  			t.Fatalf("IsPOWER8 expected true, got false")
    34  		}
    35  		if !cpu.PPC64.HasVMX {
    36  			t.Fatalf("HasVMX expected true, got false")
    37  		}
    38  		if !cpu.PPC64.HasDFP {
    39  			t.Fatalf("HasDFP expected true, got false")
    40  		}
    41  		if !cpu.PPC64.HasVSX {
    42  			t.Fatalf("HasVSX expected true, got false")
    43  		}
    44  		if !cpu.PPC64.HasISEL {
    45  			t.Fatalf("HasISEL expected true, got false")
    46  		}
    47  		if !cpu.PPC64.HasVCRYPTO {
    48  			t.Fatalf("HasVCRYPTO expected true, got false")
    49  		}
    50  	}
    51  }