aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/sandbox/tool/main.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-03-30 21:09:16 +0900
committerOphestra <cat@gensokyo.uk>2025-03-30 21:09:16 +0900
commit89a05909a4fb393864a8aa752f6979dd9aaa2898 (patch)
treeac6a0e6e25d7fdeada94bedb45c684aa5b912b73 /test/sandbox/tool/main.go
parentf772940768d9cada256f8f3291a3b9e9685003c3 (diff)
test: move test program to sandbox directory
This prepares for the separation of app and sandbox tests. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'test/sandbox/tool/main.go')
-rw-r--r--test/sandbox/tool/main.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/sandbox/tool/main.go b/test/sandbox/tool/main.go
new file mode 100644
index 00000000..4c639b28
--- /dev/null
+++ b/test/sandbox/tool/main.go
@@ -0,0 +1,39 @@
+package main
+
+import (
+ "log"
+ "os"
+ "strconv"
+ "strings"
+
+ "git.gensokyo.uk/security/fortify/test/sandbox"
+)
+
+func main() {
+ log.SetFlags(0)
+ log.SetPrefix("test: ")
+
+ if len(os.Args) < 2 {
+ log.Fatal("invalid argument")
+ }
+
+ switch os.Args[1] {
+ case "filter":
+ if len(os.Args) != 4 {
+ log.Fatal("invalid argument")
+ }
+
+ if pid, err := strconv.Atoi(strings.TrimSpace(os.Args[2])); err != nil {
+ log.Fatalf("%s", err)
+ } else if pid < 1 {
+ log.Fatalf("%d out of range", pid)
+ } else {
+ sandbox.MustCheckFilter(pid, os.Args[3])
+ return
+ }
+
+ default:
+ (&sandbox.T{FS: os.DirFS("/")}).MustCheckFile(os.Args[1], "/tmp/sandbox-ok")
+ return
+ }
+}