Skip to content

Commit

Permalink
Merge pull request #11180 from filecoin-project/macSealTest
Browse files Browse the repository at this point in the history
mac seal test
  • Loading branch information
magik6k authored Aug 17, 2023
2 parents 8092858 + 76bca6c commit 23cd583
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions storage/sealer/ffiwrapper/sealer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,12 +595,18 @@ func BenchmarkWriteWithAlignment(b *testing.B) {
}

func openFDs(t *testing.T) int {
dent, err := os.ReadDir("/proc/self/fd")
require.NoError(t, err)
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("/proc/self/fd", info.Name()))
l, err := os.Readlink(filepath.Join(path, info.Name()))
if err != nil {
continue
}
Expand All @@ -621,11 +627,15 @@ func requireFDsClosed(t *testing.T, start int) {
openNow := openFDs(t)

if start != openNow {
dent, err := os.ReadDir("/proc/self/fd")
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("/proc/self/fd", info.Name()))
l, err := os.Readlink(filepath.Join(path, info.Name()))
if err != nil {
fmt.Printf("FD err %s\n", err)
continue
Expand Down

0 comments on commit 23cd583

Please sign in to comment.