aboutsummaryrefslogtreecommitdiffhomepage
path: root/helper/seccomp/seccomp_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-03-14 22:42:40 +0900
committerOphestra <cat@gensokyo.uk>2025-03-14 22:42:40 +0900
commit2647a71be1f287e50011a65653b9e9c806627899 (patch)
tree252dd8865632df348b7573ca6f31c04e4cb6c9e5 /helper/seccomp/seccomp_test.go
parent7c60a4d8e8baa77b42789c041838fa82dd7d36f9 (diff)
seccomp: move out of helper
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'helper/seccomp/seccomp_test.go')
-rw-r--r--helper/seccomp/seccomp_test.go65
1 files changed, 0 insertions, 65 deletions
diff --git a/helper/seccomp/seccomp_test.go b/helper/seccomp/seccomp_test.go
deleted file mode 100644
index c04179c1..00000000
--- a/helper/seccomp/seccomp_test.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package seccomp_test
-
-import (
- "errors"
- "runtime"
- "syscall"
- "testing"
-
- "git.gensokyo.uk/security/fortify/helper/seccomp"
-)
-
-func TestLibraryError(t *testing.T) {
- testCases := []struct {
- name string
- sample *seccomp.LibraryError
- want string
- wantIs bool
- compare error
- }{
- {
- "full",
- &seccomp.LibraryError{Prefix: "seccomp_export_bpf failed", Seccomp: syscall.ECANCELED, Errno: syscall.EBADF},
- "seccomp_export_bpf failed: operation canceled (bad file descriptor)",
- true,
- &seccomp.LibraryError{Prefix: "seccomp_export_bpf failed", Seccomp: syscall.ECANCELED, Errno: syscall.EBADF},
- },
- {
- "errno only",
- &seccomp.LibraryError{Prefix: "seccomp_init failed", Errno: syscall.ENOMEM},
- "seccomp_init failed: cannot allocate memory",
- false,
- nil,
- },
- {
- "seccomp only",
- &seccomp.LibraryError{Prefix: "internal libseccomp failure", Seccomp: syscall.EFAULT},
- "internal libseccomp failure: bad address",
- true,
- syscall.EFAULT,
- },
- }
- for _, tc := range testCases {
- t.Run(tc.name, func(t *testing.T) {
- if errors.Is(tc.sample, tc.compare) != tc.wantIs {
- t.Errorf("errors.Is(%#v, %#v) did not return %v",
- tc.sample, tc.compare, tc.wantIs)
- }
-
- if got := tc.sample.Error(); got != tc.want {
- t.Errorf("Error: %q, want %q",
- got, tc.want)
- }
- })
- }
-
- t.Run("invalid", func(t *testing.T) {
- wantPanic := "invalid libseccomp error"
- defer func() {
- if r := recover(); r != wantPanic {
- t.Errorf("panic: %q, want %q", r, wantPanic)
- }
- }()
- runtime.KeepAlive(new(seccomp.LibraryError).Error())
- })
-}