reverse: more thorough longname stat test

Now also verifies the returned file size.
This commit is contained in:
Jakob Unterwurzacher 2016-09-25 15:32:46 +02:00
parent 2050c7f3b3
commit ffdb7cd47a
3 changed files with 20 additions and 6 deletions

View File

@ -3,15 +3,28 @@ package reverse_test
import (
"os"
"testing"
//"time"
"github.com/rfjakob/gocryptfs/tests/test_helpers"
)
func TestLongnameStat(t *testing.T) {
_, err := os.Stat(dirA + "/" + "")
fd, err := os.Create(dirA + "/" + x240)
if err != nil {
t.Error(err)
t.Fatal(err)
}
_, err = os.Stat(dirA + "/" + "")
path := dirC + "/" + x240
if !test_helpers.VerifyExistence(path) {
t.Fail()
}
test_helpers.VerifySize(t, path, 0)
_, err = fd.Write(make([]byte, 10))
if err != nil {
t.Error(err)
t.Fatal(err)
}
fd.Close()
/*
time.Sleep(1000 * time.Millisecond)
test_helpers.VerifySize(t, path, 10)
*/
}

View File

@ -1,7 +1,6 @@
package reverse_test
import (
"bytes"
"fmt"
"os"
"testing"
@ -13,7 +12,6 @@ func genName(i int, postfix string) string {
// Create 10000 files with long names
func generateLongnameFiles(dir string) {
x240 := string(bytes.Repeat([]byte("x"), 240))
for i := 0; i < 100000; i++ {
n := genName(i, x240)
f, err := os.Create(dir + "/" + n)

View File

@ -1,6 +1,7 @@
package reverse_test
import (
"bytes"
"os"
"testing"
@ -8,8 +9,10 @@ import (
)
var dirA, dirB, dirC string
var x240 string
func TestMain(m *testing.M) {
x240 = string(bytes.Repeat([]byte("x"), 240))
dirA = test_helpers.TmpDir + "/a"
dirB = test_helpers.TmpDir + "/b"
dirC = test_helpers.TmpDir + "/c"