From b0d6aa6df955f9a20d9ef61bc3e781d9ce135c6c Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 5 Jul 2024 12:20:26 +0200 Subject: pkg/runtest: accept Context as a parameter The cancellable context will let us abort runtest early in case of problems. --- pkg/runtest/run.go | 4 ++-- pkg/runtest/run_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'pkg/runtest') 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) } } -- cgit mrf-deployment