package thin import ( "context" "fmt" "net" "os" "path/filepath" "strings" "testing" ) // The coordinator's tool socket opens whatever the state directory's // length: a Unix socket path holds 107 bytes, and the staging suite's // state under a long TMPDIR failed most coordinator starts (2026-11-22). func TestToolSocketUnderLongStateDir(t *testing.T) { root := filepath.Join(t.TempDir(), strings.Repeat("s", 100)) if err := os.Mkdir(root, 0700); err != nil { t.Fatal(err) } for i := 0; i < 20; i++ { s, err := openToolSet(context.Background(), root, converseSet(false), nil) if err != nil { t.Fatalf("open %d: %v", i, err) } info, err := os.Lstat(s.Path) if err != nil || info.Mode()&os.ModeSocket == 0 || info.Mode().Perm() != 0600 || filepath.Base(s.Path) != "equipo.sock" || filepath.Dir(filepath.Dir(s.Path)) != root { t.Fatalf("socket %s: %v %v", s.Path, info, err) } dir, err := os.Open(filepath.Dir(s.Path)) if err != nil { t.Fatal(err) } conn, err := net.Dial("unix", fmt.Sprintf("/proc/self/fd/%d/equipo.sock", dir.Fd())) dir.Close() if err != nil { t.Fatalf("dial %d: %v", i, err) } conn.Close() s.Close() } }