Skip to content

Commit fc86770

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
runtime: eliminate arbitrary timeout in TestCgoLockOSThreadExit
This test previously failed if running a new pthread took longer than a hard-coded 100ms. On some slow or heavily-loaded builders, that scheduling latency is too short. Since the point of this test is to verify that the background thread is not reused after it terminates (see #20395), the arbitrary time limit does not seem helpful: if the background thread fails to terminate the test will time out on its own, and if the main goroutine is scheduled on the background thread the test will fail regardless of how long it takes. Fixes #58247. Change-Id: I626af52aac55af7a4c0e7829798573c479750c20 Reviewed-on: https://go-review.googlesource.com/c/go/+/464735 Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Auto-Submit: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent fcd0e09 commit fc86770

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/runtime/crash_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func runTestProg(t *testing.T, binary, name string, env ...string) string {
4949
}
5050

5151
testenv.MustHaveGoBuild(t)
52+
t.Helper()
5253

5354
exe, err := buildTestProg(t, binary)
5455
if err != nil {
@@ -135,13 +136,15 @@ func buildTestProg(t *testing.T, binary string, flags ...string) (string, error)
135136

136137
exe := filepath.Join(dir, name+".exe")
137138

138-
t.Logf("running go build -o %s %s", exe, strings.Join(flags, " "))
139+
start := time.Now()
139140
cmd := exec.Command(testenv.GoToolPath(t), append([]string{"build", "-o", exe}, flags...)...)
141+
t.Logf("running %v", cmd)
140142
cmd.Dir = "testdata/" + binary
141143
out, err := testenv.CleanCmdEnv(cmd).CombinedOutput()
142144
if err != nil {
143145
target.err = fmt.Errorf("building %s %v: %v\n%s", binary, flags, err, out)
144146
} else {
147+
t.Logf("built %v in %v", name, time.Since(start))
145148
target.exe = exe
146149
target.err = nil
147150
}

src/runtime/testdata/testprogcgo/lockosthread.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func LockOSThreadAlt() {
9494
// Exit with the thread locked.
9595
}()
9696
<-ready
97-
for i := 0; i < 100; i++ {
97+
for {
9898
time.Sleep(1 * time.Millisecond)
9999
// Check that this goroutine is running on a different thread.
100100
self := C.pthread_self()
@@ -107,6 +107,4 @@ func LockOSThreadAlt() {
107107
return
108108
}
109109
}
110-
println("sub thread still running")
111-
os.Exit(1)
112110
}

0 commit comments

Comments
 (0)