|
|
|
@ -32,7 +32,7 @@ type MySuite struct{} |
|
|
|
|
|
|
|
|
|
var _ = Suite(&MySuite{}) |
|
|
|
|
|
|
|
|
|
func hasCpuFeatureFromOS(feature string) (bool, error) { |
|
|
|
|
func hasCPUFeatureFromOS(feature string) (bool, error) { |
|
|
|
|
if runtime.GOOS == "linux" { |
|
|
|
|
command := exec.Command("/bin/cat", "/proc/cpuinfo") |
|
|
|
|
output, err := command.Output() |
|
|
|
@ -41,9 +41,8 @@ func hasCpuFeatureFromOS(feature string) (bool, error) { |
|
|
|
|
} |
|
|
|
|
if strings.Contains(string(output), feature) { |
|
|
|
|
return true, nil |
|
|
|
|
} else { |
|
|
|
|
return false, nil |
|
|
|
|
} |
|
|
|
|
return false, nil |
|
|
|
|
} else { |
|
|
|
|
// TODO find new way to test cpu flags on windows
|
|
|
|
|
return false, errors.New("Not Implemented on this platform") |
|
|
|
@ -53,7 +52,7 @@ func hasCpuFeatureFromOS(feature string) (bool, error) { |
|
|
|
|
func (s *MySuite) TestHasSSE41(c *C) { |
|
|
|
|
if runtime.GOOS == "linux" { |
|
|
|
|
var flag = HasSSE41() |
|
|
|
|
osCheck, err := hasCpuFeatureFromOS("sse4_1") |
|
|
|
|
osCheck, err := hasCPUFeatureFromOS("sse4_1") |
|
|
|
|
c.Assert(err, IsNil) |
|
|
|
|
c.Check(flag, Equals, osCheck) |
|
|
|
|
} |
|
|
|
@ -62,7 +61,7 @@ func (s *MySuite) TestHasSSE41(c *C) { |
|
|
|
|
func (s *MySuite) TestHasAVX(c *C) { |
|
|
|
|
if runtime.GOOS == "linux" { |
|
|
|
|
var flag = HasAVX() |
|
|
|
|
osFlag, err := hasCpuFeatureFromOS("avx") |
|
|
|
|
osFlag, err := hasCPUFeatureFromOS("avx") |
|
|
|
|
c.Assert(err, IsNil) |
|
|
|
|
c.Check(osFlag, Equals, flag) |
|
|
|
|
} |
|
|
|
@ -71,7 +70,7 @@ func (s *MySuite) TestHasAVX(c *C) { |
|
|
|
|
func (s *MySuite) TestHasAVX2(c *C) { |
|
|
|
|
if runtime.GOOS == "linux" { |
|
|
|
|
var flag = HasAVX2() |
|
|
|
|
osFlag, err := hasCpuFeatureFromOS("avx2") |
|
|
|
|
osFlag, err := hasCPUFeatureFromOS("avx2") |
|
|
|
|
c.Assert(err, IsNil) |
|
|
|
|
c.Check(osFlag, Equals, flag) |
|
|
|
|
} |
|
|
|
|