From 4f2feb1be7530d4fca7061b89d61f3ffc5761a0b Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 10 Oct 2018 22:38:22 +0200 Subject: tests: catch "name too long" symlink failure on XFS Retry with length 1000 if length 4000 fails, which should work on all filesystems. Failure was: --- FAIL: TestTooLongSymlink (0.00s) correctness_test.go:198: symlink xxx[...]xxxx /tmp/xfs.mnt/gocryptfs-test-parent/549823072/365091391/TooLongSymlink: file name too long https://github.com/rfjakob/gocryptfs/issues/267 --- tests/reverse/correctness_test.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/reverse/correctness_test.go b/tests/reverse/correctness_test.go index 62e3bbc..246936b 100644 --- a/tests/reverse/correctness_test.go +++ b/tests/reverse/correctness_test.go @@ -5,7 +5,6 @@ import ( "fmt" "io/ioutil" "os" - "runtime" "syscall" "testing" @@ -187,16 +186,22 @@ func TestEnoent(t *testing.T) { // returning an I/O error to the user. // https://github.com/rfjakob/gocryptfs/issues/167 func TestTooLongSymlink(t *testing.T) { - l := 4000 - if runtime.GOOS == "darwin" { - l = 1000 // max length is much lower on darwin - } + var err error + var l int fn := dirA + "/TooLongSymlink" - target := string(bytes.Repeat([]byte("x"), l)) - err := os.Symlink(target, fn) + // Try 4000 first (works on ext4 and tmpfs), then retry with 1000 (XFS and + // Darwin have a limit of about 1024) + for _, l = range []int{4000, 1000} { + target := string(bytes.Repeat([]byte("x"), l)) + err = os.Symlink(target, fn) + if err == nil { + break + } + } if err != nil { t.Fatal(err) } + t.Logf("Created symlink of length %d", l) _, err = os.Readlink(dirC + "/TooLongSymlink") if err == nil { return -- cgit v1.2.3