aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/seccomp/syscall_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-05 06:00:39 +0900
committerOphestra <cat@gensokyo.uk>2025-11-05 06:00:39 +0900
commitfba201c9953a490da914b09e09eaaa697a4b36e1 (patch)
tree9aa54e81577b6e3e580176f266d70a286ed52d9e /container/seccomp/syscall_test.go
parent7f27a6dc5173bc6c4b71918b98a2d6b72bd37d30 (diff)
container/std: relocate rule types
This enables its use in hst for #15. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/seccomp/syscall_test.go')
-rw-r--r--container/seccomp/syscall_test.go63
1 files changed, 0 insertions, 63 deletions
diff --git a/container/seccomp/syscall_test.go b/container/seccomp/syscall_test.go
deleted file mode 100644
index 98076cf3..00000000
--- a/container/seccomp/syscall_test.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package seccomp
-
-import (
- "reflect"
- "testing"
- "unsafe"
-
- "hakurei.app/container/std"
-)
-
-func TestSyscallResolveName(t *testing.T) {
- t.Parallel()
-
- for name, want := range std.Syscalls() {
- t.Run(name, func(t *testing.T) {
- t.Parallel()
-
- // this checks the std implementation against libseccomp.
- if got, ok := syscallResolveName(name); !ok || got != want {
- t.Errorf("syscallResolveName(%q) = %d, want %d", name, got, want)
- }
- })
- }
-}
-
-func TestRuleType(t *testing.T) {
- assertKind[ScmpUint, scmpUint](t)
- assertKind[ScmpInt, scmpInt](t)
-
- assertSize[NativeRule, syscallRule](t)
- assertKind[ScmpDatum, scmpDatum](t)
- assertKind[ScmpCompare, scmpCompare](t)
- assertSize[ScmpArgCmp, scmpArgCmp](t)
-}
-
-// assertSize asserts that native and equivalent are of the same size.
-func assertSize[native, equivalent any](t *testing.T) {
- t.Helper()
-
- got, want := unsafe.Sizeof(*new(native)), unsafe.Sizeof(*new(equivalent))
- if got != want {
- t.Fatalf("%s: %d, want %d", reflect.TypeFor[native]().Name(), got, want)
- }
-}
-
-// assertKind asserts that native and equivalent are of the same kind.
-func assertKind[native, equivalent any](t *testing.T) {
- t.Helper()
-
- assertSize[native, equivalent](t)
- nativeType, equivalentType := reflect.TypeFor[native](), reflect.TypeFor[equivalent]()
- got, want := nativeType.Kind(), equivalentType.Kind()
-
- if got == reflect.Invalid || want == reflect.Invalid {
- t.Fatalf("%s: invalid call to assertKind", nativeType.Name())
- }
- if got == reflect.Struct {
- t.Fatalf("%s: struct is unsupported by assertKind", nativeType.Name())
- }
- if got != want {
- t.Fatalf("%s: %s, want %s", nativeType.Name(), nativeType.Kind(), equivalentType.Kind())
- }
-}