Skip to content

Commit

Permalink
safesocket: create the test socket in a temp dir
Browse files Browse the repository at this point in the history
This allows the test to be run inside a mounted filesystem,
which I'm doing now as a I develop on a linux VM.

Fixes #2367.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
  • Loading branch information
josharian committed Jul 8, 2021
1 parent 254fc78 commit 7a08c15
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions safesocket/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ package safesocket

import (
"fmt"
"path/filepath"
"testing"
)

func TestBasics(t *testing.T) {
l, port, err := Listen("test", 0)
// Make the socket in a temp dir rather than the cwd
// so that the test can be run from a mounted filesystem (#2367).
dir := t.TempDir()
sock := filepath.Join(dir, "test")

l, port, err := Listen(sock, 0)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -42,7 +48,7 @@ func TestBasics(t *testing.T) {
}()

go func() {
c, err := Connect("test", port)
c, err := Connect(sock, port)
if err != nil {
errs <- err
return
Expand Down

0 comments on commit 7a08c15

Please sign in to comment.