mirror of
https://github.com/golang/go
synced 2024-11-22 14:34:45 -07:00
runtime: give test child time to block
The child in TestPanicSystemstack prints "x\n" and then blocks on a lock. Receiving those bytes only indicates that the child is _about to block_. Since we don't have a way to know when it is fully blocked, sleep a bit to give it time to block. This makes us less likely to lose the race and signal before the child blocks, which will fail the test as the stack trace cannot be read from a running G. Fixes #33626 Change-Id: I8a27b1b114bf75e1e5bcb2a7a33aa69cdbc22f40 Reviewed-on: https://go-review.googlesource.com/c/go/+/268578 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
ae76f6e962
commit
b63db7f724
@ -232,13 +232,20 @@ func TestPanicSystemstack(t *testing.T) {
|
||||
}
|
||||
defer pr.Close()
|
||||
|
||||
// Wait for "x\nx\n" to indicate readiness.
|
||||
// Wait for "x\nx\n" to indicate almost-readiness.
|
||||
buf := make([]byte, 4)
|
||||
_, err = io.ReadFull(pr, buf)
|
||||
if err != nil || string(buf) != "x\nx\n" {
|
||||
t.Fatal("subprocess failed; output:\n", string(buf))
|
||||
}
|
||||
|
||||
// The child blockers print "x\n" and then block on a lock. Receiving
|
||||
// those bytes only indicates that the child is _about to block_. Since
|
||||
// we don't have a way to know when it is fully blocked, sleep a bit to
|
||||
// make us less likely to lose the race and signal before the child
|
||||
// blocks.
|
||||
time.Sleep(100*time.Millisecond)
|
||||
|
||||
// Send SIGQUIT.
|
||||
if err := cmd.Process.Signal(syscall.SIGQUIT); err != nil {
|
||||
t.Fatal("signaling subprocess: ", err)
|
||||
|
Loading…
Reference in New Issue
Block a user