aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-05-10 18:13:13 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-05-16 15:38:27 +0000
commit1cf9be9327cbff5ed11e2106e362039f09aaed7c (patch)
tree88b858b4de4a6b5d3d76728e6d2d457df0047e86 /pkg
parenta10940b81777718365ee7f71495abdc69a32285b (diff)
pkg/runtest: print results as they appear
There's no need to wait until all results have been completed to print them.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/runtest/run.go51
1 files changed, 30 insertions, 21 deletions
diff --git a/pkg/runtest/run.go b/pkg/runtest/run.go
index dc8dcd2c4..a85fc3209 100644
--- a/pkg/runtest/run.go
+++ b/pkg/runtest/run.go
@@ -22,6 +22,7 @@ import (
"sort"
"strconv"
"strings"
+ "sync"
"github.com/google/syzkaller/pkg/csource"
"github.com/google/syzkaller/pkg/flatrpc"
@@ -29,15 +30,15 @@ import (
"github.com/google/syzkaller/pkg/ipc"
"github.com/google/syzkaller/prog"
"github.com/google/syzkaller/sys/targets"
+ "golang.org/x/sync/errgroup"
)
type runRequest struct {
*queue.Request
- err error
- finished chan struct{}
- result *queue.Result
- results *ipc.ProgInfo // the expected results
+ err error
+ result *queue.Result
+ results *ipc.ProgInfo // the expected results
name string
broken string
@@ -67,20 +68,26 @@ func (ctx *Context) Run() error {
ctx.Retries++
}
progs := make(chan *runRequest, 1000)
- errc := make(chan error, 1)
- go func() {
+ var eg errgroup.Group
+ eg.Go(func() error {
defer close(progs)
- errc <- ctx.generatePrograms(progs)
- }()
- var requests []*runRequest
+ return ctx.generatePrograms(progs)
+ })
+ done := make(chan *runRequest)
+ eg.Go(func() error {
+ return ctx.processResults(done)
+ })
+
+ var wg sync.WaitGroup
for req := range progs {
req := req
- requests = append(requests, req)
if req.broken != "" || req.skip != "" {
+ done <- req
continue
}
- req.finished = make(chan struct{})
+ wg.Add(1)
go func() {
+ defer wg.Done()
// The tests depend on timings and may be flaky, esp on overloaded/slow machines.
// We don't want to fix this by significantly bumping all timeouts,
// because if a program fails all the time with the default timeouts,
@@ -108,11 +115,21 @@ func (ctx *Context) Run() error {
}
}
req.err = resultErr
- close(req.finished)
+ done <- req
}()
}
+ wg.Wait()
+ close(done)
+ return eg.Wait()
+}
+
+func (ctx *Context) Next() *queue.Request {
+ return ctx.executor.Next()
+}
+
+func (ctx *Context) processResults(requests chan *runRequest) error {
var ok, fail, broken, skip int
- for _, req := range requests {
+ for req := range requests {
result := ""
verbose := false
if req.broken != "" {
@@ -124,7 +141,6 @@ func (ctx *Context) Run() error {
result = fmt.Sprintf("SKIP (%v)", req.skip)
verbose = true
} else {
- <-req.finished
if req.err != nil {
fail++
result = fmt.Sprintf("FAIL: %v",
@@ -146,9 +162,6 @@ func (ctx *Context) Run() error {
os.Remove(req.BinaryFile)
}
}
- if err := <-errc; err != nil {
- return err
- }
ctx.log("ok: %v, broken: %v, skip: %v, fail: %v", ok, broken, skip, fail)
if fail != 0 {
return fmt.Errorf("tests failed")
@@ -156,10 +169,6 @@ func (ctx *Context) Run() error {
return nil
}
-func (ctx *Context) Next() *queue.Request {
- return ctx.executor.Next()
-}
-
func (ctx *Context) generatePrograms(progs chan *runRequest) error {
cover := []bool{false}
if ctx.Features&flatrpc.FeatureCoverage != 0 {