unix: don't call testing.T.Fatalf in a background goroutine

> Those methods [...] must be called only from the goroutine running the
> Test function.

For golang/go#43498

Change-Id: I847067936ade613a21b059c90219bd285425f0aa
Reviewed-on: https://go-review.googlesource.com/c/sys/+/280622
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Artyom Pervukhin
2021-01-05 21:07:32 +00:00
committed by Ian Lance Taylor
parent 6f8348627a
commit 16f7687f50
+6 -3
View File
@@ -906,14 +906,17 @@ func TestPipe(t *testing.T) {
go func() {
n, err := unix.Write(w, []byte(s))
if err != nil {
t.Fatalf("bad write: %s\n", err)
t.Errorf("bad write: %s\n", err)
return
}
if n != len(s) {
t.Fatalf("bad write count: %d\n", n)
t.Errorf("bad write count: %d\n", n)
return
}
err = unix.Close(w)
if err != nil {
t.Fatalf("bad close: %s\n", err)
t.Errorf("bad close: %s\n", err)
return
}
}()
var buf [10 + len(s)]byte