summaryrefslogtreecommitdiff
path: root/integration_tests/example_filesystems_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-11-28 20:21:06 +0100
committerJakob Unterwurzacher2015-11-28 20:21:06 +0100
commit8766ab5472bcd3f70cc4caedc83d68cbd8155283 (patch)
tree982952481e6c3143b7c67b68ddc0b92a47b7e432 /integration_tests/example_filesystems_test.go
parent1fb349e97b5972b5d56c61afd05aed26698dcc97 (diff)
tests: verify that symlinks work
Diffstat (limited to 'integration_tests/example_filesystems_test.go')
-rw-r--r--integration_tests/example_filesystems_test.go29
1 files changed, 25 insertions, 4 deletions
diff --git a/integration_tests/example_filesystems_test.go b/integration_tests/example_filesystems_test.go
index 7924736..bd4f21d 100644
--- a/integration_tests/example_filesystems_test.go
+++ b/integration_tests/example_filesystems_test.go
@@ -3,6 +3,7 @@ package integration_tests
// Mount example filesystems and check that the file "status.txt" is there
import (
+ "path/filepath"
"io/ioutil"
"os"
"testing"
@@ -12,8 +13,10 @@ const statusTxtContent = "It works!\n"
// checkStatusTxt - read file "filename" and verify that it contains
// "It works!\n"
-func checkStatusTxt(t *testing.T, filename string) {
- contentBytes, err := ioutil.ReadFile(filename)
+func checkExampleContent(t *testing.T, dir string) {
+ // Check regular file
+ statusFile := filepath.Join(dir, "status.txt")
+ contentBytes, err := ioutil.ReadFile(statusFile)
if err != nil {
t.Fatal(err)
}
@@ -21,6 +24,24 @@ func checkStatusTxt(t *testing.T, filename string) {
if content != statusTxtContent {
t.Errorf("Unexpected content: %s\n", content)
}
+ // Check relative symlink
+ symlink := filepath.Join(dir, "rel")
+ target, err := os.Readlink(symlink)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if target != "status.txt" {
+ t.Errorf("Unexpected link target: %s\n", target)
+ }
+ // Check absolute symlink
+ symlink = filepath.Join(dir, "abs")
+ target, err = os.Readlink(symlink)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if target != "/a/b/c/d" {
+ t.Errorf("Unexpected link target: %s\n", target)
+ }
}
// Test example_filesystems/normal
@@ -33,11 +54,11 @@ func TestExampleFsNormal(t *testing.T) {
t.Fatal(err)
}
mount(cDir, pDir, "-extpass", "echo test")
- checkStatusTxt(t, pDir+"status.txt")
+ checkExampleContent(t, pDir)
unmount(pDir)
mount(cDir, pDir, "-masterkey", "74676e34-0b47c145-00dac61a-17a92316-"+
"bb57044c-e205b71f-65f4fdca-7cabd4b3", "-diriv=false")
- checkStatusTxt(t, pDir+"status.txt")
+ checkExampleContent(t, pDir)
unmount(pDir)
err = os.Remove(pDir)
if err != nil {