Feature *bool
Specified bool // whether feature value was specified in GODEBUG
Enable bool // whether feature should be enabled
- Required bool // whether feature is mandatory and can not be disabled
}
// processOptions enables or disables CPU feature values based on the parsed env string.
if key == "all" {
for i := range options {
options[i].Specified = true
- options[i].Enable = enable || options[i].Required
+ options[i].Enable = enable
}
continue field
}
continue
}
- if !o.Enable && o.Required {
- print("GODEBUG: can not disable \"", o.Name, "\", required CPU feature\n")
- continue
- }
-
*o.Feature = o.Enable
}
}
"internal/testenv"
"os"
"os/exec"
- "runtime"
"strings"
"testing"
)
-func TestMinimalFeatures(t *testing.T) {
- // TODO: maybe do MustSupportFeatureDectection(t) ?
- if runtime.GOARCH == "arm64" {
- switch runtime.GOOS {
- case "linux", "android", "darwin":
- default:
- t.Skipf("%s/%s is not supported", runtime.GOOS, runtime.GOARCH)
- }
- }
-
- for _, o := range Options {
- if o.Required && !*o.Feature {
- t.Errorf("%v expected true, got false", o.Name)
- }
- }
-}
-
func MustHaveDebugOptionsSupport(t *testing.T) {
if !DebugOptions {
t.Skipf("skipping test: cpu feature options not supported by OS")
}
for _, o := range Options {
- want := o.Required
+ want := false
if got := *o.Feature; got != want {
t.Errorf("%v: expected %v, got %v", o.Name, want, got)
}