MCPcopy Create free account
hub / github.com/docker/go-connections / tempSocketPath

Function tempSocketPath

sockets/unix_socket_test.go:16–35  ·  view source on GitHub ↗

tempSocketPath returns a temporary socket path short enough to avoid exceeding Unix-domain socket path length limits on some platforms.

(t *testing.T)

Source from the content-addressed store, hash-verified

14// tempSocketPath returns a temporary socket path short enough to avoid
15// exceeding Unix-domain socket path length limits on some platforms.
16func tempSocketPath(t *testing.T) string {
17 t.Helper()
18
19 f, err := os.CreateTemp("", "test*.sock")
20 if err != nil {
21 t.Fatal(err)
22 }
23 _ = f.Close()
24
25 path := f.Name()
26 t.Cleanup(func() { _ = os.Remove(path) })
27 if len(path) >= maxSocketPathLen {
28 t.Fatalf("temporary socket path too long (%d >= %d): %q", len(path), maxSocketPathLen, path)
29 }
30 // Remove the temporary file; we only need a unique path / name.
31 if err := os.Remove(path); err != nil {
32 t.Fatal(err)
33 }
34 return path
35}
36
37func runTest(t *testing.T, path string, l net.Listener, echoStr string) {
38 go func() {

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected