summaryrefslogtreecommitdiff
path: root/integration_tests
diff options
context:
space:
mode:
Diffstat (limited to 'integration_tests')
-rw-r--r--integration_tests/helpers.go36
-rw-r--r--integration_tests/main_test.go48
2 files changed, 84 insertions, 0 deletions
diff --git a/integration_tests/helpers.go b/integration_tests/helpers.go
index e5458c9..4adce97 100644
--- a/integration_tests/helpers.go
+++ b/integration_tests/helpers.go
@@ -1,6 +1,7 @@
package integration_tests
import (
+ "path/filepath"
"crypto/md5"
"encoding/hex"
"fmt"
@@ -176,3 +177,38 @@ func testRename(t *testing.T, plainDir string) {
}
syscall.Unlink(file2)
}
+
+// verifyExistence - check in 3 ways that "path" exists:
+// stat, open, readdir
+func verifyExistence(path string) bool {
+
+ // Check that file can be stated
+ _, err := os.Stat(path)
+ if err != nil {
+ //t.Log(err)
+ return false
+ }
+
+ // Check that file can be opened
+ fd, err := os.Open(path)
+ if err != nil {
+ //t.Log(err)
+ return false
+ }
+ fd.Close()
+
+ // Check that file shows up in directory listing
+ dir := filepath.Dir(path)
+ name := filepath.Base(path)
+ fi, err := ioutil.ReadDir(dir)
+ if err != nil {
+ //t.Log(err)
+ return false
+ }
+ for _, i := range(fi) {
+ if i.Name() == name {
+ return true
+ }
+ }
+ return false
+}
diff --git a/integration_tests/main_test.go b/integration_tests/main_test.go
index 03b26f9..6ac03e1 100644
--- a/integration_tests/main_test.go
+++ b/integration_tests/main_test.go
@@ -3,6 +3,7 @@ package integration_tests
// File reading, writing, modification, truncate
import (
+ "syscall"
"bytes"
"crypto/md5"
"encoding/hex"
@@ -350,3 +351,50 @@ func TestDirOverwrite(t *testing.T) {
t.Fatal(err)
}
}
+
+func TestLongNames(t *testing.T) {
+ // Create
+ wd := defaultPlainDir
+ n255x := string(bytes.Repeat([]byte("x"), 255))
+ f, err := os.Create(wd+n255x)
+ if err != nil {
+ t.Fatalf("Could not create n255x")
+ }
+ f.Close()
+ if !verifyExistence(wd+n255x) {
+ t.Errorf("n255x is not in directory listing")
+ }
+ // Rename long to long
+ n255y := string(bytes.Repeat([]byte("y"), 255))
+ err = os.Rename(wd+n255x, wd+n255y)
+ if err != nil {
+ t.Fatalf("Could not rename n255x to n255y")
+ }
+ if !verifyExistence(wd+n255y) {
+ t.Errorf("n255y is not in directory listing")
+ }
+ // Rename long to short
+ err = os.Rename(wd+n255y, wd+"short")
+ if err != nil {
+ t.Fatalf("Could not rename n255y to short")
+ }
+ if !verifyExistence(wd+"short") {
+ t.Errorf("short is not in directory listing")
+ }
+ // Rename short to long
+ err = os.Rename(wd+"short", wd+n255x)
+ if err != nil {
+ t.Fatalf("Could not rename short to n255x")
+ }
+ if !verifyExistence(wd+n255x) {
+ t.Errorf("255x is not in directory listing II")
+ }
+ // Unlink
+ err = syscall.Unlink(wd+n255x)
+ if err != nil {
+ t.Fatalf("Could not unlink n255x")
+ }
+ if verifyExistence(wd+n255x) {
+ t.Errorf("n255x still there after unlink")
+ }
+}