aports/community/tailscale/test-atomicfile-use-tmpdir.patch
Kevin Daudt 1669f230df community/tailscale: fix atomicfile_test with GOTMPDIR set
Due to us setting GOTMPDIR, the filepath for a socket becomes too large.
2026-03-04 17:17:03 +00:00

41 lines
1.3 KiB
Diff

The test tries to create a unix socket in GOTMPDIR, and fails with
'bind: invalid argument'. This is because tha max file path for a unix
socket is [108 characters][0].
We set GOTMPDIR to be located in $srcdir, which causes the filepath to become
>108 characters.
Force the test to use `/tmp` dir to make sure the path length does not
become too large.
[0]: https://man7.org/linux/man-pages/man7/unix.7.html
diff --git a/atomicfile/atomicfile_test.go b/atomicfile/atomicfile_test.go
index a081c90..f4b85db 100644
--- a/atomicfile/atomicfile_test.go
+++ b/atomicfile/atomicfile_test.go
@@ -9,7 +9,6 @@
"net"
"os"
"path/filepath"
- "runtime"
"strings"
"testing"
)
@@ -21,13 +20,9 @@ func TestDoesNotOverwriteIrregularFiles(t *testing.T) {
const filename = "TestDoesNotOverwriteIrregularFiles"
var path string
- // macOS private temp does not allow unix socket creation, but /tmp does.
- if runtime.GOOS == "darwin" {
- path = filepath.Join("/tmp", filename)
- t.Cleanup(func() { os.Remove(path) })
- } else {
- path = filepath.Join(t.TempDir(), filename)
- }
+
+ path = filepath.Join("/tmp", filename)
+ t.Cleanup(func() { os.Remove(path) })
// The least troublesome thing to make that is not a file is a unix socket.
// Making a null device sadly requires root.