From 76bca6c3922b25adfb58b7ab38879c57c959a9fc Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Thu, 17 Aug 2023 07:30:19 -0500 Subject: [PATCH] mac seal test --- storage/sealer/ffiwrapper/sealer_test.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/storage/sealer/ffiwrapper/sealer_test.go b/storage/sealer/ffiwrapper/sealer_test.go index 4d3b1a9be03..f109eed2736 100644 --- a/storage/sealer/ffiwrapper/sealer_test.go +++ b/storage/sealer/ffiwrapper/sealer_test.go @@ -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 } @@ -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