tempSocketPath returns a temporary socket path short enough to avoid exceeding Unix-domain socket path length limits on some platforms.
(t *testing.T)
| 14 | // tempSocketPath returns a temporary socket path short enough to avoid |
| 15 | // exceeding Unix-domain socket path length limits on some platforms. |
| 16 | func 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 | |
| 37 | func runTest(t *testing.T, path string, l net.Listener, echoStr string) { |
| 38 | go func() { |
no test coverage detected