-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
What version of Go are you using (go version)?
Go 1.21
darwin/arm64
What did you do?
I renamed a test to make it more descriptive (longer) and then my test failed:
integration_test.go:879: sockFile path "/var/folders/0f/7sz95dc94nj46b6yz8p_fqd40000gn/T/TestIncrementalMapUpdatePeersRemoved1080118162/001/tailscale.sock" (len 114) is too long, must be < 104
Turns out darwin, openbsd, and freebsd at least limit the length of a unix socket to 104 bytes.
Because os.TempDir on darwin is a long user-specific thing (e.g. /var/folders/0f/7sz95dc94nj46b6yz8p_fqd40000gn/) and testing.TB.TempDir includes the test name and some suffix (TestIncrementalMapUpdatePeersRemoved1080118162), by the time those are all concatenated, you're out of space for a unix socket filename that fits in 104 bytes.
Apparently @josharian discovered this two years ago in tailscale/tailscale@f80193f where I approved a rename to make test names shorter but it didn't cross my mind to file this bug until I just hit it again now.
I ended up working around it by:
dir := t.TempDir()
sockFile := filepath.Join(dir, "tailscale.sock")
if len(sockFile) >= 104 {
// Maximum length for a unix socket on darwin. Try something else.
sockFile = filepath.Join(os.TempDir(), rands.HexString(8)+".sock")
t.Cleanup(func() { os.Remove(sockFile) })
}But that's a little gross.
What did you expect to see?
Operating systems to be less annoying. Failing that, maybe the testing package could help work around it somehow?
What did you see instead?
Failure to make a unix socket in a test.