diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-03-17 12:51:21 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-03-17 12:51:21 +0900 |
| commit | 007b52d81fdc3f52af7e9de91999b291d2eac365 (patch) | |
| tree | 560abc36ea9f615480c228ec98db86165c7fd16b /sandbox | |
| parent | 33855381422932a208fa412bd4a96c0905aafdf1 (diff) | |
sandbox/seccomp: check for both partial read outcomes
This eliminates intermittent test failures.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'sandbox')
| -rw-r--r-- | sandbox/seccomp/export_test.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sandbox/seccomp/export_test.go b/sandbox/seccomp/export_test.go index 8dc88cbb..5b23106f 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 } |
