Skip to content

Commit

Permalink
pkg/runtest: accept Context as a parameter
Browse files Browse the repository at this point in the history
The cancellable context will let us abort runtest early in case of
problems.
  • Loading branch information
a-nogikh authored and dvyukov committed Jul 8, 2024
1 parent b1dad17 commit b0d6aa6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/runtest/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions pkg/runtest/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion syz-manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit b0d6aa6

Please sign in to comment.