stdout -count=1 '"Action":"pass","Package":"example","Elapsed":'
mkdir $WORK/fuzzcache
-go test -c . -fuzz=. -o test2json_interrupt_obj
-? go tool test2json -p example -t ./test2json_interrupt_obj -test.v -test.paniconexit0 -test.fuzzcachedir $WORK/fuzzcache -test.fuzz FuzzInterrupt -test.run '^$' -test.parallel 1
+go test -c . -fuzz=. -o example_test.exe
+? go tool test2json -p example -t ./example_test.exe -test.v -test.paniconexit0 -test.fuzzcachedir $WORK/fuzzcache -test.fuzz FuzzInterrupt -test.run '^$' -test.parallel 1
stdout -count=1 '"Action":"pass","Package":"example","Test":"FuzzInterrupt"'
stdout -count=1 '"Action":"pass","Package":"example","Elapsed":'
os.Setenv("GO_TEST_INTERRUPT_PIDS", fmt.Sprintf("%d,%d", ppid, pid))
}
+ sentInterrupt := false
f.Fuzz(func(t *testing.T, orig string) {
- // Simulate a ctrl-C on the keyboard by sending SIGINT
- // to the main test process and its parent.
- for _, pid := range strings.Split(pids, ",") {
- i, err := strconv.Atoi(pid)
- if err != nil {
- t.Fatal(err)
- }
- if p, err := os.FindProcess(i); err == nil {
- p.Signal(os.Interrupt)
- time.Sleep(10 * time.Millisecond)
- pids = "" // Only interrupt once.
+ if !sentInterrupt {
+ // Simulate a ctrl-C on the keyboard by sending SIGINT
+ // to the main test process and its parent.
+ for _, pid := range strings.Split(pids, ",") {
+ i, err := strconv.Atoi(pid)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if p, err := os.FindProcess(i); err == nil {
+ p.Signal(os.Interrupt)
+ sentInterrupt = true // Only send interrupts once.
+ }
}
}
+ time.Sleep(1 * time.Millisecond) // Delay the fuzzer a bit to avoid wasting CPU.
})
}