Skip to content

Commit

Permalink
chore: tests: fix failures on recent macos
Browse files Browse the repository at this point in the history
On modern darwin os.ReadDir("/dev/fd") always results in an error. Because of
this storage/sealer/ffiwrapper/sealer_test.go invariably fails.

Instead of fixing the FD enumerator, remove the check entirely, as it has been
disabled since https://github.com/filecoin-project/lotus/pull/7420/files
  • Loading branch information
ribasushi authored and rvagg committed Sep 2, 2024
1 parent 4a4ddaa commit e31e4e8
Showing 1 changed file with 0 additions and 70 deletions.
70 changes: 0 additions & 70 deletions storage/sealer/ffiwrapper/sealer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@ func getGrothParamFileAndVerifyingKeys(s abi.SectorSize) {
//
// go test -run=^TestDownloadParams
func TestDownloadParams(t *testing.T) {
// defer requireFDsClosed(t, openFDs(t)) flaky likely cause of how go-embed works with param files

getGrothParamFileAndVerifyingKeys(sectorSize)
}

Expand All @@ -288,8 +286,6 @@ func TestSealAndVerify(t *testing.T) {
t.Skip("skipping test in short mode")
}

defer requireFDsClosed(t, openFDs(t))

if runtime.NumCPU() < 10 && os.Getenv("CI") == "" { // don't bother on slow hardware
t.Skip("this is slow")
}
Expand Down Expand Up @@ -359,8 +355,6 @@ func TestSealPoStNoCommit(t *testing.T) {
t.Skip("skipping test in short mode")
}

defer requireFDsClosed(t, openFDs(t))

if runtime.NumCPU() < 10 && os.Getenv("CI") == "" { // don't bother on slow hardware
t.Skip("this is slow")
}
Expand Down Expand Up @@ -434,8 +428,6 @@ func TestSealAndVerify3(t *testing.T) {
t.Skip("skipping test in short mode")
}

defer requireFDsClosed(t, openFDs(t))

if runtime.NumCPU() < 10 && os.Getenv("CI") == "" { // don't bother on slow hardware
t.Skip("this is slow")
}
Expand Down Expand Up @@ -510,8 +502,6 @@ func TestSealAndVerifyAggregate(t *testing.T) {
t.Skip("skipping test in short mode")
}

defer requireFDsClosed(t, openFDs(t))

if runtime.NumCPU() < 10 && os.Getenv("CI") == "" { // don't bother on slow hardware
t.Skip("this is slow")
}
Expand Down Expand Up @@ -609,62 +599,6 @@ func BenchmarkWriteWithAlignment(b *testing.B) {
}
}

func openFDs(t *testing.T) int {
path := "/proc/self/fd"
if runtime.GOOS == "darwin" {
path = "/dev/fd"
}
dent, err := os.ReadDir(path)
if err != nil && !strings.Contains(err.Error(), "/dev/fd/3: bad file descriptor") {
require.NoError(t, err)
}

var skip int
for _, info := range dent {
l, err := os.Readlink(filepath.Join(path, info.Name()))
if err != nil {
continue
}

if strings.HasPrefix(l, "/dev/nvidia") {
skip++
}

if strings.HasPrefix(l, "/var/tmp/filecoin-proof-parameters/") {
skip++
}
}

return len(dent) - skip
}

func requireFDsClosed(t *testing.T, start int) {
openNow := openFDs(t)

if start != openNow {
path := "/proc/self/fd"
if runtime.GOOS == "darwin" {
path = "/dev/fd"
}
dent, err := os.ReadDir(path)
require.NoError(t, err)

for _, info := range dent {
l, err := os.Readlink(filepath.Join(path, info.Name()))
if err != nil {
fmt.Printf("FD err %s\n", err)
continue
}

fmt.Printf("FD %s -> %s\n", info.Name(), l)
}
}

log.Infow("open FDs", "start", start, "now", openNow)
// todo make work with cuda somehow
// require.Equal(t, start, openNow, "FDs shouldn't leak")
}

func TestGenerateUnsealedCID(t *testing.T) {
pt := abi.RegisteredSealProof_StackedDrg2KiBV1
ups := int(abi.PaddedPieceSize(2048).Unpadded())
Expand Down Expand Up @@ -1106,8 +1040,6 @@ func TestSealAndVerifySynth(t *testing.T) {
t.Skip("skipping test in short mode")
}

defer requireFDsClosed(t, openFDs(t))

if runtime.NumCPU() < 10 && os.Getenv("CI") == "" { // don't bother on slow hardware
t.Skip("this is slow")
}
Expand Down Expand Up @@ -1226,8 +1158,6 @@ func TestSealCommDRInGo(t *testing.T) {
t.Skip("skipping test in short mode")
}

defer requireFDsClosed(t, openFDs(t))

cdir, err := os.MkdirTemp("", "sbtest-c-")
require.NoError(t, err)
miner := abi.ActorID(123)
Expand Down

0 comments on commit e31e4e8

Please sign in to comment.