@@ -71,8 +71,12 @@ func TestDefaultHost_XDGRuntimeDir(t *testing.T) {
7171 path := strings .TrimPrefix (host , "unix://" )
7272
7373 // The composed path may exceed maxUnixSocketPathLen and fall back
74- // to /tmp; only assert containment when it did not.
75- if len (filepath .Join (dir , "crush.sock" )) <= maxUnixSocketPathLen {
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 ))
79+ if len (composed ) <= maxUnixSocketPathLen {
7680 require .True (t , strings .HasPrefix (path , dir ),
7781 "socket path %q should live under %q" , path , dir )
7882 }
@@ -104,15 +108,15 @@ func TestDefaultHost_FallbackTemp(t *testing.T) {
104108// it. A leftover file is best-effort removed via t.Cleanup.
105109func staleSocketPath (t * testing.T , path string ) {
106110 t .Helper ()
107- ln , err := net .Listen ("unix" , path )
111+ ln , err := net .Listen ("unix" , path ) //nolint:noctx
108112 require .NoError (t , err )
109113 ul , ok := ln .(* net.UnixListener )
110114 require .True (t , ok , "expected *net.UnixListener, got %T" , ln )
111115 ul .SetUnlinkOnClose (false )
112116 require .NoError (t , ul .Close ())
113117
114118 // 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
116120 if dialErr == nil {
117121 conn .Close ()
118122 t .Fatalf ("expected stale socket at %q to refuse connections" , path )
@@ -150,7 +154,7 @@ func TestListen_LiveSocketNotRemoved(t *testing.T) {
150154 dir := t .TempDir ()
151155 path := filepath .Join (dir , "s.sock" )
152156
153- ln1 , err := net .Listen ("unix" , path )
157+ ln1 , err := net .Listen ("unix" , path ) //nolint:noctx
154158 require .NoError (t , err )
155159
156160 // Drain accepts so the listener stays alive and responsive without
@@ -183,7 +187,7 @@ func TestListen_LiveSocketNotRemoved(t *testing.T) {
183187 // The live socket file must still be on disk and dialable.
184188 _ , statErr := os .Stat (path )
185189 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
187191 require .NoError (t , dialErr , "live socket should still accept dials" )
188192 _ = conn .Close ()
189193}
0 commit comments