From 007b52d81fdc3f52af7e9de91999b291d2eac365 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 17 Mar 2025 12:51:21 +0900 Subject: [PATCH] sandbox/seccomp: check for both partial read outcomes This eliminates intermittent test failures. Signed-off-by: Ophestra --- sandbox/seccomp/export_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sandbox/seccomp/export_test.go b/sandbox/seccomp/export_test.go index 8dc88cb..5b23106 100644 --- a/sandbox/seccomp/export_test.go +++ b/sandbox/seccomp/export_test.go @@ -111,11 +111,14 @@ func TestExport(t *testing.T) { t.Run("close partial read", func(t *testing.T) { e := seccomp.New(0) - if _, err := e.Read(make([]byte, 0)); err != nil { + if _, err := e.Read(nil); err != nil { t.Errorf("Read: error = %v", err) return } - if err := e.Close(); err == nil || !errors.Is(err, syscall.ECANCELED) || !errors.Is(err, syscall.EBADF) { + // the underlying implementation uses buffered io, so the outcome of this is nondeterministic; + // that is not harmful however, so both outcomes are checked for here + if err := e.Close(); err != nil && + (!errors.Is(err, syscall.ECANCELED) || !errors.Is(err, syscall.EBADF)) { t.Errorf("Close: error = %v", err) return }