summaryrefslogtreecommitdiff
path: root/integration_tests
diff options
context:
space:
mode:
Diffstat (limited to 'integration_tests')
-rw-r--r--integration_tests/example_filesystems_test.go35
-rw-r--r--integration_tests/helpers.go30
-rw-r--r--integration_tests/main_test.go20
3 files changed, 51 insertions, 34 deletions
diff --git a/integration_tests/example_filesystems_test.go b/integration_tests/example_filesystems_test.go
index 69cbe0e..5eb34e0 100644
--- a/integration_tests/example_filesystems_test.go
+++ b/integration_tests/example_filesystems_test.go
@@ -13,8 +13,8 @@ const statusTxtContent = "It works!\n"
// checkStatusTxt - read file "filename" and verify that it contains
// "It works!\n"
-func checkExampleContent(t *testing.T, dir string) {
- // Check regular file
+func checkExampleFS(t *testing.T, dir string) {
+ // Read regular file
statusFile := filepath.Join(dir, "status.txt")
contentBytes, err := ioutil.ReadFile(statusFile)
if err != nil {
@@ -24,7 +24,7 @@ func checkExampleContent(t *testing.T, dir string) {
if content != statusTxtContent {
t.Errorf("Unexpected content: %s\n", content)
}
- // Check relative symlink
+ // Read relative symlink
symlink := filepath.Join(dir, "rel")
target, err := os.Readlink(symlink)
if err != nil {
@@ -33,7 +33,7 @@ func checkExampleContent(t *testing.T, dir string) {
if target != "status.txt" {
t.Errorf("Unexpected link target: %s\n", target)
}
- // Check absolute symlink
+ // Read absolute symlink
symlink = filepath.Join(dir, "abs")
target, err = os.Readlink(symlink)
if err != nil {
@@ -42,11 +42,14 @@ func checkExampleContent(t *testing.T, dir string) {
if target != "/a/b/c/d" {
t.Errorf("Unexpected link target: %s\n", target)
}
+ // Test directory operations
+ testRename(t, dir)
+ testMkdirRmdir(t, dir)
}
// Test example_filesystems/v0.4
// with password mount and -masterkey mount
-func TestExampleFsV04(t *testing.T) {
+func TestExampleFSv04(t *testing.T) {
pDir := tmpDir + "TestExampleFsV04/"
cDir := "example_filesystems/v0.4"
err := os.Mkdir(pDir, 0777)
@@ -54,11 +57,11 @@ func TestExampleFsV04(t *testing.T) {
t.Fatal(err)
}
mount(cDir, pDir, "-extpass", "echo test")
- checkExampleContent(t, pDir)
+ checkExampleFS(t, pDir)
unmount(pDir)
mount(cDir, pDir, "-masterkey", "74676e34-0b47c145-00dac61a-17a92316-"+
"bb57044c-e205b71f-65f4fdca-7cabd4b3", "-diriv=false", "-emenames=false")
- checkExampleContent(t, pDir)
+ checkExampleFS(t, pDir)
unmount(pDir)
err = os.Remove(pDir)
if err != nil {
@@ -68,7 +71,7 @@ func TestExampleFsV04(t *testing.T) {
// Test example_filesystems/v0.5
// with password mount and -masterkey mount
-func TestExampleFsV05(t *testing.T) {
+func TestExampleFSv05(t *testing.T) {
pDir := tmpDir + "TestExampleFsV05/"
cDir := "example_filesystems/v0.5"
err := os.Mkdir(pDir, 0777)
@@ -76,11 +79,11 @@ func TestExampleFsV05(t *testing.T) {
t.Fatal(err)
}
mount(cDir, pDir, "-extpass", "echo test")
- checkExampleContent(t, pDir)
+ checkExampleFS(t, pDir)
unmount(pDir)
mount(cDir, pDir, "-masterkey", "199eae55-36bff4af-83b9a3a2-4fa16f65-"+
"1549ccdb-2d08d1f0-b1b26965-1b61f896", "-emenames=false")
- checkExampleContent(t, pDir)
+ checkExampleFS(t, pDir)
unmount(pDir)
err = os.Remove(pDir)
if err != nil {
@@ -90,7 +93,7 @@ func TestExampleFsV05(t *testing.T) {
// Test example_filesystems/v0.6
// with password mount and -masterkey mount
-func TestExampleFsV06(t *testing.T) {
+func TestExampleFSv06(t *testing.T) {
pDir := tmpDir + "TestExampleFsV06/"
cDir := "example_filesystems/v0.6"
err := os.Mkdir(pDir, 0777)
@@ -98,11 +101,11 @@ func TestExampleFsV06(t *testing.T) {
t.Fatal(err)
}
mount(cDir, pDir, "-extpass", "echo test")
- checkExampleContent(t, pDir)
+ checkExampleFS(t, pDir)
unmount(pDir)
mount(cDir, pDir, "-masterkey", "7bc8deb0-5fc894ef-a093da43-61561a81-"+
"0e8dee83-fdc056a4-937c37dd-9df5c520")
- checkExampleContent(t, pDir)
+ checkExampleFS(t, pDir)
unmount(pDir)
err = os.Remove(pDir)
if err != nil {
@@ -112,7 +115,7 @@ func TestExampleFsV06(t *testing.T) {
// Test example_filesystems/v0.6
// with password mount and -masterkey mount
-func TestExampleFsV06PlaintextNames(t *testing.T) {
+func TestExampleFSv06PlaintextNames(t *testing.T) {
pDir := tmpDir + "TestExampleFsV06PlaintextNames/"
cDir := "example_filesystems/v0.6-plaintextnames"
err := os.Mkdir(pDir, 0777)
@@ -120,11 +123,11 @@ func TestExampleFsV06PlaintextNames(t *testing.T) {
t.Fatal(err)
}
mount(cDir, pDir, "-extpass", "echo test")
- checkExampleContent(t, pDir)
+ checkExampleFS(t, pDir)
unmount(pDir)
mount(cDir, pDir, "-masterkey", "f4690202-595e4593-64c4f7e0-4dddd7d1-"+
"303147f9-0ca8aea2-966341a7-52ea8ae9", "-plaintextnames")
- checkExampleContent(t, pDir)
+ checkExampleFS(t, pDir)
unmount(pDir)
err = os.Remove(pDir)
if err != nil {
diff --git a/integration_tests/helpers.go b/integration_tests/helpers.go
index bff4e5b..b269069 100644
--- a/integration_tests/helpers.go
+++ b/integration_tests/helpers.go
@@ -1,6 +1,7 @@
package integration_tests
import (
+ "syscall"
"crypto/md5"
"encoding/hex"
"fmt"
@@ -51,6 +52,7 @@ func resetTmpDir() {
func mount(c string, p string, extraArgs ...string) {
var args []string
args = append(args, extraArgs...)
+ args = append(args, "-q")
//args = append(args, "--fusedebug")
args = append(args, c)
args = append(args, p)
@@ -113,3 +115,31 @@ func verifySize(t *testing.T, path string, want int) {
t.Errorf("wrong stat file size, got=%d want=%d", fi.Size(), want)
}
}
+
+// Create and delete a directory
+func testMkdirRmdir(t *testing.T, plainDir string) {
+ dir := plainDir + "dir1"
+ err := os.Mkdir(dir, 0777)
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = syscall.Rmdir(dir)
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+
+// Create and rename a file
+func testRename(t *testing.T, plainDir string) {
+ file1 := plainDir+"rename1"
+ file2 := plainDir+"rename2"
+ err := ioutil.WriteFile(file1, []byte("content"), 0777)
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = syscall.Rename(file1, file2)
+ if err != nil {
+ t.Fatal(err)
+ }
+ syscall.Unlink(file2)
+}
diff --git a/integration_tests/main_test.go b/integration_tests/main_test.go
index 953c552..398a9d4 100644
--- a/integration_tests/main_test.go
+++ b/integration_tests/main_test.go
@@ -12,7 +12,6 @@ import (
"os"
"runtime"
"sync"
- "syscall"
"testing"
)
@@ -314,25 +313,10 @@ func TestFilenameEncryption(t *testing.T) {
// Test Mkdir and Rmdir
func TestMkdirRmdir(t *testing.T) {
- dir := defaultPlainDir + "dir1"
- err := os.Mkdir(dir, 0777)
- if err != nil {
- t.Fatal(err)
- }
- err = syscall.Rmdir(dir)
- if err != nil {
- t.Fatal(err)
- }
+ testMkdirRmdir(t, defaultPlainDir)
}
// Test Rename
func TestRename(t *testing.T) {
- err := ioutil.WriteFile(defaultPlainDir+"rename1", []byte("content"), 0777)
- if err != nil {
- t.Fatal(err)
- }
- err = syscall.Rename(defaultPlainDir+"rename1", defaultPlainDir+"rename2")
- if err != nil {
- t.Fatal(err)
- }
+ testRename(t, defaultPlainDir)
}