]> Cypherpunks repositories - gostls13.git/commitdiff
internal/cpu: use 'off' for disabling cpu capabilities instead of '0'
authorMartin Möhrmann <moehrmann@google.com>
Fri, 12 Oct 2018 16:01:50 +0000 (18:01 +0200)
committerMartin Möhrmann <moehrmann@google.com>
Fri, 12 Oct 2018 16:44:26 +0000 (16:44 +0000)
Updates #27218

Change-Id: I4ce20376fd601b5f958d79014af7eaf89e9de613
Reviewed-on: https://go-review.googlesource.com/c/141818
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/internal/cpu/cpu.go
src/internal/cpu/cpu_test.go
src/internal/cpu/cpu_x86_test.go

index 54b100b1d4606f829c897d6da4e0c713b261f654..fdda880af4abe1ab85cceb7faf05c8b2d43ed007 100644 (file)
@@ -157,11 +157,11 @@ type option struct {
 }
 
 // processOptions disables CPU feature values based on the parsed env string.
-// The env string is expected to be of the form feature1=0,feature2=0...
+// The env string is expected to be of the form feature1=off,feature2=off...
 // where feature names is one of the architecture specifc list stored in the
-// cpu packages options variable. If env contains all=0 then all capabilities
+// cpu packages options variable. If env contains all=off then all capabilities
 // referenced through the options variable are disabled. Other feature
-// names and values other than 0 are silently ignored.
+// names and values other than 'off' are silently ignored.
 func processOptions(env string) {
 field:
        for env != "" {
@@ -178,8 +178,8 @@ field:
                }
                key, value := field[:i], field[i+1:]
 
-               // Only allow turning off CPU features by specifying '0'.
-               if value == "0" {
+               // Only allow turning off CPU features by specifying 'off'.
+               if value == "off" {
                        if key == "all" {
                                for _, v := range options {
                                        *v.Feature = false
index 04ab9eeecb87b2d6aff015b7ab28a9b44b8c6683..6e7375fa7cdc3a92b6dddf8f3d2b48573c3df2f5 100644 (file)
@@ -38,14 +38,14 @@ func runDebugOptionsTest(t *testing.T, test string, options string) {
 }
 
 func TestDisableAllCapabilities(t *testing.T) {
-       runDebugOptionsTest(t, "TestAllCapabilitiesDisabled", "all=0")
+       runDebugOptionsTest(t, "TestAllCapabilitiesDisabled", "all=off")
 }
 
 func TestAllCapabilitiesDisabled(t *testing.T) {
        MustHaveDebugOptionsSupport(t)
 
-       if os.Getenv("GODEBUGCPU") != "all=0" {
-               t.Skipf("skipping test: GODEBUGCPU=all=0 not set")
+       if os.Getenv("GODEBUGCPU") != "all=off" {
+               t.Skipf("skipping test: GODEBUGCPU=all=off not set")
        }
 
        for _, o := range Options {
index c3ea7cb59035d731a82c718939ec37b49e108907..59c51770c5a8948a17044ab73dc054083371d546 100644 (file)
@@ -30,14 +30,14 @@ func TestX86ifAVX2hasAVX(t *testing.T) {
 }
 
 func TestDisableSSE2(t *testing.T) {
-       runDebugOptionsTest(t, "TestSSE2DebugOption", "sse2=0")
+       runDebugOptionsTest(t, "TestSSE2DebugOption", "sse2=off")
 }
 
 func TestSSE2DebugOption(t *testing.T) {
        MustHaveDebugOptionsSupport(t)
 
-       if os.Getenv("GODEBUGCPU") != "sse2=0" {
-               t.Skipf("skipping test: GODEBUGCPU=sse2=0 not set")
+       if os.Getenv("GODEBUGCPU") != "sse2=off" {
+               t.Skipf("skipping test: GODEBUGCPU=sse2=off not set")
        }
 
        want := runtime.GOARCH != "386" // SSE2 can only be disabled on 386.