cmd/cgo/internal/testcshared: remove an arbitrary timeout in TestSignalHandlersWithNotify

Also log verbose information when -test.v is set.

We need an arbitrary delay when checking that a signal is *not*
delivered, but when we expect the signal to arrive we don't need to
set an arbitrary limit on how long that can take.

Fixes #61264.

Change-Id: If3bbbf78e3c22694bf825d90d7ee9564ce8daedd
Reviewed-on: https://go-review.googlesource.com/c/go/+/509636
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
This commit is contained in:
Bryan C. Mills 2023-07-14 13:24:55 -04:00 committed by Gopher Robot
parent a55ef98239
commit 9ee23e97a2
4 changed files with 72 additions and 49 deletions

View file

@ -182,6 +182,8 @@ func run(t *testing.T, extraEnv []string, args ...string) string {
if len(extraEnv) > 0 {
cmd.Env = append(os.Environ(), extraEnv...)
}
stderr := new(strings.Builder)
cmd.Stderr = stderr
if GOOS != "windows" {
// TestUnexportedSymbols relies on file descriptor 30
@ -192,11 +194,13 @@ func run(t *testing.T, extraEnv []string, args ...string) string {
cmd.ExtraFiles = make([]*os.File, 28)
}
out, err := cmd.CombinedOutput()
t.Logf("run: %v", args)
out, err := cmd.Output()
if stderr.Len() > 0 {
t.Logf("stderr:\n%s", stderr)
}
if err != nil {
t.Fatalf("command failed: %v\n%v\n%s\n", args, err, out)
} else {
t.Logf("run: %v", args)
}
return string(out)
}
@ -602,9 +606,13 @@ func testSignalHandlers(t *testing.T, pkgname, cfile, cmd string) {
defer os.Remove(bin)
defer os.Remove(pkgname + ".h")
out := runExe(t, nil, bin, "./"+libname)
args := []string{bin, "./" + libname}
if testing.Verbose() {
args = append(args, "verbose")
}
out := runExe(t, nil, args...)
if strings.TrimSpace(out) != "PASS" {
t.Error(run(t, nil, bin, libname, "verbose"))
t.Errorf("%v%s", args, out)
}
}