@@ -71,8 +71,12 @@ func TestDefaultHost_XDGRuntimeDir(t *testing.T) {
71 path := strings.TrimPrefix(host, "unix://")
71 path := strings.TrimPrefix(host, "unix://")
73 // The composed path may exceed maxUnixSocketPathLen and fall back
73 // The composed path may exceed maxUnixSocketPathLen and fall back
74− // to /tmp; only assert containment when it did not.
74+ // to /tmp; only assert containment when it did not. Recompose the
75+ // path under dir (rather than checking the returned path length,
76+ // which is short again after a /tmp fallback) to decide whether a
77+ // fallback happened. The socket is named crush-<uid>.sock.
78+ composed := filepath.Join(dir, filepath.Base(path))
75− if len(filepath.Join(dir, "crush.sock")) <= maxUnixSocketPathLen {
79+ if len(composed) <= maxUnixSocketPathLen {
76 require.True(t, strings.HasPrefix(path, dir),
80 require.True(t, strings.HasPrefix(path, dir),
77 "socket path %q should live under %q", path, dir)
81 "socket path %q should live under %q", path, dir)
@@ -104,7 +108,7 @@ func TestDefaultHost_FallbackTemp(t *testing.T) {
104// it. A leftover file is best-effort removed via t.Cleanup.
108// it. A leftover file is best-effort removed via t.Cleanup.
105func staleSocketPath(t *testing.T, path string) {
109func staleSocketPath(t *testing.T, path string) {
106 t.Helper()
110 t.Helper()
107− ln, err := net.Listen("unix", path)
111+ ln, err := net.Listen("unix", path) //nolint:noctx
108 require.NoError(t, err)
112 require.NoError(t, err)
109 ul, ok := ln.(*net.UnixListener)
113 ul, ok := ln.(*net.UnixListener)
110 require.True(t, ok, "expected *net.UnixListener, got %T", ln)
114 require.True(t, ok, "expected *net.UnixListener, got %T", ln)
@@ -112,7 +116,7 @@ func staleSocketPath(t *testing.T, path string) {
112 require.NoError(t, ul.Close())
116 require.NoError(t, ul.Close())
114 // Verify it is actually stale: dialing should fail.
118 // Verify it is actually stale: dialing should fail.
115− conn, dialErr := net.DialTimeout("unix", path, 200*time.Millisecond)
119+ conn, dialErr := net.DialTimeout("unix", path, 200*time.Millisecond) //nolint:noctx
116 if dialErr == nil {
120 if dialErr == nil {
117 conn.Close()
121 conn.Close()
118 t.Fatalf("expected stale socket at %q to refuse connections", path)
122 t.Fatalf("expected stale socket at %q to refuse connections", path)
@@ -150,7 +154,7 @@ func TestListen_LiveSocketNotRemoved(t *testing.T) {
150 dir := t.TempDir()
154 dir := t.TempDir()
151 path := filepath.Join(dir, "s.sock")
155 path := filepath.Join(dir, "s.sock")
153− ln1, err := net.Listen("unix", path)
157+ ln1, err := net.Listen("unix", path) //nolint:noctx
154 require.NoError(t, err)
158 require.NoError(t, err)
156 // Drain accepts so the listener stays alive and responsive without
160 // Drain accepts so the listener stays alive and responsive without
@@ -183,7 +187,7 @@ func TestListen_LiveSocketNotRemoved(t *testing.T) {
183 // The live socket file must still be on disk and dialable.
187 // The live socket file must still be on disk and dialable.
184 _, statErr := os.Stat(path)
188 _, statErr := os.Stat(path)
185 require.NoError(t, statErr, "live socket file should still exist")
189 require.NoError(t, statErr, "live socket file should still exist")
186− conn, dialErr := net.DialTimeout("unix", path, 200*time.Millisecond)
190+ conn, dialErr := net.DialTimeout("unix", path, 200*time.Millisecond) //nolint:noctx
187 require.NoError(t, dialErr, "live socket should still accept dials")
191 require.NoError(t, dialErr, "live socket should still accept dials")
188 _ = conn.Close()
192 _ = conn.Close()