diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-03-17 14:09:38 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-03-17 14:09:38 +0900 |
| commit | 1c2d5f6b57af2bb05759647d6e6ff1aa8ff47de0 (patch) | |
| tree | 559d1f042e456b34e14ee6fb08d34b6f8f26089a /container | |
| parent | faea1f4bd607263c59af8f228c97e9406ba482a7 (diff) | |
ext: integer limit values
For portably using C integers without cgo.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container')
| -rw-r--r-- | container/seccomp/std_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/container/seccomp/std_test.go b/container/seccomp/std_test.go index 026fef8b..93b5613c 100644 --- a/container/seccomp/std_test.go +++ b/container/seccomp/std_test.go @@ -26,7 +26,9 @@ func TestSyscallResolveName(t *testing.T) { func TestRuleType(t *testing.T) { assertKind[ext.Uint, scmpUint](t) + assertOverflow(t, ext.Uint(ext.MaxUint)) assertKind[ext.Int, scmpInt](t) + assertOverflow(t, ext.Int(ext.MaxInt)) assertSize[std.NativeRule, syscallRule](t) assertKind[std.ScmpDatum, scmpDatum](t) @@ -62,3 +64,14 @@ func assertKind[native, equivalent any](t *testing.T) { t.Fatalf("%s: %s, want %s", nativeType.Name(), nativeType.Kind(), equivalentType.Kind()) } } + +// assertOverflow asserts that incrementing m overflows. +func assertOverflow[T ~int32 | ~uint32](t *testing.T, m T) { + t.Helper() + + old := m + m++ + if m > old { + t.Fatalf("unexpected value %#x", m) + } +} |
