Skip to content

Commit 7e5d01e

Browse files
authored
Merge pull request #5043 from lifubang/backport-5014-fd-leaks-flake-1.2
[1.2] libct/int: TestFdLeaks: deflake
2 parents 0675ec8 + 0c910b9 commit 7e5d01e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

libcontainer/integration/exec_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"os/exec"
1010
"path/filepath"
1111
"reflect"
12+
"slices"
1213
"strconv"
1314
"strings"
1415
"syscall"
@@ -1704,7 +1705,11 @@ func fdList(t *testing.T) []string {
17041705
fds, err := fdDir.Readdirnames(-1)
17051706
ok(t, err)
17061707

1707-
return fds
1708+
// Remove the fdDir fd.
1709+
extraFd := strconv.Itoa(int(fdDir.Fd()))
1710+
return slices.DeleteFunc(fds, func(fd string) bool {
1711+
return fd == extraFd
1712+
})
17081713
}
17091714

17101715
func testFdLeaks(t *testing.T, systemd bool) {
@@ -1726,7 +1731,7 @@ func testFdLeaks(t *testing.T, systemd bool) {
17261731
_ = runContainerOk(t, config, "true")
17271732
fds1 := fdList(t)
17281733

1729-
if reflect.DeepEqual(fds0, fds1) {
1734+
if slices.Equal(fds0, fds1) {
17301735
return
17311736
}
17321737
// Show the extra opened files.

0 commit comments

Comments
 (0)