From d7d42c69a1de656692a6da14c40d2f34cfc46ded Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 7 Apr 2026 14:44:34 +0900 Subject: [PATCH] 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 --- internal/pkg/pkg_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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)