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.
16 func MustHaveDebugOptionsSupport(t *testing.T) {
18 t.Skipf("skipping test: cpu feature options not supported by OS")
22 func MustSupportFeatureDetection(t *testing.T) {
23 // TODO: add platforms that do not have CPU feature detection support.
26 func runDebugOptionsTest(t *testing.T, test string, options string) {
27 MustHaveDebugOptionsSupport(t)
29 testenv.MustHaveExec(t)
31 env := "GODEBUG=" + options
33 cmd := exec.Command(os.Args[0], "-test.run="+test)
34 cmd.Env = append(cmd.Env, env)
36 output, err := cmd.CombinedOutput()
38 t.Fatalf("%s with %s: run failed: %v output:\n%s\n",
39 test, env, err, string(output))
43 func TestDisableAllCapabilities(t *testing.T) {
44 MustSupportFeatureDetection(t)
45 runDebugOptionsTest(t, "TestAllCapabilitiesDisabled", "cpu.all=off")
48 func TestAllCapabilitiesDisabled(t *testing.T) {
49 MustHaveDebugOptionsSupport(t)
51 if godebug.New("#cpu.all").Value() != "off" {
52 t.Skipf("skipping test: GODEBUG=cpu.all=off not set")
55 for _, o := range Options {
57 if got := *o.Feature; got != want {
58 t.Errorf("%v: expected %v, got %v", o.Name, want, got)