mac seal test

This commit is contained in:
Andrew Jackson (Ajax) 2023-08-17 07:30:19 -05:00
parent b226a7dbff
commit 76bca6c392

View File

@ -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