tests: adapt for read-only operation

The v0.6 and older example filesystem are mounted read-only
because they are deprecated, so skip the read-write tests.
This commit is contained in:
Jakob Unterwurzacher 2016-06-16 23:24:32 +02:00
parent cc2a75b050
commit 4d067e2de1

View File

@ -19,7 +19,7 @@ func TestMain(m *testing.M) {
} }
// checkExampleFS - verify that "dir" contains the expected test files // checkExampleFS - verify that "dir" contains the expected test files
func checkExampleFS(t *testing.T, dir string) { func checkExampleFS(t *testing.T, dir string, rw bool) {
// Read regular file // Read regular file
statusFile := filepath.Join(dir, "status.txt") statusFile := filepath.Join(dir, "status.txt")
contentBytes, err := ioutil.ReadFile(statusFile) contentBytes, err := ioutil.ReadFile(statusFile)
@ -48,16 +48,19 @@ func checkExampleFS(t *testing.T, dir string) {
if target != "/a/b/c/d" { if target != "/a/b/c/d" {
t.Errorf("Unexpected link target: %s\n", target) t.Errorf("Unexpected link target: %s\n", target)
} }
if rw {
// Test directory operations // Test directory operations
test_helpers.TestRename(t, dir) test_helpers.TestRename(t, dir)
test_helpers.TestMkdirRmdir(t, dir) test_helpers.TestMkdirRmdir(t, dir)
} }
}
// checkExampleFSLongnames - verify that "dir" contains the expected test files // checkExampleFSLongnames - verify that "dir" contains the expected test files
// plus the long file name test file // plus the long file name test file
func checkExampleFSLongnames(t *testing.T, dir string) { func checkExampleFSLongnames(t *testing.T, dir string) {
// regular tests // regular tests
checkExampleFS(t, dir) checkExampleFS(t, dir, true)
// long name test file // long name test file
longname := "longname_255_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + longname := "longname_255_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +
@ -84,11 +87,11 @@ func TestExampleFSv04(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test") test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test")
checkExampleFS(t, pDir) checkExampleFS(t, pDir, false)
test_helpers.Unmount(pDir) test_helpers.Unmount(pDir)
test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "74676e34-0b47c145-00dac61a-17a92316-"+ test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "74676e34-0b47c145-00dac61a-17a92316-"+
"bb57044c-e205b71f-65f4fdca-7cabd4b3", "-diriv=false", "-emenames=false", "-gcmiv128=false") "bb57044c-e205b71f-65f4fdca-7cabd4b3", "-diriv=false", "-emenames=false", "-gcmiv128=false")
checkExampleFS(t, pDir) checkExampleFS(t, pDir, true)
test_helpers.Unmount(pDir) test_helpers.Unmount(pDir)
err = os.Remove(pDir) err = os.Remove(pDir)
if err != nil { if err != nil {
@ -106,11 +109,11 @@ func TestExampleFSv05(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test") test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test")
checkExampleFS(t, pDir) checkExampleFS(t, pDir, false)
test_helpers.Unmount(pDir) test_helpers.Unmount(pDir)
test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "199eae55-36bff4af-83b9a3a2-4fa16f65-"+ test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "199eae55-36bff4af-83b9a3a2-4fa16f65-"+
"1549ccdb-2d08d1f0-b1b26965-1b61f896", "-emenames=false", "-gcmiv128=false") "1549ccdb-2d08d1f0-b1b26965-1b61f896", "-emenames=false", "-gcmiv128=false")
checkExampleFS(t, pDir) checkExampleFS(t, pDir, true)
test_helpers.Unmount(pDir) test_helpers.Unmount(pDir)
err = os.Remove(pDir) err = os.Remove(pDir)
if err != nil { if err != nil {
@ -128,11 +131,11 @@ func TestExampleFSv06(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test") test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test")
checkExampleFS(t, pDir) checkExampleFS(t, pDir, false)
test_helpers.Unmount(pDir) test_helpers.Unmount(pDir)
test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "7bc8deb0-5fc894ef-a093da43-61561a81-"+ test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "7bc8deb0-5fc894ef-a093da43-61561a81-"+
"0e8dee83-fdc056a4-937c37dd-9df5c520", "-gcmiv128=false") "0e8dee83-fdc056a4-937c37dd-9df5c520", "-gcmiv128=false")
checkExampleFS(t, pDir) checkExampleFS(t, pDir, true)
test_helpers.Unmount(pDir) test_helpers.Unmount(pDir)
err = os.Remove(pDir) err = os.Remove(pDir)
if err != nil { if err != nil {
@ -152,11 +155,11 @@ func TestExampleFSv06PlaintextNames(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test") test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test")
checkExampleFS(t, pDir) checkExampleFS(t, pDir, false)
test_helpers.Unmount(pDir) test_helpers.Unmount(pDir)
test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "f4690202-595e4593-64c4f7e0-4dddd7d1-"+ test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "f4690202-595e4593-64c4f7e0-4dddd7d1-"+
"303147f9-0ca8aea2-966341a7-52ea8ae9", "-plaintextnames", "-gcmiv128=false") "303147f9-0ca8aea2-966341a7-52ea8ae9", "-plaintextnames", "-gcmiv128=false")
checkExampleFS(t, pDir) checkExampleFS(t, pDir, true)
test_helpers.Unmount(pDir) test_helpers.Unmount(pDir)
err = os.Remove(pDir) err = os.Remove(pDir)
if err != nil { if err != nil {
@ -175,11 +178,11 @@ func TestExampleFSv07(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test") test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test")
checkExampleFS(t, pDir) checkExampleFS(t, pDir, true)
test_helpers.Unmount(pDir) test_helpers.Unmount(pDir)
test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "ed7f6d83-40cce86c-0e7d79c2-a9438710-"+ test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "ed7f6d83-40cce86c-0e7d79c2-a9438710-"+
"575221bf-30a0eb60-2821fa8f-7f3123bf") "575221bf-30a0eb60-2821fa8f-7f3123bf")
checkExampleFS(t, pDir) checkExampleFS(t, pDir, true)
test_helpers.Unmount(pDir) test_helpers.Unmount(pDir)
err = os.Remove(pDir) err = os.Remove(pDir)
if err != nil { if err != nil {