aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-07-05 12:20:26 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-07-08 07:01:24 +0000
commitb0d6aa6df955f9a20d9ef61bc3e781d9ce135c6c (patch)
treee4b1367cbe1ea24f20f37366ffe68ee8e6148bd6
parentb1dad173ed7da74feb273f0397de0f4a4ff759e7 (diff)
pkg/runtest: accept Context as a parameter
The cancellable context will let us abort runtest early in case of problems.
-rw-r--r--pkg/runtest/run.go4
-rw-r--r--pkg/runtest/run_test.go4
-rw-r--r--syz-manager/manager.go2
3 files changed, 5 insertions, 5 deletions
diff --git a/pkg/runtest/run.go b/pkg/runtest/run.go
index 50af943e0..110ec15d4 100644
--- a/pkg/runtest/run.go
+++ b/pkg/runtest/run.go
@@ -67,7 +67,7 @@ func (ctx *Context) log(msg string, args ...interface{}) {
ctx.LogFunc(fmt.Sprintf(msg, args...))
}
-func (ctx *Context) Run() error {
+func (ctx *Context) Run(waitCtx context.Context) error {
ctx.buildSem = make(chan bool, runtime.GOMAXPROCS(0))
ctx.executor = queue.DynamicOrder()
ctx.generatePrograms()
@@ -84,7 +84,7 @@ func (ctx *Context) Run() error {
result = fmt.Sprintf("SKIP (%v)", req.skip)
verbose = true
} else {
- req.Request.Wait(context.Background())
+ req.Request.Wait(waitCtx)
if req.err != nil {
fail++
result = fmt.Sprintf("FAIL: %v",
diff --git a/pkg/runtest/run_test.go b/pkg/runtest/run_test.go
index 19619ee73..acf59c93d 100644
--- a/pkg/runtest/run_test.go
+++ b/pkg/runtest/run_test.go
@@ -85,7 +85,7 @@ func test(t *testing.T, sysTarget *targets.Target) {
Verbose: true,
Debug: *flagDebug,
}
- startRPCServer(t, target, executor, "", ctx, nil, nil, func(features flatrpc.Feature) {
+ waitCtx := startRPCServer(t, target, executor, "", ctx, nil, nil, func(features flatrpc.Feature) {
// Features we expect to be enabled on the test OS.
// All sandboxes except for none are not implemented, coverage is not returned,
// and setup for few features is failing specifically to test feature detection.
@@ -113,7 +113,7 @@ func test(t *testing.T, sysTarget *targets.Target) {
if t.Failed() {
return
}
- if err := ctx.Run(); err != nil {
+ if err := ctx.Run(waitCtx); err != nil {
t.Fatal(err)
}
}
diff --git a/syz-manager/manager.go b/syz-manager/manager.go
index 9990aacc0..a949089ef 100644
--- a/syz-manager/manager.go
+++ b/syz-manager/manager.go
@@ -1566,7 +1566,7 @@ func (mgr *Manager) MachineChecked(features flatrpc.Feature, enabledSyscalls map
Debug: *flagDebug,
}
go func() {
- err := ctx.Run()
+ err := ctx.Run(context.Background())
if err != nil {
log.Fatal(err)
}