Adding upstream version 1.34.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e393c3af3f
commit
4978089aab
4963 changed files with 677545 additions and 0 deletions
32
testutil/socket.go
Normal file
32
testutil/socket.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package testutil
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TempSocket(tb testing.TB) string {
|
||||
// On MacOS, the maximum path length of Unix domain socket is 104
|
||||
// characters. (https://unix.stackexchange.com/a/367012/376279)
|
||||
//
|
||||
// On MacOS, tb.TempDir() returns e.g.
|
||||
// /var/folders/bl/wbxjgtzx7j5_mjsmfr3ynlc00000gp/T/<the-test-name>/001/socket.sock
|
||||
//
|
||||
// If the name of the test is long, the path length could exceed 104
|
||||
// characters, and this would result in listen unix ...: bind: invalid argument
|
||||
if runtime.GOOS == "darwin" {
|
||||
sock := "/tmp/sock"
|
||||
|
||||
tb.Cleanup(func() {
|
||||
require.NoError(tb, os.RemoveAll(sock))
|
||||
})
|
||||
|
||||
return sock
|
||||
}
|
||||
|
||||
return filepath.Join(tb.TempDir(), "sock")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue