Skip to content

Commit

Permalink
mac seal test
Browse files Browse the repository at this point in the history
  • Loading branch information
snadrus committed Aug 17, 2023
1 parent b226a7d commit 76bca6c
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 76bca6c

Please sign in to comment.