diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-11-05 05:04:56 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-11-05 05:21:43 +0900 |
| commit | b65aba94467e9d8f3400c3e3de5f403e82bc99e7 (patch) | |
| tree | f5e36784fd7209b9b57ec82a4025f06e8506db50 /container/seccomp/syscall_test.go | |
| parent | becaf8b6d7151971907ff65f338afa038f021c92 (diff) | |
container/seccomp: alias libseccomp types
This enables tests to refer to these types and check its size.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/seccomp/syscall_test.go')
| -rw-r--r-- | container/seccomp/syscall_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
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) + } +} |
