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
This commit is contained in:
parent
5a1ebdb4f7
commit
4f2feb1be7
@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -187,16 +186,22 @@ func TestEnoent(t *testing.T) {
|
|||||||
// returning an I/O error to the user.
|
// returning an I/O error to the user.
|
||||||
// https://github.com/rfjakob/gocryptfs/issues/167
|
// https://github.com/rfjakob/gocryptfs/issues/167
|
||||||
func TestTooLongSymlink(t *testing.T) {
|
func TestTooLongSymlink(t *testing.T) {
|
||||||
l := 4000
|
var err error
|
||||||
if runtime.GOOS == "darwin" {
|
var l int
|
||||||
l = 1000 // max length is much lower on darwin
|
|
||||||
}
|
|
||||||
fn := dirA + "/TooLongSymlink"
|
fn := dirA + "/TooLongSymlink"
|
||||||
target := string(bytes.Repeat([]byte("x"), l))
|
// Try 4000 first (works on ext4 and tmpfs), then retry with 1000 (XFS and
|
||||||
err := os.Symlink(target, fn)
|
// 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 {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
t.Logf("Created symlink of length %d", l)
|
||||||
_, err = os.Readlink(dirC + "/TooLongSymlink")
|
_, err = os.Readlink(dirC + "/TooLongSymlink")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user