All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m14s
Test / Hakurei (push) Successful in 3m18s
Test / Hpkg (push) Successful in 4m6s
Test / Sandbox (race detector) (push) Successful in 4m20s
Test / Hakurei (race detector) (push) Successful in 5m2s
Test / Flake checks (push) Successful in 1m29s
This enables tests to refer to these types and check its size. Signed-off-by: Ophestra <cat@gensokyo.uk>
40 lines
910 B
Go
40 lines
910 B
Go
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 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)
|
|
}
|
|
}
|