diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-09-29 14:59:39 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-09-29 14:59:39 +0900 |
| commit | 3bf456da6593708823a967c4d88e4b0a816179dd (patch) | |
| tree | 24d3a98a2462ff1af42990d9c134c36e5ea975eb /helper/args_test.go | |
| parent | 61ba841c881b54fd3bc890b995a6d1cb1a39e532 (diff) | |
helper: test child process handling
The stub child process simulates reading from the argument fd and copies the entire payload unmodified to stdout. If status pipe is enabled it will simulate sync fd behaviour as well.
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'helper/args_test.go')
| -rw-r--r-- | helper/args_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/helper/args_test.go b/helper/args_test.go new file mode 100644 index 00000000..378c6dcc --- /dev/null +++ b/helper/args_test.go @@ -0,0 +1,29 @@ +package helper_test + +import ( + "errors" + "fmt" + "strings" + "testing" + + "git.ophivana.moe/cat/fortify/helper" +) + +func Test_argsFD_String(t *testing.T) { + argsOnce.Do(prepareArgs) + + wantString := strings.Join(want, " ") + if got := argsWt.(fmt.Stringer).String(); got != wantString { + t.Errorf("String(): got %v; want %v", + got, wantString) + } +} + +func TestNewCheckedArgs(t *testing.T) { + args := []string{"\x00"} + if _, err := helper.NewCheckedArgs(args); !errors.Is(err, helper.ErrContainsNull) { + t.Errorf("NewCheckedArgs(%q) error = %v, wantErr %v", + args, + err, helper.ErrContainsNull) + } +} |
