forked from security/hakurei
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user