From b65aba94467e9d8f3400c3e3de5f403e82bc99e7 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Wed, 5 Nov 2025 05:04:56 +0900 Subject: container/seccomp: alias libseccomp types This enables tests to refer to these types and check its size. Signed-off-by: Ophestra --- container/seccomp/syscall_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'container/seccomp/syscall_test.go') diff --git a/container/seccomp/syscall_test.go b/container/seccomp/syscall_test.go index 57a73265..151f6321 100644 --- a/container/seccomp/syscall_test.go +++ b/container/seccomp/syscall_test.go @@ -1,7 +1,9 @@ package seccomp import ( + "reflect" "testing" + "unsafe" "hakurei.app/container/std" ) @@ -20,3 +22,18 @@ func TestSyscallResolveName(t *testing.T) { }) } } + +func TestRuleSize(t *testing.T) { + assertSize[NativeRule, syscallRule](t) + assertSize[ScmpDatum, scmpDatum](t) + assertSize[ScmpArgCmp, scmpArgCmp](t) +} + +// assertSize asserts that native and equivalent are of the same size. +func assertSize[native, equivalent any](t *testing.T) { + got := unsafe.Sizeof(*new(native)) + want := unsafe.Sizeof(*new(equivalent)) + if got != want { + t.Fatalf("%s: %d, want %d", reflect.TypeFor[native]().Name(), got, want) + } +} -- cgit v1.3.1