diff options
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/abi_test.go | 4 | ||||
| -rw-r--r-- | src/runtime/crash_test.go | 15 | ||||
| -rw-r--r-- | src/runtime/crash_unix_test.go | 2 | ||||
| -rw-r--r-- | src/runtime/debug/stack_test.go | 17 | ||||
| -rw-r--r-- | src/runtime/hash_test.go | 3 | ||||
| -rw-r--r-- | src/runtime/malloc_test.go | 4 | ||||
| -rw-r--r-- | src/runtime/map_test.go | 2 | ||||
| -rw-r--r-- | src/runtime/syscall_windows_test.go | 2 |
8 files changed, 14 insertions, 35 deletions
diff --git a/src/runtime/abi_test.go b/src/runtime/abi_test.go index d2e79c6dc4..af187fc7a8 100644 --- a/src/runtime/abi_test.go +++ b/src/runtime/abi_test.go @@ -44,12 +44,10 @@ type TintPointer struct { func (*TintPointer) m() {} func TestFinalizerRegisterABI(t *testing.T) { - testenv.MustHaveExec(t) - // Actually run the test in a subprocess because we don't want // finalizers from other tests interfering. if os.Getenv("TEST_FINALIZER_REGABI") != "1" { - cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=^TestFinalizerRegisterABI$", "-test.v")) + cmd := testenv.CleanCmdEnv(exec.Command(testenv.Executable(t), "-test.run=^TestFinalizerRegisterABI$", "-test.v")) cmd.Env = append(cmd.Env, "TEST_FINALIZER_REGABI=1") out, err := cmd.CombinedOutput() if !strings.Contains(string(out), "PASS\n") || err != nil { diff --git a/src/runtime/crash_test.go b/src/runtime/crash_test.go index fcf5ef85ce..00e84a3879 100644 --- a/src/runtime/crash_test.go +++ b/src/runtime/crash_test.go @@ -889,8 +889,7 @@ func init() { } func TestRuntimePanic(t *testing.T) { - testenv.MustHaveExec(t) - cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=^TestRuntimePanic$")) + cmd := testenv.CleanCmdEnv(exec.Command(testenv.Executable(t), "-test.run=^TestRuntimePanic$")) cmd.Env = append(cmd.Env, "GO_TEST_RUNTIME_PANIC=1") out, err := cmd.CombinedOutput() t.Logf("%s", out) @@ -902,8 +901,7 @@ func TestRuntimePanic(t *testing.T) { } func TestTracebackRuntimeFunction(t *testing.T) { - testenv.MustHaveExec(t) - cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=TestTracebackRuntimeFunction")) + cmd := testenv.CleanCmdEnv(exec.Command(testenv.Executable(t), "-test.run=TestTracebackRuntimeFunction")) cmd.Env = append(cmd.Env, "GO_TEST_RUNTIME_NPE_READMEMSTATS=1") out, err := cmd.CombinedOutput() t.Logf("%s", out) @@ -915,8 +913,7 @@ func TestTracebackRuntimeFunction(t *testing.T) { } func TestTracebackRuntimeMethod(t *testing.T) { - testenv.MustHaveExec(t) - cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=TestTracebackRuntimeMethod")) + cmd := testenv.CleanCmdEnv(exec.Command(testenv.Executable(t), "-test.run=TestTracebackRuntimeMethod")) cmd.Env = append(cmd.Env, "GO_TEST_RUNTIME_NPE_FUNCMETHOD=1") out, err := cmd.CombinedOutput() t.Logf("%s", out) @@ -929,14 +926,12 @@ func TestTracebackRuntimeMethod(t *testing.T) { // Test that g0 stack overflows are handled gracefully. func TestG0StackOverflow(t *testing.T) { - testenv.MustHaveExec(t) - if runtime.GOOS == "ios" { testenv.SkipFlaky(t, 62671) } if os.Getenv("TEST_G0_STACK_OVERFLOW") != "1" { - cmd := testenv.CleanCmdEnv(testenv.Command(t, os.Args[0], "-test.run=^TestG0StackOverflow$", "-test.v")) + cmd := testenv.CleanCmdEnv(testenv.Command(t, testenv.Executable(t), "-test.run=^TestG0StackOverflow$", "-test.v")) cmd.Env = append(cmd.Env, "TEST_G0_STACK_OVERFLOW=1") out, err := cmd.CombinedOutput() t.Logf("output:\n%s", out) @@ -977,7 +972,7 @@ func init() { func TestCrashWhileTracing(t *testing.T) { testenv.MustHaveExec(t) - cmd := testenv.CleanCmdEnv(testenv.Command(t, os.Args[0])) + cmd := testenv.CleanCmdEnv(testenv.Command(t, testenv.Executable(t))) cmd.Env = append(cmd.Env, "TEST_CRASH_WHILE_TRACING=1") stdOut, err := cmd.StdoutPipe() var errOut bytes.Buffer diff --git a/src/runtime/crash_unix_test.go b/src/runtime/crash_unix_test.go index 123a462423..101107d2f7 100644 --- a/src/runtime/crash_unix_test.go +++ b/src/runtime/crash_unix_test.go @@ -163,7 +163,7 @@ func TestPanicSystemstack(t *testing.T) { } t.Parallel() - cmd := exec.Command(os.Args[0], "testPanicSystemstackInternal") + cmd := exec.Command(testenv.Executable(t), "testPanicSystemstackInternal") cmd = testenv.CleanCmdEnv(cmd) cmd.Dir = t.TempDir() // put any core file in tempdir cmd.Env = append(cmd.Env, "GOTRACEBACK=crash") diff --git a/src/runtime/debug/stack_test.go b/src/runtime/debug/stack_test.go index e1559303f0..88d4ad0c0f 100644 --- a/src/runtime/debug/stack_test.go +++ b/src/runtime/debug/stack_test.go @@ -87,12 +87,7 @@ func TestStack(t *testing.T) { // initial (not current) environment. Spawn a subprocess to determine the // real baked-in GOROOT. t.Logf("found GOROOT %q from environment; checking embedded GOROOT value", envGoroot) - testenv.MustHaveExec(t) - exe, err := os.Executable() - if err != nil { - t.Fatal(err) - } - cmd := exec.Command(exe) + cmd := exec.Command(testenv.Executable(t)) cmd.Env = append(os.Environ(), "GOROOT=", "GO_RUNTIME_DEBUG_TEST_ENTRYPOINT=dumpgoroot") out, err := cmd.Output() if err != nil { @@ -137,18 +132,12 @@ func TestStack(t *testing.T) { } func TestSetCrashOutput(t *testing.T) { - testenv.MustHaveExec(t) - exe, err := os.Executable() - if err != nil { - t.Fatal(err) - } - crashOutput := filepath.Join(t.TempDir(), "crash.out") - cmd := exec.Command(exe) + cmd := exec.Command(testenv.Executable(t)) cmd.Stderr = new(strings.Builder) cmd.Env = append(os.Environ(), "GO_RUNTIME_DEBUG_TEST_ENTRYPOINT=setcrashoutput", "CRASHOUTPUT="+crashOutput) - err = cmd.Run() + err := cmd.Run() stderr := fmt.Sprint(cmd.Stderr) if err == nil { t.Fatalf("child process succeeded unexpectedly (stderr: %s)", stderr) diff --git a/src/runtime/hash_test.go b/src/runtime/hash_test.go index 24c04b260e..3ef9f9addb 100644 --- a/src/runtime/hash_test.go +++ b/src/runtime/hash_test.go @@ -638,11 +638,10 @@ func TestSmhasherSeed(t *testing.T) { } func TestIssue66841(t *testing.T) { - testenv.MustHaveExec(t) if *UseAeshash && os.Getenv("TEST_ISSUE_66841") == "" { // We want to test the backup hash, so if we're running on a machine // that uses aeshash, exec ourselves while turning aes off. - cmd := testenv.CleanCmdEnv(testenv.Command(t, os.Args[0], "-test.run=^TestIssue66841$")) + cmd := testenv.CleanCmdEnv(testenv.Command(t, testenv.Executable(t), "-test.run=^TestIssue66841$")) cmd.Env = append(cmd.Env, "GODEBUG=cpu.aes=off", "TEST_ISSUE_66841=1") out, err := cmd.CombinedOutput() if err != nil { diff --git a/src/runtime/malloc_test.go b/src/runtime/malloc_test.go index 67bceef2e3..6cd525d5e9 100644 --- a/src/runtime/malloc_test.go +++ b/src/runtime/malloc_test.go @@ -270,12 +270,10 @@ type acLink struct { var arenaCollisionSink []*acLink func TestArenaCollision(t *testing.T) { - testenv.MustHaveExec(t) - // Test that mheap.sysAlloc handles collisions with other // memory mappings. if os.Getenv("TEST_ARENA_COLLISION") != "1" { - cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=^TestArenaCollision$", "-test.v")) + cmd := testenv.CleanCmdEnv(exec.Command(testenv.Executable(t), "-test.run=^TestArenaCollision$", "-test.v")) cmd.Env = append(cmd.Env, "TEST_ARENA_COLLISION=1") out, err := cmd.CombinedOutput() if race.Enabled { diff --git a/src/runtime/map_test.go b/src/runtime/map_test.go index c522c44a4e..b1ff02d851 100644 --- a/src/runtime/map_test.go +++ b/src/runtime/map_test.go @@ -1106,7 +1106,7 @@ func computeHash() uintptr { func subprocessHash(t *testing.T, env string) uintptr { t.Helper() - cmd := testenv.CleanCmdEnv(testenv.Command(t, os.Args[0], "-test.run=^TestMemHashGlobalSeed$")) + cmd := testenv.CleanCmdEnv(testenv.Command(t, testenv.Executable(t), "-test.run=^TestMemHashGlobalSeed$")) cmd.Env = append(cmd.Env, "GO_TEST_SUBPROCESS_HASH=1") if env != "" { cmd.Env = append(cmd.Env, env) diff --git a/src/runtime/syscall_windows_test.go b/src/runtime/syscall_windows_test.go index 01a9ca3b8c..7a7269d125 100644 --- a/src/runtime/syscall_windows_test.go +++ b/src/runtime/syscall_windows_test.go @@ -1043,7 +1043,7 @@ func TestNumCPU(t *testing.T) { _GetProcessAffinityMask := kernel32.MustFindProc("GetProcessAffinityMask") _SetProcessAffinityMask := kernel32.MustFindProc("SetProcessAffinityMask") - cmd := exec.Command(os.Args[0], "-test.run=TestNumCPU") + cmd := exec.Command(testenv.Executable(t), "-test.run=TestNumCPU") cmd.Env = append(os.Environ(), "GO_WANT_HELPER_PROCESS=1") var buf strings.Builder cmd.Stdout = &buf |
