aboutsummaryrefslogtreecommitdiffhomepage
path: root/helper/cmd_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'helper/cmd_test.go')
-rw-r--r--helper/cmd_test.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/helper/cmd_test.go b/helper/cmd_test.go
index 60c0caff..9c640983 100644
--- a/helper/cmd_test.go
+++ b/helper/cmd_test.go
@@ -3,6 +3,7 @@ package helper_test
import (
"context"
"errors"
+ "io"
"os"
"os/exec"
"testing"
@@ -10,9 +11,9 @@ import (
"git.gensokyo.uk/security/fortify/helper"
)
-func TestDirect(t *testing.T) {
+func TestCmd(t *testing.T) {
t.Run("start non-existent helper path", func(t *testing.T) {
- h := helper.NewDirect(context.Background(), "/nonexistent", argsWt, false, argF, nil, nil)
+ h := helper.NewDirect(context.Background(), "/proc/nonexistent", argsWt, false, argF, nil, nil)
if err := h.Start(); !errors.Is(err, os.ErrNotExist) {
t.Errorf("Start: error = %v, wantErr %v",
@@ -22,15 +23,17 @@ func TestDirect(t *testing.T) {
t.Run("valid new helper nil check", func(t *testing.T) {
if got := helper.NewDirect(context.TODO(), "fortify", argsWt, false, argF, nil, nil); got == nil {
- t.Errorf("New(%q, %q) got nil",
+ t.Errorf("NewDirect(%q, %q) got nil",
argsWt, "fortify")
return
}
})
t.Run("implementation compliance", func(t *testing.T) {
- testHelper(t, func(ctx context.Context, cmdF func(cmd *exec.Cmd), stat bool) helper.Helper {
- return helper.NewDirect(ctx, "crash-test-dummy", argsWt, stat, argF, cmdF, nil)
- })
+ testHelper(t, func(ctx context.Context, setOutput func(stdoutP, stderrP *io.Writer), stat bool) helper.Helper {
+ return helper.NewDirect(ctx, os.Args[0], argsWt, stat, argF, func(cmd *exec.Cmd) {
+ setOutput(&cmd.Stdout, &cmd.Stderr)
+ }, nil)
+ }, "exec")
})
}