aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-04-07 14:44:34 +0900
committerOphestra <cat@gensokyo.uk>2026-04-07 14:44:34 +0900
commitd7d42c69a1de656692a6da14c40d2f34cfc46ded (patch)
tree6fa552d845c6f22dc1fc39921e855f482f1cf529 /internal
parentc758e762bd0334b6f86fbc41ab3223b9115e9982 (diff)
internal/pkg: transparently degrade landlock in tests
This does not test package container, so should transparently cope with Landlock LSM being unavailable. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
-rw-r--r--internal/pkg/pkg_test.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/internal/pkg/pkg_test.go b/internal/pkg/pkg_test.go
index 50e2a584..4fce4b1e 100644
--- a/internal/pkg/pkg_test.go
+++ b/internal/pkg/pkg_test.go
@@ -289,8 +289,17 @@ func checkWithCache(t *testing.T, testCases []cacheTestCase) {
msg := message.New(log.New(os.Stderr, "cache: ", 0))
msg.SwapVerbose(testing.Verbose())
+ flags := tc.flags
+ if _, err := container.LandlockGetABI(); err != nil {
+ if !errors.Is(err, syscall.ENOSYS) {
+ t.Fatalf("LandlockGetABI: error = %v", err)
+ }
+ flags |= pkg.CHostAbstract
+ t.Log("Landlock LSM is unavailable, setting CHostAbstract")
+ }
+
var scrubFunc func() error // scrub after hashing
- if c, err := pkg.Open(t.Context(), msg, tc.flags, 1<<4, base); err != nil {
+ if c, err := pkg.Open(t.Context(), msg, flags, 1<<4, base); err != nil {
t.Fatalf("Open: error = %v", err)
} else {
t.Cleanup(c.Close)