aboutsummaryrefslogtreecommitdiffhomepage
path: root/helper/bwrap_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-03-15 00:27:44 +0900
committerOphestra <cat@gensokyo.uk>2025-03-15 00:27:44 +0900
commitf443d315ad60d761c06135569abb0adb183ac8c1 (patch)
treee22b866dc239cd888ef7f3d2ffadaf6a14bd51aa /helper/bwrap_test.go
parent9e18d1de77b2c9bb24a51c2e99b060c6d06818ee (diff)
helper: clean up interface
The helper interface was messy due to odd context acquisition order. That has changed, so this cleans it up. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'helper/bwrap_test.go')
-rw-r--r--helper/bwrap_test.go35
1 files changed, 16 insertions, 19 deletions
diff --git a/helper/bwrap_test.go b/helper/bwrap_test.go
index a14a4179..4b423564 100644
--- a/helper/bwrap_test.go
+++ b/helper/bwrap_test.go
@@ -4,6 +4,7 @@ import (
"context"
"errors"
"os"
+ "os/exec"
"strings"
"testing"
"time"
@@ -33,11 +34,11 @@ func TestBwrap(t *testing.T) {
h := helper.MustNewBwrap(
context.Background(),
sc, "fortify", false,
- argsWt, argF,
- nil, nil,
+ argsWt, argF, nil,
+ nil, nil, false,
)
- if err := h.Start(false); !errors.Is(err, os.ErrNotExist) {
+ if err := h.Start(); !errors.Is(err, os.ErrNotExist) {
t.Errorf("Start: error = %v, wantErr %v",
err, os.ErrNotExist)
}
@@ -47,8 +48,8 @@ func TestBwrap(t *testing.T) {
if got := helper.MustNewBwrap(
context.TODO(),
sc, "fortify", false,
- argsWt, argF,
- nil, nil,
+ argsWt, argF, nil,
+ nil, nil, false,
); got == nil {
t.Errorf("MustNewBwrap(%#v, %#v, %#v) got nil",
sc, argsWt, "fortify")
@@ -68,8 +69,8 @@ func TestBwrap(t *testing.T) {
helper.MustNewBwrap(
context.TODO(),
&bwrap.Config{Hostname: "\x00"}, "fortify", false,
- nil, argF,
- nil, nil,
+ nil, argF, nil,
+ nil, nil, false,
)
})
@@ -78,17 +79,14 @@ func TestBwrap(t *testing.T) {
c, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
+ stdout, stderr := new(strings.Builder), new(strings.Builder)
h := helper.MustNewBwrap(
- c,
- sc, "crash-test-dummy", false,
- nil, argFChecked,
- nil, nil,
+ c, sc, "crash-test-dummy", false,
+ nil, argFChecked, func(cmd *exec.Cmd) { cmd.Stdout, cmd.Stderr = stdout, stderr },
+ nil, nil, false,
)
- stdout, stderr := new(strings.Builder), new(strings.Builder)
- h.SetStdout(stdout).SetStderr(stderr)
-
- if err := h.Start(false); err != nil {
+ if err := h.Start(); err != nil {
t.Errorf("Start: error = %v",
err)
return
@@ -101,11 +99,10 @@ func TestBwrap(t *testing.T) {
})
t.Run("implementation compliance", func(t *testing.T) {
- testHelper(t, func(ctx context.Context) helper.Helper {
+ testHelper(t, func(ctx context.Context, cmdF func(cmd *exec.Cmd), stat bool) helper.Helper {
return helper.MustNewBwrap(
- ctx,
- sc, "crash-test-dummy", false,
- argsWt, argF, nil, nil,
+ ctx, sc, "crash-test-dummy", false,
+ argsWt, argF, cmdF, nil, nil, stat,
)
})
})