tests: verify that symlinks work
This commit is contained in:
parent
1fb349e97b
commit
8766ab5472
@ -0,0 +1 @@
|
||||
3-HZSwv99agoWgTErV0YFQ==
|
@ -0,0 +1 @@
|
||||
/tTXhw8tmmz4PK9YG21Whug==/Qe8z0HUArb5bZJjUqEo2Nw==/wv68UB9DLF9OfAcxgRKKtQ==/9No5n3deBUGa-BsvPRi3DQ==
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user