container/seccomp: alias libseccomp types

This enables tests to refer to these types and check its size.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-11-05 05:04:56 +09:00
parent becaf8b6d7
commit b65aba9446
2 changed files with 52 additions and 25 deletions

View File

@@ -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)
}
}