Merge pull request #5043 from lifubang/backport-5014-fd-leaks-flake-1.2

[1.2] libct/int: TestFdLeaks: deflake
This commit is contained in:
Kir Kolyshkin
2025-11-26 17:58:27 -08:00
committed by GitHub
+7 -2
View File
@@ -9,6 +9,7 @@ import (
"os/exec"
"path/filepath"
"reflect"
"slices"
"strconv"
"strings"
"syscall"
@@ -1704,7 +1705,11 @@ func fdList(t *testing.T) []string {
fds, err := fdDir.Readdirnames(-1)
ok(t, err)
return fds
// Remove the fdDir fd.
extraFd := strconv.Itoa(int(fdDir.Fd()))
return slices.DeleteFunc(fds, func(fd string) bool {
return fd == extraFd
})
}
func testFdLeaks(t *testing.T, systemd bool) {
@@ -1726,7 +1731,7 @@ func testFdLeaks(t *testing.T, systemd bool) {
_ = runContainerOk(t, config, "true")
fds1 := fdList(t)
if reflect.DeepEqual(fds0, fds1) {
if slices.Equal(fds0, fds1) {
return
}
// Show the extra opened files.