mirror of
https://github.com/golang/go
synced 2024-11-17 23:44:48 -07:00
cmd/go: test with SIGTERM in test_fuzz_non_crash_signal
The test currently uses only SIGKILL (which cannot be trapped by the worker process) and SIGILL (which is handled by the Go runtime, and does pretty unambiguously indicate a crash). It is missing a third (and perhaps more likely) case: a signal like SIGTERM that is handled by the Go runtime and causes the test to terminate, but nonetheless does not indicate a crash. Change-Id: I0595a0917e977e8eb2c24ae8b706d734ce3b2f4f Reviewed-on: https://go-review.googlesource.com/c/go/+/359482 Trust: Bryan C. Mills <bcmills@google.com> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org>
This commit is contained in:
parent
b9540246ba
commit
d0751b1ad8
@ -10,6 +10,15 @@
|
||||
! exists testdata
|
||||
! stdout unreachable
|
||||
! stderr unreachable
|
||||
stdout 'fuzzing process terminated by unexpected signal; no crash will be recorded: signal: terminated'
|
||||
|
||||
# FuzzKill sends itself a signal that cannot be caught by the worker process
|
||||
# and does not appear to be a crash.
|
||||
# We should not save a crasher.
|
||||
! go test -fuzz=FuzzKill
|
||||
! exists testdata
|
||||
! stdout unreachable
|
||||
! stderr unreachable
|
||||
stdout 'fuzzing process terminated by unexpected signal; no crash will be recorded: signal: killed'
|
||||
|
||||
# FuzzCrash sends itself a signal that looks like a crash.
|
||||
@ -33,6 +42,17 @@ import (
|
||||
)
|
||||
|
||||
func FuzzNonCrash(f *testing.F) {
|
||||
f.Fuzz(func(*testing.T, bool) {
|
||||
pid := syscall.Getpid()
|
||||
if err := syscall.Kill(pid, syscall.SIGTERM); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// signal may not be received immediately. Wait for it.
|
||||
select{}
|
||||
})
|
||||
}
|
||||
|
||||
func FuzzKill(f *testing.F) {
|
||||
f.Fuzz(func(*testing.T, bool) {
|
||||
pid := syscall.Getpid()
|
||||
if err := syscall.Kill(pid, syscall.SIGKILL); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user