Commit d822ee41 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Shorten /mount to /mnt in unionfs tests.

parent 62094b64
...@@ -30,7 +30,7 @@ func WriteFile(name string, contents string) { ...@@ -30,7 +30,7 @@ func WriteFile(name string, contents string) {
func setup(t *testing.T) (workdir string, cleanup func()) { func setup(t *testing.T) (workdir string, cleanup func()) {
wd, _ := ioutil.TempDir("", "") wd, _ := ioutil.TempDir("", "")
err := os.Mkdir(wd+"/mount", 0700) err := os.Mkdir(wd+"/mnt", 0700)
fuse.CheckSuccess(err) fuse.CheckSuccess(err)
err = os.Mkdir(wd+"/store", 0700) err = os.Mkdir(wd+"/store", 0700)
...@@ -42,7 +42,7 @@ func setup(t *testing.T) (workdir string, cleanup func()) { ...@@ -42,7 +42,7 @@ func setup(t *testing.T) (workdir string, cleanup func()) {
WriteFile(wd+"/ro/file2", "file2") WriteFile(wd+"/ro/file2", "file2")
fs := NewAutoUnionFs(wd+"/store", testAOpts) fs := NewAutoUnionFs(wd+"/store", testAOpts)
state, conn, err := fuse.MountPathFileSystem(wd+"/mount", fs, &testAOpts.FileSystemOptions) state, conn, err := fuse.MountPathFileSystem(wd+"/mnt", fs, &testAOpts.FileSystemOptions)
CheckSuccess(err) CheckSuccess(err)
state.Debug = fuse.VerboseTest() state.Debug = fuse.VerboseTest()
conn.Debug = fuse.VerboseTest() conn.Debug = fuse.VerboseTest()
...@@ -58,7 +58,7 @@ func TestVersion(t *testing.T) { ...@@ -58,7 +58,7 @@ func TestVersion(t *testing.T) {
wd, clean := setup(t) wd, clean := setup(t)
defer clean() defer clean()
c, err := ioutil.ReadFile(wd + "/mount/status/gounionfs_version") c, err := ioutil.ReadFile(wd + "/mnt/status/gounionfs_version")
CheckSuccess(err) CheckSuccess(err)
if len(c) == 0 { if len(c) == 0 {
t.Fatal("No version found.") t.Fatal("No version found.")
...@@ -76,36 +76,36 @@ func TestAutoFsSymlink(t *testing.T) { ...@@ -76,36 +76,36 @@ func TestAutoFsSymlink(t *testing.T) {
err = os.Symlink(wd+"/ro", wd+"/store/backing1/READONLY") err = os.Symlink(wd+"/ro", wd+"/store/backing1/READONLY")
CheckSuccess(err) CheckSuccess(err)
err = os.Symlink(wd+"/store/backing1", wd+"/mount/config/manual1") err = os.Symlink(wd+"/store/backing1", wd+"/mnt/config/manual1")
CheckSuccess(err) CheckSuccess(err)
fi, err := os.Lstat(wd + "/mount/manual1/file1") fi, err := os.Lstat(wd + "/mnt/manual1/file1")
CheckSuccess(err) CheckSuccess(err)
entries, err := ioutil.ReadDir(wd + "/mount") entries, err := ioutil.ReadDir(wd + "/mnt")
CheckSuccess(err) CheckSuccess(err)
if len(entries) != 3 { if len(entries) != 3 {
t.Error("readdir mismatch", entries) t.Error("readdir mismatch", entries)
} }
err = os.Remove(wd + "/mount/config/manual1") err = os.Remove(wd + "/mnt/config/manual1")
CheckSuccess(err) CheckSuccess(err)
scan := wd + "/mount/config/" + _SCAN_CONFIG scan := wd + "/mnt/config/" + _SCAN_CONFIG
err = ioutil.WriteFile(scan, []byte("something"), 0644) err = ioutil.WriteFile(scan, []byte("something"), 0644)
if err != nil { if err != nil {
t.Error("error writing:", err) t.Error("error writing:", err)
} }
fi, _ = os.Lstat(wd + "/mount/manual1") fi, _ = os.Lstat(wd + "/mnt/manual1")
if fi != nil { if fi != nil {
t.Error("Should not have file:", fi) t.Error("Should not have file:", fi)
} }
_, err = ioutil.ReadDir(wd + "/mount/config") _, err = ioutil.ReadDir(wd + "/mnt/config")
CheckSuccess(err) CheckSuccess(err)
_, err = os.Lstat(wd + "/mount/backing1/file1") _, err = os.Lstat(wd + "/mnt/backing1/file1")
CheckSuccess(err) CheckSuccess(err)
} }
...@@ -122,13 +122,13 @@ func TestDetectSymlinkedDirectories(t *testing.T) { ...@@ -122,13 +122,13 @@ func TestDetectSymlinkedDirectories(t *testing.T) {
err = os.Symlink(wd+"/backing1", wd+"/store/backing1") err = os.Symlink(wd+"/backing1", wd+"/store/backing1")
CheckSuccess(err) CheckSuccess(err)
scan := wd + "/mount/config/" + _SCAN_CONFIG scan := wd + "/mnt/config/" + _SCAN_CONFIG
err = ioutil.WriteFile(scan, []byte("something"), 0644) err = ioutil.WriteFile(scan, []byte("something"), 0644)
if err != nil { if err != nil {
t.Error("error writing:", err) t.Error("error writing:", err)
} }
_, err = os.Lstat(wd + "/mount/backing1") _, err = os.Lstat(wd + "/mnt/backing1")
CheckSuccess(err) CheckSuccess(err)
} }
...@@ -141,12 +141,12 @@ func TestExplicitScan(t *testing.T) { ...@@ -141,12 +141,12 @@ func TestExplicitScan(t *testing.T) {
os.Symlink(wd+"/ro", wd+"/store/backing1/READONLY") os.Symlink(wd+"/ro", wd+"/store/backing1/READONLY")
CheckSuccess(err) CheckSuccess(err)
fi, _ := os.Lstat(wd + "/mount/backing1") fi, _ := os.Lstat(wd + "/mnt/backing1")
if fi != nil { if fi != nil {
t.Error("Should not have file:", fi) t.Error("Should not have file:", fi)
} }
scan := wd + "/mount/config/" + _SCAN_CONFIG scan := wd + "/mnt/config/" + _SCAN_CONFIG
_, err = os.Lstat(scan) _, err = os.Lstat(scan)
if err != nil { if err != nil {
t.Error(".scan_config missing:", err) t.Error(".scan_config missing:", err)
...@@ -157,7 +157,7 @@ func TestExplicitScan(t *testing.T) { ...@@ -157,7 +157,7 @@ func TestExplicitScan(t *testing.T) {
t.Error("error writing:", err) t.Error("error writing:", err)
} }
_, err = os.Lstat(wd + "/mount/backing1") _, err = os.Lstat(wd + "/mnt/backing1")
if err != nil { if err != nil {
t.Error("Should have workspace backing1:", err) t.Error("Should have workspace backing1:", err)
} }
...@@ -177,16 +177,16 @@ func TestCreationChecks(t *testing.T) { ...@@ -177,16 +177,16 @@ func TestCreationChecks(t *testing.T) {
os.Symlink(wd+"/ro", wd+"/store/ws2/READONLY") os.Symlink(wd+"/ro", wd+"/store/ws2/READONLY")
CheckSuccess(err) CheckSuccess(err)
err = os.Symlink(wd+"/store/foo", wd+"/mount/config/bar") err = os.Symlink(wd+"/store/foo", wd+"/mnt/config/bar")
CheckSuccess(err) CheckSuccess(err)
err = os.Symlink(wd+"/store/foo", wd+"/mount/config/foo") err = os.Symlink(wd+"/store/foo", wd+"/mnt/config/foo")
code := fuse.OsErrorToErrno(err) code := fuse.OsErrorToErrno(err)
if code != fuse.EBUSY { if code != fuse.EBUSY {
t.Error("Should return EBUSY", err) t.Error("Should return EBUSY", err)
} }
err = os.Symlink(wd+"/store/ws2", wd+"/mount/config/config") err = os.Symlink(wd+"/store/ws2", wd+"/mnt/config/config")
code = fuse.OsErrorToErrno(err) code = fuse.OsErrorToErrno(err)
if code != fuse.EINVAL { if code != fuse.EINVAL {
t.Error("Should return EINVAL", err) t.Error("Should return EINVAL", err)
......
...@@ -23,7 +23,7 @@ func setupMemUfs(t *testing.T) (workdir string, ufs *MemUnionFs, cleanup func()) ...@@ -23,7 +23,7 @@ func setupMemUfs(t *testing.T) (workdir string, ufs *MemUnionFs, cleanup func())
syscall.Umask(0) syscall.Umask(0)
wd, _ := ioutil.TempDir("", "") wd, _ := ioutil.TempDir("", "")
err := os.Mkdir(wd+"/mount", 0700) err := os.Mkdir(wd+"/mnt", 0700)
fuse.CheckSuccess(err) fuse.CheckSuccess(err)
err = os.Mkdir(wd+"/backing", 0700) err = os.Mkdir(wd+"/backing", 0700)
...@@ -43,7 +43,7 @@ func setupMemUfs(t *testing.T) (workdir string, ufs *MemUnionFs, cleanup func()) ...@@ -43,7 +43,7 @@ func setupMemUfs(t *testing.T) (workdir string, ufs *MemUnionFs, cleanup func())
NegativeTimeout: .5 * entryTtl, NegativeTimeout: .5 * entryTtl,
} }
state, conn, err := fuse.MountNodeFileSystem(wd+"/mount", memFs, opts) state, conn, err := fuse.MountNodeFileSystem(wd+"/mnt", memFs, opts)
CheckSuccess(err) CheckSuccess(err)
conn.Debug = fuse.VerboseTest() conn.Debug = fuse.VerboseTest()
state.Debug = fuse.VerboseTest() state.Debug = fuse.VerboseTest()
...@@ -59,10 +59,10 @@ func TestMemUnionFsSymlink(t *testing.T) { ...@@ -59,10 +59,10 @@ func TestMemUnionFsSymlink(t *testing.T) {
wd, ufs, clean := setupMemUfs(t) wd, ufs, clean := setupMemUfs(t)
defer clean() defer clean()
err := os.Symlink("/foobar", wd+"/mount/link") err := os.Symlink("/foobar", wd+"/mnt/link")
CheckSuccess(err) CheckSuccess(err)
val, err := os.Readlink(wd + "/mount/link") val, err := os.Readlink(wd + "/mnt/link")
CheckSuccess(err) CheckSuccess(err)
if val != "/foobar" { if val != "/foobar" {
...@@ -82,7 +82,7 @@ func TestMemUnionFsSymlinkPromote(t *testing.T) { ...@@ -82,7 +82,7 @@ func TestMemUnionFsSymlinkPromote(t *testing.T) {
err := os.Mkdir(wd+"/ro/subdir", 0755) err := os.Mkdir(wd+"/ro/subdir", 0755)
CheckSuccess(err) CheckSuccess(err)
err = os.Symlink("/foobar", wd+"/mount/subdir/link") err = os.Symlink("/foobar", wd+"/mnt/subdir/link")
CheckSuccess(err) CheckSuccess(err)
r := ufs.Reap() r := ufs.Reap()
...@@ -99,10 +99,10 @@ func TestMemUnionFsChtimes(t *testing.T) { ...@@ -99,10 +99,10 @@ func TestMemUnionFsChtimes(t *testing.T) {
err := os.Chtimes(wd+"/ro/file", 42e9, 43e9) err := os.Chtimes(wd+"/ro/file", 42e9, 43e9)
CheckSuccess(err) CheckSuccess(err)
err = os.Chtimes(wd+"/mount/file", 82e9, 83e9) err = os.Chtimes(wd+"/mnt/file", 82e9, 83e9)
CheckSuccess(err) CheckSuccess(err)
fi, err := os.Lstat(wd + "/mount/file") fi, err := os.Lstat(wd + "/mnt/file")
if fi.Atime_ns != 82e9 || fi.Mtime_ns != 83e9 { if fi.Atime_ns != 82e9 || fi.Mtime_ns != 83e9 {
t.Error("Incorrect timestamp", fi) t.Error("Incorrect timestamp", fi)
} }
...@@ -118,7 +118,7 @@ func TestMemUnionFsChmod(t *testing.T) { ...@@ -118,7 +118,7 @@ func TestMemUnionFsChmod(t *testing.T) {
defer clean() defer clean()
ro_fn := wd + "/ro/file" ro_fn := wd + "/ro/file"
m_fn := wd + "/mount/file" m_fn := wd + "/mnt/file"
writeToFile(ro_fn, "a") writeToFile(ro_fn, "a")
err := os.Chmod(m_fn, 07070) err := os.Chmod(m_fn, 07070)
CheckSuccess(err) CheckSuccess(err)
...@@ -140,7 +140,7 @@ func TestMemUnionFsChown(t *testing.T) { ...@@ -140,7 +140,7 @@ func TestMemUnionFsChown(t *testing.T) {
defer clean() defer clean()
ro_fn := wd + "/ro/file" ro_fn := wd + "/ro/file"
m_fn := wd + "/mount/file" m_fn := wd + "/mnt/file"
writeToFile(ro_fn, "a") writeToFile(ro_fn, "a")
err := os.Chown(m_fn, 0, 0) err := os.Chown(m_fn, 0, 0)
...@@ -155,13 +155,13 @@ func TestMemUnionFsDelete(t *testing.T) { ...@@ -155,13 +155,13 @@ func TestMemUnionFsDelete(t *testing.T) {
defer clean() defer clean()
writeToFile(wd+"/ro/file", "a") writeToFile(wd+"/ro/file", "a")
_, err := os.Lstat(wd + "/mount/file") _, err := os.Lstat(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
err = os.Remove(wd + "/mount/file") err = os.Remove(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
_, err = os.Lstat(wd + "/mount/file") _, err = os.Lstat(wd + "/mnt/file")
if err == nil { if err == nil {
t.Fatal("should have disappeared.") t.Fatal("should have disappeared.")
} }
...@@ -176,32 +176,32 @@ func TestMemUnionFsBasic(t *testing.T) { ...@@ -176,32 +176,32 @@ func TestMemUnionFsBasic(t *testing.T) {
wd, _, clean := setupMemUfs(t) wd, _, clean := setupMemUfs(t)
defer clean() defer clean()
writeToFile(wd+"/mount/rw", "a") writeToFile(wd+"/mnt/rw", "a")
writeToFile(wd+"/ro/ro1", "a") writeToFile(wd+"/ro/ro1", "a")
writeToFile(wd+"/ro/ro2", "b") writeToFile(wd+"/ro/ro2", "b")
names := dirNames(wd + "/mount") names := dirNames(wd + "/mnt")
expected := map[string]bool{ expected := map[string]bool{
"rw": true, "ro1": true, "ro2": true, "rw": true, "ro1": true, "ro2": true,
} }
checkMapEq(t, names, expected) checkMapEq(t, names, expected)
writeToFile(wd+"/mount/new", "new contents") writeToFile(wd+"/mnt/new", "new contents")
contents := readFromFile(wd + "/mount/new") contents := readFromFile(wd + "/mnt/new")
if contents != "new contents" { if contents != "new contents" {
t.Errorf("read mismatch: '%v'", contents) t.Errorf("read mismatch: '%v'", contents)
} }
writeToFile(wd+"/mount/ro1", "promote me") writeToFile(wd+"/mnt/ro1", "promote me")
remove(wd + "/mount/new") remove(wd + "/mnt/new")
names = dirNames(wd + "/mount") names = dirNames(wd + "/mnt")
checkMapEq(t, names, map[string]bool{ checkMapEq(t, names, map[string]bool{
"rw": true, "ro1": true, "ro2": true, "rw": true, "ro1": true, "ro2": true,
}) })
remove(wd + "/mount/ro1") remove(wd + "/mnt/ro1")
names = dirNames(wd + "/mount") names = dirNames(wd + "/mnt")
checkMapEq(t, names, map[string]bool{ checkMapEq(t, names, map[string]bool{
"rw": true, "ro2": true, "rw": true, "ro2": true,
}) })
...@@ -214,7 +214,7 @@ func TestMemUnionFsPromote(t *testing.T) { ...@@ -214,7 +214,7 @@ func TestMemUnionFsPromote(t *testing.T) {
err := os.Mkdir(wd+"/ro/subdir", 0755) err := os.Mkdir(wd+"/ro/subdir", 0755)
CheckSuccess(err) CheckSuccess(err)
writeToFile(wd+"/ro/subdir/file", "content") writeToFile(wd+"/ro/subdir/file", "content")
writeToFile(wd+"/mount/subdir/file", "other-content") writeToFile(wd+"/mnt/subdir/file", "other-content")
r := ufs.Reap() r := ufs.Reap()
if r["subdir/file"] == nil || r["subdir/file"].Backing == "" { if r["subdir/file"] == nil || r["subdir/file"].Backing == "" {
...@@ -228,8 +228,8 @@ func TestMemUnionFsSubdirCreate(t *testing.T) { ...@@ -228,8 +228,8 @@ func TestMemUnionFsSubdirCreate(t *testing.T) {
err := os.MkdirAll(wd+"/ro/subdir/sub2", 0755) err := os.MkdirAll(wd+"/ro/subdir/sub2", 0755)
CheckSuccess(err) CheckSuccess(err)
writeToFile(wd+"/mount/subdir/sub2/file", "other-content") writeToFile(wd+"/mnt/subdir/sub2/file", "other-content")
_, err = os.Lstat(wd + "/mount/subdir/sub2/file") _, err = os.Lstat(wd + "/mnt/subdir/sub2/file")
CheckSuccess(err) CheckSuccess(err)
r := ufs.Reap() r := ufs.Reap()
...@@ -242,8 +242,8 @@ func TestMemUnionFsCreate(t *testing.T) { ...@@ -242,8 +242,8 @@ func TestMemUnionFsCreate(t *testing.T) {
wd, ufs, clean := setupMemUfs(t) wd, ufs, clean := setupMemUfs(t)
defer clean() defer clean()
writeToFile(wd+"/mount/file.txt", "hello") writeToFile(wd+"/mnt/file.txt", "hello")
_, err := os.Lstat(wd + "/mount/file.txt") _, err := os.Lstat(wd + "/mnt/file.txt")
CheckSuccess(err) CheckSuccess(err)
r := ufs.Reap() r := ufs.Reap()
...@@ -257,17 +257,17 @@ func TestMemUnionFsOpenUndeletes(t *testing.T) { ...@@ -257,17 +257,17 @@ func TestMemUnionFsOpenUndeletes(t *testing.T) {
defer clean() defer clean()
writeToFile(wd+"/ro/file", "X") writeToFile(wd+"/ro/file", "X")
err := os.Remove(wd + "/mount/file") err := os.Remove(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
writeToFile(wd+"/mount/file", "X") writeToFile(wd+"/mnt/file", "X")
_, err = os.Lstat(wd + "/mount/file") _, err = os.Lstat(wd + "/mnt/file")
} }
func TestMemUnionFsMkdir(t *testing.T) { func TestMemUnionFsMkdir(t *testing.T) {
wd, ufs, clean := setupMemUfs(t) wd, ufs, clean := setupMemUfs(t)
defer clean() defer clean()
dirname := wd + "/mount/subdir" dirname := wd + "/mnt/subdir"
err := os.Mkdir(dirname, 0755) err := os.Mkdir(dirname, 0755)
CheckSuccess(err) CheckSuccess(err)
...@@ -288,7 +288,7 @@ func TestMemUnionFsMkdirPromote(t *testing.T) { ...@@ -288,7 +288,7 @@ func TestMemUnionFsMkdirPromote(t *testing.T) {
err := os.MkdirAll(dirname, 0755) err := os.MkdirAll(dirname, 0755)
CheckSuccess(err) CheckSuccess(err)
err = os.Mkdir(wd+"/mount/subdir/subdir2/dir3", 0755) err = os.Mkdir(wd+"/mnt/subdir/subdir2/dir3", 0755)
CheckSuccess(err) CheckSuccess(err)
r := ufs.Reap() r := ufs.Reap()
...@@ -304,7 +304,7 @@ func TestMemUnionFsRmdirMkdir(t *testing.T) { ...@@ -304,7 +304,7 @@ func TestMemUnionFsRmdirMkdir(t *testing.T) {
err := os.Mkdir(wd+"/ro/subdir", 0755) err := os.Mkdir(wd+"/ro/subdir", 0755)
CheckSuccess(err) CheckSuccess(err)
dirname := wd + "/mount/subdir" dirname := wd + "/mnt/subdir"
err = os.Remove(dirname) err = os.Remove(dirname)
CheckSuccess(err) CheckSuccess(err)
...@@ -321,18 +321,18 @@ func TestMemUnionFsLink(t *testing.T) { ...@@ -321,18 +321,18 @@ func TestMemUnionFsLink(t *testing.T) {
err := ioutil.WriteFile(fn, []byte(content), 0666) err := ioutil.WriteFile(fn, []byte(content), 0666)
CheckSuccess(err) CheckSuccess(err)
err = os.Link(wd+"/mount/file", wd+"/mount/linked") err = os.Link(wd+"/mnt/file", wd+"/mnt/linked")
CheckSuccess(err) CheckSuccess(err)
fi2, err := os.Lstat(wd + "/mount/linked") fi2, err := os.Lstat(wd + "/mnt/linked")
CheckSuccess(err) CheckSuccess(err)
fi1, err := os.Lstat(wd + "/mount/file") fi1, err := os.Lstat(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
if fi1.Ino != fi2.Ino { if fi1.Ino != fi2.Ino {
t.Errorf("inode numbers should be equal for linked files %v, %v", fi1.Ino, fi2.Ino) t.Errorf("inode numbers should be equal for linked files %v, %v", fi1.Ino, fi2.Ino)
} }
c, err := ioutil.ReadFile(wd + "/mount/linked") c, err := ioutil.ReadFile(wd + "/mnt/linked")
if string(c) != content { if string(c) != content {
t.Errorf("content mismatch got %q want %q", string(c), content) t.Errorf("content mismatch got %q want %q", string(c), content)
} }
...@@ -347,7 +347,7 @@ func TestMemUnionFsCreateLink(t *testing.T) { ...@@ -347,7 +347,7 @@ func TestMemUnionFsCreateLink(t *testing.T) {
err := ioutil.WriteFile(fn, []byte(content), 0666) err := ioutil.WriteFile(fn, []byte(content), 0666)
CheckSuccess(err) CheckSuccess(err)
err = os.Link(wd+"/mount/file", wd+"/mount/linked") err = os.Link(wd+"/mnt/file", wd+"/mnt/linked")
CheckSuccess(err) CheckSuccess(err)
} }
...@@ -356,8 +356,8 @@ func TestMemUnionFsTruncate(t *testing.T) { ...@@ -356,8 +356,8 @@ func TestMemUnionFsTruncate(t *testing.T) {
defer clean() defer clean()
writeToFile(wd+"/ro/file", "hello") writeToFile(wd+"/ro/file", "hello")
os.Truncate(wd+"/mount/file", 2) os.Truncate(wd+"/mnt/file", 2)
content := readFromFile(wd + "/mount/file") content := readFromFile(wd + "/mnt/file")
if content != "he" { if content != "he" {
t.Errorf("unexpected content %v", content) t.Errorf("unexpected content %v", content)
} }
...@@ -368,7 +368,7 @@ func TestMemUnionFsCopyChmod(t *testing.T) { ...@@ -368,7 +368,7 @@ func TestMemUnionFsCopyChmod(t *testing.T) {
defer clean() defer clean()
contents := "hello" contents := "hello"
fn := wd + "/mount/y" fn := wd + "/mnt/y"
err := ioutil.WriteFile(fn, []byte(contents), 0644) err := ioutil.WriteFile(fn, []byte(contents), 0644)
CheckSuccess(err) CheckSuccess(err)
...@@ -393,7 +393,7 @@ func TestMemUnionFsTruncateTimestamp(t *testing.T) { ...@@ -393,7 +393,7 @@ func TestMemUnionFsTruncateTimestamp(t *testing.T) {
defer clean() defer clean()
contents := "hello" contents := "hello"
fn := wd + "/mount/y" fn := wd + "/mnt/y"
err := ioutil.WriteFile(fn, []byte(contents), 0644) err := ioutil.WriteFile(fn, []byte(contents), 0644)
CheckSuccess(err) CheckSuccess(err)
time.Sleep(0.2e9) time.Sleep(0.2e9)
...@@ -422,7 +422,7 @@ func TestMemUnionFsRemoveAll(t *testing.T) { ...@@ -422,7 +422,7 @@ func TestMemUnionFsRemoveAll(t *testing.T) {
err = ioutil.WriteFile(fn, []byte(contents), 0644) err = ioutil.WriteFile(fn, []byte(contents), 0644)
CheckSuccess(err) CheckSuccess(err)
err = os.RemoveAll(wd + "/mount/dir") err = os.RemoveAll(wd + "/mnt/dir")
if err != nil { if err != nil {
t.Error("Should delete all") t.Error("Should delete all")
} }
...@@ -447,7 +447,7 @@ func TestMemUnionFsRmRf(t *testing.T) { ...@@ -447,7 +447,7 @@ func TestMemUnionFsRmRf(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
bin, err := exec.LookPath("rm") bin, err := exec.LookPath("rm")
CheckSuccess(err) CheckSuccess(err)
cmd := exec.Command(bin, "-rf", wd+"/mount/dir") cmd := exec.Command(bin, "-rf", wd+"/mnt/dir")
err = cmd.Run() err = cmd.Run()
if err != nil { if err != nil {
t.Fatal("rm -rf returned error:", err) t.Fatal("rm -rf returned error:", err)
...@@ -467,11 +467,11 @@ func TestMemUnionFsDeletedGetAttr(t *testing.T) { ...@@ -467,11 +467,11 @@ func TestMemUnionFsDeletedGetAttr(t *testing.T) {
err := ioutil.WriteFile(wd+"/ro/file", []byte("blabla"), 0644) err := ioutil.WriteFile(wd+"/ro/file", []byte("blabla"), 0644)
CheckSuccess(err) CheckSuccess(err)
f, err := os.Open(wd + "/mount/file") f, err := os.Open(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
defer f.Close() defer f.Close()
err = os.Remove(wd + "/mount/file") err = os.Remove(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
if fi, err := f.Stat(); err != nil || !fi.IsRegular() { if fi, err := f.Stat(); err != nil || !fi.IsRegular() {
...@@ -485,10 +485,10 @@ func TestMemUnionFsDoubleOpen(t *testing.T) { ...@@ -485,10 +485,10 @@ func TestMemUnionFsDoubleOpen(t *testing.T) {
err := ioutil.WriteFile(wd+"/ro/file", []byte("blablabla"), 0644) err := ioutil.WriteFile(wd+"/ro/file", []byte("blablabla"), 0644)
CheckSuccess(err) CheckSuccess(err)
roFile, err := os.Open(wd + "/mount/file") roFile, err := os.Open(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
defer roFile.Close() defer roFile.Close()
rwFile, err := os.OpenFile(wd+"/mount/file", os.O_WRONLY|os.O_TRUNC, 0666) rwFile, err := os.OpenFile(wd+"/mnt/file", os.O_WRONLY|os.O_TRUNC, 0666)
CheckSuccess(err) CheckSuccess(err)
defer rwFile.Close() defer rwFile.Close()
...@@ -521,12 +521,12 @@ func TestMemUnionFsUpdate(t *testing.T) { ...@@ -521,12 +521,12 @@ func TestMemUnionFsUpdate(t *testing.T) {
err := ioutil.WriteFile(wd+"/ro/file1", []byte("blablabla"), 0644) err := ioutil.WriteFile(wd+"/ro/file1", []byte("blablabla"), 0644)
CheckSuccess(err) CheckSuccess(err)
_, err = os.Lstat(wd + "/mount/file1") _, err = os.Lstat(wd + "/mnt/file1")
CheckSuccess(err) CheckSuccess(err)
if fi, _ := os.Lstat(wd + "/mount/file2"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/file2"); fi != nil {
t.Fatal("file2 should not exist", fi) t.Fatal("file2 should not exist", fi)
} }
if fi, _ := os.Lstat(wd + "/mount/symlink"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/symlink"); fi != nil {
t.Fatal("symlink should not exist", fi) t.Fatal("symlink should not exist", fi)
} }
...@@ -538,12 +538,12 @@ func TestMemUnionFsUpdate(t *testing.T) { ...@@ -538,12 +538,12 @@ func TestMemUnionFsUpdate(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
// Still have cached attributes. // Still have cached attributes.
fi, err := os.Lstat(wd + "/mount/file1") fi, err := os.Lstat(wd + "/mnt/file1")
CheckSuccess(err) CheckSuccess(err)
if fi, _ := os.Lstat(wd + "/mount/file2"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/file2"); fi != nil {
t.Fatal("file2 should not exist") t.Fatal("file2 should not exist")
} }
if fi, _ := os.Lstat(wd + "/mount/symlink"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/symlink"); fi != nil {
t.Fatal("symlink should not exist", fi) t.Fatal("symlink should not exist", fi)
} }
...@@ -567,17 +567,17 @@ func TestMemUnionFsUpdate(t *testing.T) { ...@@ -567,17 +567,17 @@ func TestMemUnionFsUpdate(t *testing.T) {
ufs.Update(updates) ufs.Update(updates)
// Cached attributes flushed. // Cached attributes flushed.
if fi, _ := os.Lstat(wd + "/mount/file1"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/file1"); fi != nil {
t.Fatal("file1 should have disappeared", fi) t.Fatal("file1 should have disappeared", fi)
} }
fi, err = os.Lstat(wd + "/mount/file2") fi, err = os.Lstat(wd + "/mnt/file2")
CheckSuccess(err) CheckSuccess(err)
if roF2.Mtime_ns != fi.Mtime_ns { if roF2.Mtime_ns != fi.Mtime_ns {
t.Fatalf("file2 attribute mismatch: got %v want %v", fi, roF2) t.Fatalf("file2 attribute mismatch: got %v want %v", fi, roF2)
} }
val, err := os.Readlink(wd + "/mount/symlink") val, err := os.Readlink(wd + "/mnt/symlink")
CheckSuccess(err) CheckSuccess(err)
if val != "target" { if val != "target" {
t.Error("symlink value got %q want %v", val, "target") t.Error("symlink value got %q want %v", val, "target")
...@@ -592,10 +592,10 @@ func TestMemUnionFsFdLeak(t *testing.T) { ...@@ -592,10 +592,10 @@ func TestMemUnionFsFdLeak(t *testing.T) {
err = ioutil.WriteFile(wd+"/ro/file", []byte("blablabla"), 0644) err = ioutil.WriteFile(wd+"/ro/file", []byte("blablabla"), 0644)
CheckSuccess(err) CheckSuccess(err)
contents, err := ioutil.ReadFile(wd + "/mount/file") contents, err := ioutil.ReadFile(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
err = ioutil.WriteFile(wd+"/mount/file", contents, 0644) err = ioutil.WriteFile(wd+"/mnt/file", contents, 0644)
CheckSuccess(err) CheckSuccess(err)
clean() clean()
...@@ -613,7 +613,7 @@ func TestMemUnionFsStatFs(t *testing.T) { ...@@ -613,7 +613,7 @@ func TestMemUnionFsStatFs(t *testing.T) {
defer clean() defer clean()
s1 := syscall.Statfs_t{} s1 := syscall.Statfs_t{}
err := syscall.Statfs(wd+"/mount", &s1) err := syscall.Statfs(wd+"/mnt", &s1)
if err != 0 { if err != 0 {
t.Fatal("statfs mnt", err) t.Fatal("statfs mnt", err)
} }
...@@ -626,7 +626,7 @@ func TestMemUnionFsFlushSize(t *testing.T) { ...@@ -626,7 +626,7 @@ func TestMemUnionFsFlushSize(t *testing.T) {
wd, _, clean := setupMemUfs(t) wd, _, clean := setupMemUfs(t)
defer clean() defer clean()
fn := wd + "/mount/file" fn := wd + "/mnt/file"
f, err := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE, 0644) f, err := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE, 0644)
CheckSuccess(err) CheckSuccess(err)
fi, err := f.Stat() fi, err := f.Stat()
...@@ -647,9 +647,9 @@ func TestMemUnionFsFlushRename(t *testing.T) { ...@@ -647,9 +647,9 @@ func TestMemUnionFsFlushRename(t *testing.T) {
wd, _, clean := setupMemUfs(t) wd, _, clean := setupMemUfs(t)
defer clean() defer clean()
err := ioutil.WriteFile(wd+"/mount/file", []byte("x"), 0644) err := ioutil.WriteFile(wd+"/mnt/file", []byte("x"), 0644)
fn := wd + "/mount/tmp" fn := wd + "/mnt/tmp"
f, err := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE, 0644) f, err := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE, 0644)
CheckSuccess(err) CheckSuccess(err)
fi, err := f.Stat() fi, err := f.Stat()
...@@ -659,7 +659,7 @@ func TestMemUnionFsFlushRename(t *testing.T) { ...@@ -659,7 +659,7 @@ func TestMemUnionFsFlushRename(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
f.Close() f.Close()
dst := wd + "/mount/file" dst := wd + "/mnt/file"
err = os.Rename(fn, dst) err = os.Rename(fn, dst)
CheckSuccess(err) CheckSuccess(err)
...@@ -675,14 +675,14 @@ func TestMemUnionFsTruncGetAttr(t *testing.T) { ...@@ -675,14 +675,14 @@ func TestMemUnionFsTruncGetAttr(t *testing.T) {
defer clean() defer clean()
c := []byte("hello") c := []byte("hello")
f, err := os.OpenFile(wd+"/mount/file", os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0644) f, err := os.OpenFile(wd+"/mnt/file", os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0644)
CheckSuccess(err) CheckSuccess(err)
_, err = f.Write(c) _, err = f.Write(c)
CheckSuccess(err) CheckSuccess(err)
err = f.Close() err = f.Close()
CheckSuccess(err) CheckSuccess(err)
fi, err := os.Lstat(wd + "/mount/file") fi, err := os.Lstat(wd + "/mnt/file")
if fi.Size != int64(len(c)) { if fi.Size != int64(len(c)) {
t.Fatalf("Length mismatch got %d want %d", fi.Size, len(c)) t.Fatalf("Length mismatch got %d want %d", fi.Size, len(c))
} }
...@@ -695,20 +695,20 @@ func TestMemUnionFsRenameDirBasic(t *testing.T) { ...@@ -695,20 +695,20 @@ func TestMemUnionFsRenameDirBasic(t *testing.T) {
err := os.MkdirAll(wd+"/ro/dir/subdir", 0755) err := os.MkdirAll(wd+"/ro/dir/subdir", 0755)
CheckSuccess(err) CheckSuccess(err)
err = os.Rename(wd+"/mount/dir", wd+"/mount/renamed") err = os.Rename(wd+"/mnt/dir", wd+"/mnt/renamed")
CheckSuccess(err) CheckSuccess(err)
if fi, _ := os.Lstat(wd + "/mount/dir"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/dir"); fi != nil {
t.Fatalf("%s/mount/dir should have disappeared: %v", wd, fi) t.Fatalf("%s/mnt/dir should have disappeared: %v", wd, fi)
} }
if fi, _ := os.Lstat(wd + "/mount/renamed"); fi == nil || !fi.IsDirectory() { if fi, _ := os.Lstat(wd + "/mnt/renamed"); fi == nil || !fi.IsDirectory() {
t.Fatalf("%s/mount/renamed should be directory: %v", wd, fi) t.Fatalf("%s/mnt/renamed should be directory: %v", wd, fi)
} }
entries, err := ioutil.ReadDir(wd + "/mount/renamed") entries, err := ioutil.ReadDir(wd + "/mnt/renamed")
if err != nil || len(entries) != 1 || entries[0].Name != "subdir" { if err != nil || len(entries) != 1 || entries[0].Name != "subdir" {
t.Errorf("readdir(%s/mount/renamed) should have one entry: %v, err %v", wd, entries, err) t.Errorf("readdir(%s/mnt/renamed) should have one entry: %v, err %v", wd, entries, err)
} }
r := ufs.Reap() r := ufs.Reap()
...@@ -716,7 +716,7 @@ func TestMemUnionFsRenameDirBasic(t *testing.T) { ...@@ -716,7 +716,7 @@ func TestMemUnionFsRenameDirBasic(t *testing.T) {
t.Errorf("Reap should del dir, and add renamed/subdir: %v", r) t.Errorf("Reap should del dir, and add renamed/subdir: %v", r)
} }
if err = os.Mkdir(wd+"/mount/dir", 0755); err != nil { if err = os.Mkdir(wd+"/mnt/dir", 0755); err != nil {
t.Errorf("mkdir should succeed %v", err) t.Errorf("mkdir should succeed %v", err)
} }
...@@ -732,7 +732,7 @@ func TestMemUnionFsRenameDirAllSourcesGone(t *testing.T) { ...@@ -732,7 +732,7 @@ func TestMemUnionFsRenameDirAllSourcesGone(t *testing.T) {
err = ioutil.WriteFile(wd+"/ro/dir/file.txt", []byte{42}, 0644) err = ioutil.WriteFile(wd+"/ro/dir/file.txt", []byte{42}, 0644)
CheckSuccess(err) CheckSuccess(err)
err = os.Rename(wd+"/mount/dir", wd+"/mount/renamed") err = os.Rename(wd+"/mnt/dir", wd+"/mnt/renamed")
CheckSuccess(err) CheckSuccess(err)
r := ufs.Reap() r := ufs.Reap()
...@@ -754,38 +754,38 @@ func TestMemUnionFsRenameDirWithDeletions(t *testing.T) { ...@@ -754,38 +754,38 @@ func TestMemUnionFsRenameDirWithDeletions(t *testing.T) {
err = ioutil.WriteFile(wd+"/ro/dir/subdir/file.txt", []byte{42}, 0644) err = ioutil.WriteFile(wd+"/ro/dir/subdir/file.txt", []byte{42}, 0644)
CheckSuccess(err) CheckSuccess(err)
if fi, _ := os.Lstat(wd + "/mount/dir/subdir/file.txt"); fi == nil || !fi.IsRegular() { if fi, _ := os.Lstat(wd + "/mnt/dir/subdir/file.txt"); fi == nil || !fi.IsRegular() {
t.Fatalf("%s/mount/dir/subdir/file.txt should be file: %v", wd, fi) t.Fatalf("%s/mnt/dir/subdir/file.txt should be file: %v", wd, fi)
} }
err = os.Remove(wd + "/mount/dir/file.txt") err = os.Remove(wd + "/mnt/dir/file.txt")
CheckSuccess(err) CheckSuccess(err)
err = os.Rename(wd+"/mount/dir", wd+"/mount/renamed") err = os.Rename(wd+"/mnt/dir", wd+"/mnt/renamed")
CheckSuccess(err) CheckSuccess(err)
if fi, _ := os.Lstat(wd + "/mount/dir/subdir/file.txt"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/dir/subdir/file.txt"); fi != nil {
t.Fatalf("%s/mount/dir/subdir/file.txt should have disappeared: %v", wd, fi) t.Fatalf("%s/mnt/dir/subdir/file.txt should have disappeared: %v", wd, fi)
} }
if fi, _ := os.Lstat(wd + "/mount/dir"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/dir"); fi != nil {
t.Fatalf("%s/mount/dir should have disappeared: %v", wd, fi) t.Fatalf("%s/mnt/dir should have disappeared: %v", wd, fi)
} }
if fi, _ := os.Lstat(wd + "/mount/renamed"); fi == nil || !fi.IsDirectory() { if fi, _ := os.Lstat(wd + "/mnt/renamed"); fi == nil || !fi.IsDirectory() {
t.Fatalf("%s/mount/renamed should be directory: %v", wd, fi) t.Fatalf("%s/mnt/renamed should be directory: %v", wd, fi)
} }
if fi, _ := os.Lstat(wd + "/mount/renamed/file.txt"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/renamed/file.txt"); fi != nil {
t.Fatalf("%s/mount/renamed/file.txt should have disappeared %#v", wd, fi) t.Fatalf("%s/mnt/renamed/file.txt should have disappeared %#v", wd, fi)
} }
if err = os.Mkdir(wd+"/mount/dir", 0755); err != nil { if err = os.Mkdir(wd+"/mnt/dir", 0755); err != nil {
t.Errorf("mkdir should succeed %v", err) t.Errorf("mkdir should succeed %v", err)
} }
if fi, _ := os.Lstat(wd + "/mount/dir/subdir"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/dir/subdir"); fi != nil {
t.Fatalf("%s/mount/dir/subdir should have disappeared %#v", wd, fi) t.Fatalf("%s/mnt/dir/subdir should have disappeared %#v", wd, fi)
} }
} }
...@@ -793,9 +793,9 @@ func TestMemUnionGc(t *testing.T) { ...@@ -793,9 +793,9 @@ func TestMemUnionGc(t *testing.T) {
wd, ufs, clean := setupMemUfs(t) wd, ufs, clean := setupMemUfs(t)
defer clean() defer clean()
writeToFile(wd+"/mount/file1", "other-content") writeToFile(wd+"/mnt/file1", "other-content")
writeToFile(wd+"/mount/file2", "other-content") writeToFile(wd+"/mnt/file2", "other-content")
err := os.Remove(wd + "/mount/file1") err := os.Remove(wd + "/mnt/file1")
CheckSuccess(err) CheckSuccess(err)
ufs.Clear() ufs.Clear()
......
...@@ -41,7 +41,7 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) { ...@@ -41,7 +41,7 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
syscall.Umask(0) syscall.Umask(0)
wd, _ := ioutil.TempDir("", "") wd, _ := ioutil.TempDir("", "")
err := os.Mkdir(wd+"/mount", 0700) err := os.Mkdir(wd+"/mnt", 0700)
fuse.CheckSuccess(err) fuse.CheckSuccess(err)
err = os.Mkdir(wd+"/rw", 0700) err = os.Mkdir(wd+"/rw", 0700)
...@@ -66,7 +66,7 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) { ...@@ -66,7 +66,7 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
pathfs := fuse.NewPathNodeFs(ufs, pathfs := fuse.NewPathNodeFs(ufs,
&fuse.PathNodeFsOptions{ClientInodes: true}) &fuse.PathNodeFsOptions{ClientInodes: true})
state, conn, err := fuse.MountNodeFileSystem(wd+"/mount", pathfs, opts) state, conn, err := fuse.MountNodeFileSystem(wd+"/mnt", pathfs, opts)
CheckSuccess(err) CheckSuccess(err)
conn.Debug = fuse.VerboseTest() conn.Debug = fuse.VerboseTest()
state.Debug = fuse.VerboseTest() state.Debug = fuse.VerboseTest()
...@@ -143,10 +143,10 @@ func TestUnionFsAutocreateDeletionDir(t *testing.T) { ...@@ -143,10 +143,10 @@ func TestUnionFsAutocreateDeletionDir(t *testing.T) {
err := os.Remove(wd + "/rw/DELETIONS") err := os.Remove(wd + "/rw/DELETIONS")
CheckSuccess(err) CheckSuccess(err)
err = os.Mkdir(wd+"/mount/dir", 0755) err = os.Mkdir(wd+"/mnt/dir", 0755)
CheckSuccess(err) CheckSuccess(err)
_, err = ioutil.ReadDir(wd + "/mount/dir") _, err = ioutil.ReadDir(wd + "/mnt/dir")
CheckSuccess(err) CheckSuccess(err)
} }
...@@ -154,10 +154,10 @@ func TestUnionFsSymlink(t *testing.T) { ...@@ -154,10 +154,10 @@ func TestUnionFsSymlink(t *testing.T) {
wd, clean := setupUfs(t) wd, clean := setupUfs(t)
defer clean() defer clean()
err := os.Symlink("/foobar", wd+"/mount/link") err := os.Symlink("/foobar", wd+"/mnt/link")
CheckSuccess(err) CheckSuccess(err)
val, err := os.Readlink(wd + "/mount/link") val, err := os.Readlink(wd + "/mnt/link")
CheckSuccess(err) CheckSuccess(err)
if val != "/foobar" { if val != "/foobar" {
...@@ -172,7 +172,7 @@ func TestUnionFsSymlinkPromote(t *testing.T) { ...@@ -172,7 +172,7 @@ func TestUnionFsSymlinkPromote(t *testing.T) {
err := os.Mkdir(wd+"/ro/subdir", 0755) err := os.Mkdir(wd+"/ro/subdir", 0755)
CheckSuccess(err) CheckSuccess(err)
err = os.Symlink("/foobar", wd+"/mount/subdir/link") err = os.Symlink("/foobar", wd+"/mnt/subdir/link")
CheckSuccess(err) CheckSuccess(err)
} }
...@@ -184,10 +184,10 @@ func TestUnionFsChtimes(t *testing.T) { ...@@ -184,10 +184,10 @@ func TestUnionFsChtimes(t *testing.T) {
err := os.Chtimes(wd+"/ro/file", 42e9, 43e9) err := os.Chtimes(wd+"/ro/file", 42e9, 43e9)
CheckSuccess(err) CheckSuccess(err)
err = os.Chtimes(wd+"/mount/file", 82e9, 83e9) err = os.Chtimes(wd+"/mnt/file", 82e9, 83e9)
CheckSuccess(err) CheckSuccess(err)
fi, err := os.Lstat(wd + "/mount/file") fi, err := os.Lstat(wd + "/mnt/file")
if fi.Atime_ns != 82e9 || fi.Mtime_ns != 83e9 { if fi.Atime_ns != 82e9 || fi.Mtime_ns != 83e9 {
t.Error("Incorrect timestamp", fi) t.Error("Incorrect timestamp", fi)
} }
...@@ -198,7 +198,7 @@ func TestUnionFsChmod(t *testing.T) { ...@@ -198,7 +198,7 @@ func TestUnionFsChmod(t *testing.T) {
defer clean() defer clean()
ro_fn := wd + "/ro/file" ro_fn := wd + "/ro/file"
m_fn := wd + "/mount/file" m_fn := wd + "/mnt/file"
writeToFile(ro_fn, "a") writeToFile(ro_fn, "a")
err := os.Chmod(m_fn, 07070) err := os.Chmod(m_fn, 07070)
CheckSuccess(err) CheckSuccess(err)
...@@ -219,7 +219,7 @@ func TestUnionFsChown(t *testing.T) { ...@@ -219,7 +219,7 @@ func TestUnionFsChown(t *testing.T) {
defer clean() defer clean()
ro_fn := wd + "/ro/file" ro_fn := wd + "/ro/file"
m_fn := wd + "/mount/file" m_fn := wd + "/mnt/file"
writeToFile(ro_fn, "a") writeToFile(ro_fn, "a")
err := os.Chown(m_fn, 0, 0) err := os.Chown(m_fn, 0, 0)
...@@ -234,13 +234,13 @@ func TestUnionFsDelete(t *testing.T) { ...@@ -234,13 +234,13 @@ func TestUnionFsDelete(t *testing.T) {
defer clean() defer clean()
writeToFile(wd+"/ro/file", "a") writeToFile(wd+"/ro/file", "a")
_, err := os.Lstat(wd + "/mount/file") _, err := os.Lstat(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
err = os.Remove(wd + "/mount/file") err = os.Remove(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
_, err = os.Lstat(wd + "/mount/file") _, err = os.Lstat(wd + "/mnt/file")
if err == nil { if err == nil {
t.Fatal("should have disappeared.") t.Fatal("should have disappeared.")
} }
...@@ -267,28 +267,28 @@ func TestUnionFsBasic(t *testing.T) { ...@@ -267,28 +267,28 @@ func TestUnionFsBasic(t *testing.T) {
writeToFile(wd+"/ro/ro1", "a") writeToFile(wd+"/ro/ro1", "a")
writeToFile(wd+"/ro/ro2", "b") writeToFile(wd+"/ro/ro2", "b")
names := dirNames(wd + "/mount") names := dirNames(wd + "/mnt")
expected := map[string]bool{ expected := map[string]bool{
"rw": true, "ro1": true, "ro2": true, "rw": true, "ro1": true, "ro2": true,
} }
checkMapEq(t, names, expected) checkMapEq(t, names, expected)
writeToFile(wd+"/mount/new", "new contents") writeToFile(wd+"/mnt/new", "new contents")
if !fileExists(wd + "/rw/new") { if !fileExists(wd + "/rw/new") {
t.Errorf("missing file in rw layer", names) t.Errorf("missing file in rw layer", names)
} }
contents := readFromFile(wd + "/mount/new") contents := readFromFile(wd + "/mnt/new")
if contents != "new contents" { if contents != "new contents" {
t.Errorf("read mismatch: '%v'", contents) t.Errorf("read mismatch: '%v'", contents)
} }
writeToFile(wd+"/mount/ro1", "promote me") writeToFile(wd+"/mnt/ro1", "promote me")
if !fileExists(wd + "/rw/ro1") { if !fileExists(wd + "/rw/ro1") {
t.Errorf("missing file in rw layer", names) t.Errorf("missing file in rw layer", names)
} }
remove(wd + "/mount/new") remove(wd + "/mnt/new")
names = dirNames(wd + "/mount") names = dirNames(wd + "/mnt")
checkMapEq(t, names, map[string]bool{ checkMapEq(t, names, map[string]bool{
"rw": true, "ro1": true, "ro2": true, "rw": true, "ro1": true, "ro2": true,
}) })
...@@ -303,8 +303,8 @@ func TestUnionFsBasic(t *testing.T) { ...@@ -303,8 +303,8 @@ func TestUnionFsBasic(t *testing.T) {
t.Errorf("Expected 0 entry in %v", names) t.Errorf("Expected 0 entry in %v", names)
} }
remove(wd + "/mount/ro1") remove(wd + "/mnt/ro1")
names = dirNames(wd + "/mount") names = dirNames(wd + "/mnt")
checkMapEq(t, names, map[string]bool{ checkMapEq(t, names, map[string]bool{
"rw": true, "ro2": true, "rw": true, "ro2": true,
}) })
...@@ -327,7 +327,7 @@ func TestUnionFsPromote(t *testing.T) { ...@@ -327,7 +327,7 @@ func TestUnionFsPromote(t *testing.T) {
err := os.Mkdir(wd+"/ro/subdir", 0755) err := os.Mkdir(wd+"/ro/subdir", 0755)
CheckSuccess(err) CheckSuccess(err)
writeToFile(wd+"/ro/subdir/file", "content") writeToFile(wd+"/ro/subdir/file", "content")
writeToFile(wd+"/mount/subdir/file", "other-content") writeToFile(wd+"/mnt/subdir/file", "other-content")
} }
func TestUnionFsCreate(t *testing.T) { func TestUnionFsCreate(t *testing.T) {
...@@ -336,8 +336,8 @@ func TestUnionFsCreate(t *testing.T) { ...@@ -336,8 +336,8 @@ func TestUnionFsCreate(t *testing.T) {
err := os.MkdirAll(wd+"/ro/subdir/sub2", 0755) err := os.MkdirAll(wd+"/ro/subdir/sub2", 0755)
CheckSuccess(err) CheckSuccess(err)
writeToFile(wd+"/mount/subdir/sub2/file", "other-content") writeToFile(wd+"/mnt/subdir/sub2/file", "other-content")
_, err = os.Lstat(wd + "/mount/subdir/sub2/file") _, err = os.Lstat(wd + "/mnt/subdir/sub2/file")
CheckSuccess(err) CheckSuccess(err)
} }
...@@ -346,10 +346,10 @@ func TestUnionFsOpenUndeletes(t *testing.T) { ...@@ -346,10 +346,10 @@ func TestUnionFsOpenUndeletes(t *testing.T) {
defer clean() defer clean()
writeToFile(wd+"/ro/file", "X") writeToFile(wd+"/ro/file", "X")
err := os.Remove(wd + "/mount/file") err := os.Remove(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
writeToFile(wd+"/mount/file", "X") writeToFile(wd+"/mnt/file", "X")
_, err = os.Lstat(wd + "/mount/file") _, err = os.Lstat(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
} }
...@@ -357,7 +357,7 @@ func TestUnionFsMkdir(t *testing.T) { ...@@ -357,7 +357,7 @@ func TestUnionFsMkdir(t *testing.T) {
wd, clean := setupUfs(t) wd, clean := setupUfs(t)
defer clean() defer clean()
dirname := wd + "/mount/subdir" dirname := wd + "/mnt/subdir"
err := os.Mkdir(dirname, 0755) err := os.Mkdir(dirname, 0755)
CheckSuccess(err) CheckSuccess(err)
...@@ -373,7 +373,7 @@ func TestUnionFsMkdirPromote(t *testing.T) { ...@@ -373,7 +373,7 @@ func TestUnionFsMkdirPromote(t *testing.T) {
err := os.MkdirAll(dirname, 0755) err := os.MkdirAll(dirname, 0755)
CheckSuccess(err) CheckSuccess(err)
err = os.Mkdir(wd+"/mount/subdir/subdir2/dir3", 0755) err = os.Mkdir(wd+"/mnt/subdir/subdir2/dir3", 0755)
CheckSuccess(err) CheckSuccess(err)
fi, _ := os.Lstat(wd + "/rw/subdir/subdir2/dir3") fi, _ := os.Lstat(wd + "/rw/subdir/subdir2/dir3")
CheckSuccess(err) CheckSuccess(err)
...@@ -389,7 +389,7 @@ func TestUnionFsRmdirMkdir(t *testing.T) { ...@@ -389,7 +389,7 @@ func TestUnionFsRmdirMkdir(t *testing.T) {
err := os.Mkdir(wd+"/ro/subdir", 0755) err := os.Mkdir(wd+"/ro/subdir", 0755)
CheckSuccess(err) CheckSuccess(err)
dirname := wd + "/mount/subdir" dirname := wd + "/mnt/subdir"
err = os.Remove(dirname) err = os.Remove(dirname)
CheckSuccess(err) CheckSuccess(err)
...@@ -431,24 +431,24 @@ func TestUnionFsRename(t *testing.T) { ...@@ -431,24 +431,24 @@ func TestUnionFsRename(t *testing.T) {
writeToFile(wd+"/rw/file2", "c4") writeToFile(wd+"/rw/file2", "c4")
} }
err := os.Rename(wd+"/mount/file1", wd+"/mount/file2") err := os.Rename(wd+"/mnt/file1", wd+"/mnt/file2")
CheckSuccess(err) CheckSuccess(err)
_, err = os.Lstat(wd + "/mount/file1") _, err = os.Lstat(wd + "/mnt/file1")
if err == nil { if err == nil {
t.Errorf("Should have lost file1") t.Errorf("Should have lost file1")
} }
_, err = os.Lstat(wd + "/mount/file2") _, err = os.Lstat(wd + "/mnt/file2")
CheckSuccess(err) CheckSuccess(err)
err = os.Rename(wd+"/mount/file2", wd+"/mount/file1") err = os.Rename(wd+"/mnt/file2", wd+"/mnt/file1")
CheckSuccess(err) CheckSuccess(err)
_, err = os.Lstat(wd + "/mount/file2") _, err = os.Lstat(wd + "/mnt/file2")
if err == nil { if err == nil {
t.Errorf("Should have lost file2") t.Errorf("Should have lost file2")
} }
_, err = os.Lstat(wd + "/mount/file1") _, err = os.Lstat(wd + "/mnt/file1")
CheckSuccess(err) CheckSuccess(err)
clean() clean()
...@@ -462,23 +462,23 @@ func TestUnionFsRenameDirBasic(t *testing.T) { ...@@ -462,23 +462,23 @@ func TestUnionFsRenameDirBasic(t *testing.T) {
err := os.MkdirAll(wd+"/ro/dir/subdir", 0755) err := os.MkdirAll(wd+"/ro/dir/subdir", 0755)
CheckSuccess(err) CheckSuccess(err)
err = os.Rename(wd+"/mount/dir", wd+"/mount/renamed") err = os.Rename(wd+"/mnt/dir", wd+"/mnt/renamed")
CheckSuccess(err) CheckSuccess(err)
if fi, _ := os.Lstat(wd + "/mount/dir"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/dir"); fi != nil {
t.Fatalf("%s/mount/dir should have disappeared: %v", wd, fi) t.Fatalf("%s/mnt/dir should have disappeared: %v", wd, fi)
} }
if fi, _ := os.Lstat(wd + "/mount/renamed"); fi == nil || !fi.IsDirectory() { if fi, _ := os.Lstat(wd + "/mnt/renamed"); fi == nil || !fi.IsDirectory() {
t.Fatalf("%s/mount/renamed should be directory: %v", wd, fi) t.Fatalf("%s/mnt/renamed should be directory: %v", wd, fi)
} }
entries, err := ioutil.ReadDir(wd + "/mount/renamed") entries, err := ioutil.ReadDir(wd + "/mnt/renamed")
if err != nil || len(entries) != 1 || entries[0].Name != "subdir" { if err != nil || len(entries) != 1 || entries[0].Name != "subdir" {
t.Errorf("readdir(%s/mount/renamed) should have one entry: %v, err %v", wd, entries, err) t.Errorf("readdir(%s/mnt/renamed) should have one entry: %v, err %v", wd, entries, err)
} }
if err = os.Mkdir(wd+"/mount/dir", 0755); err != nil { if err = os.Mkdir(wd+"/mnt/dir", 0755); err != nil {
t.Errorf("mkdir should succeed %v", err) t.Errorf("mkdir should succeed %v", err)
} }
} }
...@@ -494,7 +494,7 @@ func TestUnionFsRenameDirAllSourcesGone(t *testing.T) { ...@@ -494,7 +494,7 @@ func TestUnionFsRenameDirAllSourcesGone(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
freezeRo(wd + "/ro") freezeRo(wd + "/ro")
err = os.Rename(wd+"/mount/dir", wd+"/mount/renamed") err = os.Rename(wd+"/mnt/dir", wd+"/mnt/renamed")
CheckSuccess(err) CheckSuccess(err)
names := dirNames(wd + "/rw/" + testOpts.DeletionDirName) names := dirNames(wd + "/rw/" + testOpts.DeletionDirName)
...@@ -517,38 +517,38 @@ func TestUnionFsRenameDirWithDeletions(t *testing.T) { ...@@ -517,38 +517,38 @@ func TestUnionFsRenameDirWithDeletions(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
freezeRo(wd + "/ro") freezeRo(wd + "/ro")
if fi, _ := os.Lstat(wd + "/mount/dir/subdir/file.txt"); fi == nil || !fi.IsRegular() { if fi, _ := os.Lstat(wd + "/mnt/dir/subdir/file.txt"); fi == nil || !fi.IsRegular() {
t.Fatalf("%s/mount/dir/subdir/file.txt should be file: %v", wd, fi) t.Fatalf("%s/mnt/dir/subdir/file.txt should be file: %v", wd, fi)
} }
err = os.Remove(wd + "/mount/dir/file.txt") err = os.Remove(wd + "/mnt/dir/file.txt")
CheckSuccess(err) CheckSuccess(err)
err = os.Rename(wd+"/mount/dir", wd+"/mount/renamed") err = os.Rename(wd+"/mnt/dir", wd+"/mnt/renamed")
CheckSuccess(err) CheckSuccess(err)
if fi, _ := os.Lstat(wd + "/mount/dir/subdir/file.txt"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/dir/subdir/file.txt"); fi != nil {
t.Fatalf("%s/mount/dir/subdir/file.txt should have disappeared: %v", wd, fi) t.Fatalf("%s/mnt/dir/subdir/file.txt should have disappeared: %v", wd, fi)
} }
if fi, _ := os.Lstat(wd + "/mount/dir"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/dir"); fi != nil {
t.Fatalf("%s/mount/dir should have disappeared: %v", wd, fi) t.Fatalf("%s/mnt/dir should have disappeared: %v", wd, fi)
} }
if fi, _ := os.Lstat(wd + "/mount/renamed"); fi == nil || !fi.IsDirectory() { if fi, _ := os.Lstat(wd + "/mnt/renamed"); fi == nil || !fi.IsDirectory() {
t.Fatalf("%s/mount/renamed should be directory: %v", wd, fi) t.Fatalf("%s/mnt/renamed should be directory: %v", wd, fi)
} }
if fi, _ := os.Lstat(wd + "/mount/renamed/file.txt"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/renamed/file.txt"); fi != nil {
t.Fatalf("%s/mount/renamed/file.txt should have disappeared %#v", wd, fi) t.Fatalf("%s/mnt/renamed/file.txt should have disappeared %#v", wd, fi)
} }
if err = os.Mkdir(wd+"/mount/dir", 0755); err != nil { if err = os.Mkdir(wd+"/mnt/dir", 0755); err != nil {
t.Errorf("mkdir should succeed %v", err) t.Errorf("mkdir should succeed %v", err)
} }
if fi, _ := os.Lstat(wd + "/mount/dir/subdir"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/dir/subdir"); fi != nil {
t.Fatalf("%s/mount/dir/subdir should have disappeared %#v", wd, fi) t.Fatalf("%s/mnt/dir/subdir should have disappeared %#v", wd, fi)
} }
} }
...@@ -559,19 +559,19 @@ func TestUnionFsRenameSymlink(t *testing.T) { ...@@ -559,19 +559,19 @@ func TestUnionFsRenameSymlink(t *testing.T) {
err := os.Symlink("linktarget", wd+"/ro/link") err := os.Symlink("linktarget", wd+"/ro/link")
CheckSuccess(err) CheckSuccess(err)
err = os.Rename(wd+"/mount/link", wd+"/mount/renamed") err = os.Rename(wd+"/mnt/link", wd+"/mnt/renamed")
CheckSuccess(err) CheckSuccess(err)
if fi, _ := os.Lstat(wd + "/mount/link"); fi != nil { if fi, _ := os.Lstat(wd + "/mnt/link"); fi != nil {
t.Fatalf("%s/mount/link should have disappeared: %v", wd, fi) t.Fatalf("%s/mnt/link should have disappeared: %v", wd, fi)
} }
if fi, _ := os.Lstat(wd + "/mount/renamed"); fi == nil || !fi.IsSymlink() { if fi, _ := os.Lstat(wd + "/mnt/renamed"); fi == nil || !fi.IsSymlink() {
t.Fatalf("%s/mount/renamed should be link: %v", wd, fi) t.Fatalf("%s/mnt/renamed should be link: %v", wd, fi)
} }
if link, err := os.Readlink(wd + "/mount/renamed"); err != nil || link != "linktarget" { if link, err := os.Readlink(wd + "/mnt/renamed"); err != nil || link != "linktarget" {
t.Fatalf("readlink(%s/mount/renamed) should point to 'linktarget': %v, err %v", wd, link, err) t.Fatalf("readlink(%s/mnt/renamed) should point to 'linktarget': %v, err %v", wd, link, err)
} }
} }
...@@ -584,7 +584,7 @@ func TestUnionFsWritableDir(t *testing.T) { ...@@ -584,7 +584,7 @@ func TestUnionFsWritableDir(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
freezeRo(wd + "/ro") freezeRo(wd + "/ro")
fi, err := os.Lstat(wd + "/mount/subdir") fi, err := os.Lstat(wd + "/mnt/subdir")
CheckSuccess(err) CheckSuccess(err)
if fi.Permission()&0222 == 0 { if fi.Permission()&0222 == 0 {
t.Errorf("unexpected permission %o", fi.Permission()) t.Errorf("unexpected permission %o", fi.Permission())
...@@ -601,7 +601,7 @@ func TestUnionFsWriteAccess(t *testing.T) { ...@@ -601,7 +601,7 @@ func TestUnionFsWriteAccess(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
freezeRo(wd + "/ro") freezeRo(wd + "/ro")
errno := syscall.Access(wd+"/mount/file", fuse.W_OK) errno := syscall.Access(wd+"/mnt/file", fuse.W_OK)
if errno != 0 { if errno != 0 {
err = os.Errno(errno) err = os.Errno(errno)
CheckSuccess(err) CheckSuccess(err)
...@@ -618,18 +618,18 @@ func TestUnionFsLink(t *testing.T) { ...@@ -618,18 +618,18 @@ func TestUnionFsLink(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
freezeRo(wd + "/ro") freezeRo(wd + "/ro")
err = os.Link(wd+"/mount/file", wd+"/mount/linked") err = os.Link(wd+"/mnt/file", wd+"/mnt/linked")
CheckSuccess(err) CheckSuccess(err)
fi2, err := os.Lstat(wd + "/mount/linked") fi2, err := os.Lstat(wd + "/mnt/linked")
CheckSuccess(err) CheckSuccess(err)
fi1, err := os.Lstat(wd + "/mount/file") fi1, err := os.Lstat(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
if fi1.Ino != fi2.Ino { if fi1.Ino != fi2.Ino {
t.Errorf("inode numbers should be equal for linked files %v, %v", fi1.Ino, fi2.Ino) t.Errorf("inode numbers should be equal for linked files %v, %v", fi1.Ino, fi2.Ino)
} }
c, err := ioutil.ReadFile(wd + "/mount/linked") c, err := ioutil.ReadFile(wd + "/mnt/linked")
if string(c) != content { if string(c) != content {
t.Errorf("content mismatch got %q want %q", string(c), content) t.Errorf("content mismatch got %q want %q", string(c), content)
} }
...@@ -642,8 +642,8 @@ func TestUnionFsTruncate(t *testing.T) { ...@@ -642,8 +642,8 @@ func TestUnionFsTruncate(t *testing.T) {
writeToFile(wd+"/ro/file", "hello") writeToFile(wd+"/ro/file", "hello")
freezeRo(wd + "/ro") freezeRo(wd + "/ro")
os.Truncate(wd+"/mount/file", 2) os.Truncate(wd+"/mnt/file", 2)
content := readFromFile(wd + "/mount/file") content := readFromFile(wd + "/mnt/file")
if content != "he" { if content != "he" {
t.Errorf("unexpected content %v", content) t.Errorf("unexpected content %v", content)
} }
...@@ -658,7 +658,7 @@ func TestUnionFsCopyChmod(t *testing.T) { ...@@ -658,7 +658,7 @@ func TestUnionFsCopyChmod(t *testing.T) {
defer clean() defer clean()
contents := "hello" contents := "hello"
fn := wd + "/mount/y" fn := wd + "/mnt/y"
err := ioutil.WriteFile(fn, []byte(contents), 0644) err := ioutil.WriteFile(fn, []byte(contents), 0644)
CheckSuccess(err) CheckSuccess(err)
...@@ -690,7 +690,7 @@ func TestUnionFsTruncateTimestamp(t *testing.T) { ...@@ -690,7 +690,7 @@ func TestUnionFsTruncateTimestamp(t *testing.T) {
defer clean() defer clean()
contents := "hello" contents := "hello"
fn := wd + "/mount/y" fn := wd + "/mnt/y"
err := ioutil.WriteFile(fn, []byte(contents), 0644) err := ioutil.WriteFile(fn, []byte(contents), 0644)
CheckSuccess(err) CheckSuccess(err)
time.Sleep(0.2e9) time.Sleep(0.2e9)
...@@ -720,7 +720,7 @@ func TestUnionFsRemoveAll(t *testing.T) { ...@@ -720,7 +720,7 @@ func TestUnionFsRemoveAll(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
freezeRo(wd + "/ro") freezeRo(wd + "/ro")
err = os.RemoveAll(wd + "/mount/dir") err = os.RemoveAll(wd + "/mnt/dir")
if err != nil { if err != nil {
t.Error("Should delete all") t.Error("Should delete all")
} }
...@@ -753,7 +753,7 @@ func TestUnionFsRmRf(t *testing.T) { ...@@ -753,7 +753,7 @@ func TestUnionFsRmRf(t *testing.T) {
bin, err := exec.LookPath("rm") bin, err := exec.LookPath("rm")
CheckSuccess(err) CheckSuccess(err)
cmd := exec.Command(bin, "-rf", wd+"/mount/dir") cmd := exec.Command(bin, "-rf", wd+"/mnt/dir")
err = cmd.Run() err = cmd.Run()
if err != nil { if err != nil {
t.Fatal("rm -rf returned error:", err) t.Fatal("rm -rf returned error:", err)
...@@ -790,11 +790,11 @@ func TestUnionFsDropDeletionCache(t *testing.T) { ...@@ -790,11 +790,11 @@ func TestUnionFsDropDeletionCache(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
freezeRo(wd + "/ro") freezeRo(wd + "/ro")
_, err = os.Lstat(wd + "/mount/file") _, err = os.Lstat(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
err = os.Remove(wd + "/mount/file") err = os.Remove(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
fi, _ := os.Lstat(wd + "/mount/file") fi, _ := os.Lstat(wd + "/mnt/file")
if fi != nil { if fi != nil {
t.Fatal("Lstat() should have failed", fi) t.Fatal("Lstat() should have failed", fi)
} }
...@@ -805,16 +805,16 @@ func TestUnionFsDropDeletionCache(t *testing.T) { ...@@ -805,16 +805,16 @@ func TestUnionFsDropDeletionCache(t *testing.T) {
t.Fatal("unexpected names", names) t.Fatal("unexpected names", names)
} }
os.Remove(wd + "/rw/DELETIONS/" + names[0]) os.Remove(wd + "/rw/DELETIONS/" + names[0])
fi, _ = os.Lstat(wd + "/mount/file") fi, _ = os.Lstat(wd + "/mnt/file")
if fi != nil { if fi != nil {
t.Fatal("Lstat() should have failed", fi) t.Fatal("Lstat() should have failed", fi)
} }
// Expire kernel entry. // Expire kernel entry.
time.Sleep(0.6e9 * entryTtl) time.Sleep(0.6e9 * entryTtl)
err = ioutil.WriteFile(wd+"/mount/.drop_cache", []byte(""), 0644) err = ioutil.WriteFile(wd+"/mnt/.drop_cache", []byte(""), 0644)
CheckSuccess(err) CheckSuccess(err)
_, err = os.Lstat(wd + "/mount/file") _, err = os.Lstat(wd + "/mnt/file")
if err != nil { if err != nil {
t.Fatal("Lstat() should have succeeded", err) t.Fatal("Lstat() should have succeeded", err)
} }
...@@ -827,25 +827,25 @@ func TestUnionFsDropCache(t *testing.T) { ...@@ -827,25 +827,25 @@ func TestUnionFsDropCache(t *testing.T) {
err := ioutil.WriteFile(wd+"/ro/file", []byte("bla"), 0644) err := ioutil.WriteFile(wd+"/ro/file", []byte("bla"), 0644)
CheckSuccess(err) CheckSuccess(err)
_, err = os.Lstat(wd + "/mount/.drop_cache") _, err = os.Lstat(wd + "/mnt/.drop_cache")
CheckSuccess(err) CheckSuccess(err)
names, err := Readdirnames(wd + "/mount") names, err := Readdirnames(wd + "/mnt")
CheckSuccess(err) CheckSuccess(err)
if len(names) != 1 || names[0] != "file" { if len(names) != 1 || names[0] != "file" {
t.Fatal("unexpected names", names) t.Fatal("unexpected names", names)
} }
err = ioutil.WriteFile(wd+"/ro/file2", []byte("blabla"), 0644) err = ioutil.WriteFile(wd+"/ro/file2", []byte("blabla"), 0644)
names2, err := Readdirnames(wd + "/mount") names2, err := Readdirnames(wd + "/mnt")
CheckSuccess(err) CheckSuccess(err)
if len(names2) != len(names) { if len(names2) != len(names) {
t.Fatal("mismatch", names2) t.Fatal("mismatch", names2)
} }
err = ioutil.WriteFile(wd+"/mount/.drop_cache", []byte("does not matter"), 0644) err = ioutil.WriteFile(wd+"/mnt/.drop_cache", []byte("does not matter"), 0644)
CheckSuccess(err) CheckSuccess(err)
names2, err = Readdirnames(wd + "/mount") names2, err = Readdirnames(wd + "/mnt")
if len(names2) != 2 { if len(names2) != 2 {
t.Fatal("mismatch 2", names2) t.Fatal("mismatch 2", names2)
} }
...@@ -856,7 +856,7 @@ func TestUnionFsDisappearing(t *testing.T) { ...@@ -856,7 +856,7 @@ func TestUnionFsDisappearing(t *testing.T) {
// writable Fs. // writable Fs.
wd, _ := ioutil.TempDir("", "") wd, _ := ioutil.TempDir("", "")
defer os.RemoveAll(wd) defer os.RemoveAll(wd)
err := os.Mkdir(wd+"/mount", 0700) err := os.Mkdir(wd+"/mnt", 0700)
fuse.CheckSuccess(err) fuse.CheckSuccess(err)
err = os.Mkdir(wd+"/rw", 0700) err = os.Mkdir(wd+"/rw", 0700)
...@@ -877,7 +877,7 @@ func TestUnionFsDisappearing(t *testing.T) { ...@@ -877,7 +877,7 @@ func TestUnionFsDisappearing(t *testing.T) {
NegativeTimeout: entryTtl, NegativeTimeout: entryTtl,
} }
state, _, err := fuse.MountPathFileSystem(wd+"/mount", ufs, opts) state, _, err := fuse.MountPathFileSystem(wd+"/mnt", ufs, opts)
CheckSuccess(err) CheckSuccess(err)
defer state.Unmount() defer state.Unmount()
state.Debug = fuse.VerboseTest() state.Debug = fuse.VerboseTest()
...@@ -889,20 +889,20 @@ func TestUnionFsDisappearing(t *testing.T) { ...@@ -889,20 +889,20 @@ func TestUnionFsDisappearing(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
freezeRo(wd + "/ro") freezeRo(wd + "/ro")
err = os.Remove(wd + "/mount/file") err = os.Remove(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
oldRoot := wrFs.Root oldRoot := wrFs.Root
wrFs.Root = "/dev/null" wrFs.Root = "/dev/null"
time.Sleep(1.5 * entryTtl * 1e9) time.Sleep(1.5 * entryTtl * 1e9)
_, err = ioutil.ReadDir(wd + "/mount") _, err = ioutil.ReadDir(wd + "/mnt")
if err == nil { if err == nil {
t.Fatal("Readdir should have failed") t.Fatal("Readdir should have failed")
} }
log.Println("expected readdir failure:", err) log.Println("expected readdir failure:", err)
err = ioutil.WriteFile(wd+"/mount/file2", []byte("blabla"), 0644) err = ioutil.WriteFile(wd+"/mnt/file2", []byte("blabla"), 0644)
if err == nil { if err == nil {
t.Fatal("write should have failed") t.Fatal("write should have failed")
} }
...@@ -912,11 +912,11 @@ func TestUnionFsDisappearing(t *testing.T) { ...@@ -912,11 +912,11 @@ func TestUnionFsDisappearing(t *testing.T) {
wrFs.Root = oldRoot wrFs.Root = oldRoot
time.Sleep(1.5 * entryTtl * 1e9) time.Sleep(1.5 * entryTtl * 1e9)
_, err = ioutil.ReadDir(wd + "/mount") _, err = ioutil.ReadDir(wd + "/mnt")
if err != nil { if err != nil {
t.Fatal("Readdir should succeed", err) t.Fatal("Readdir should succeed", err)
} }
err = ioutil.WriteFile(wd+"/mount/file2", []byte("blabla"), 0644) err = ioutil.WriteFile(wd+"/mnt/file2", []byte("blabla"), 0644)
if err != nil { if err != nil {
t.Fatal("write should succeed", err) t.Fatal("write should succeed", err)
} }
...@@ -930,11 +930,11 @@ func TestUnionFsDeletedGetAttr(t *testing.T) { ...@@ -930,11 +930,11 @@ func TestUnionFsDeletedGetAttr(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
freezeRo(wd + "/ro") freezeRo(wd + "/ro")
f, err := os.Open(wd + "/mount/file") f, err := os.Open(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
defer f.Close() defer f.Close()
err = os.Remove(wd + "/mount/file") err = os.Remove(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
if fi, err := f.Stat(); err != nil || !fi.IsRegular() { if fi, err := f.Stat(); err != nil || !fi.IsRegular() {
...@@ -949,10 +949,10 @@ func TestUnionFsDoubleOpen(t *testing.T) { ...@@ -949,10 +949,10 @@ func TestUnionFsDoubleOpen(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
freezeRo(wd + "/ro") freezeRo(wd + "/ro")
roFile, err := os.Open(wd + "/mount/file") roFile, err := os.Open(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
defer roFile.Close() defer roFile.Close()
rwFile, err := os.OpenFile(wd+"/mount/file", os.O_WRONLY|os.O_TRUNC, 0666) rwFile, err := os.OpenFile(wd+"/mnt/file", os.O_WRONLY|os.O_TRUNC, 0666)
CheckSuccess(err) CheckSuccess(err)
defer rwFile.Close() defer rwFile.Close()
...@@ -987,10 +987,10 @@ func TestUnionFsFdLeak(t *testing.T) { ...@@ -987,10 +987,10 @@ func TestUnionFsFdLeak(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
freezeRo(wd + "/ro") freezeRo(wd + "/ro")
contents, err := ioutil.ReadFile(wd + "/mount/file") contents, err := ioutil.ReadFile(wd + "/mnt/file")
CheckSuccess(err) CheckSuccess(err)
err = ioutil.WriteFile(wd+"/mount/file", contents, 0644) err = ioutil.WriteFile(wd+"/mnt/file", contents, 0644)
CheckSuccess(err) CheckSuccess(err)
clean() clean()
...@@ -1008,7 +1008,7 @@ func TestUnionFsStatFs(t *testing.T) { ...@@ -1008,7 +1008,7 @@ func TestUnionFsStatFs(t *testing.T) {
defer clean() defer clean()
s1 := syscall.Statfs_t{} s1 := syscall.Statfs_t{}
err := syscall.Statfs(wd+"/mount", &s1) err := syscall.Statfs(wd+"/mnt", &s1)
if err != 0 { if err != 0 {
t.Fatal("statfs mnt", err) t.Fatal("statfs mnt", err)
} }
...@@ -1021,7 +1021,7 @@ func TestUnionFsFlushSize(t *testing.T) { ...@@ -1021,7 +1021,7 @@ func TestUnionFsFlushSize(t *testing.T) {
wd, clean := setupUfs(t) wd, clean := setupUfs(t)
defer clean() defer clean()
fn := wd + "/mount/file" fn := wd + "/mnt/file"
f, err := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE, 0644) f, err := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE, 0644)
CheckSuccess(err) CheckSuccess(err)
fi, err := f.Stat() fi, err := f.Stat()
...@@ -1042,9 +1042,9 @@ func TestUnionFsFlushRename(t *testing.T) { ...@@ -1042,9 +1042,9 @@ func TestUnionFsFlushRename(t *testing.T) {
wd, clean := setupUfs(t) wd, clean := setupUfs(t)
defer clean() defer clean()
err := ioutil.WriteFile(wd+"/mount/file", []byte("x"), 0644) err := ioutil.WriteFile(wd+"/mnt/file", []byte("x"), 0644)
fn := wd + "/mount/tmp" fn := wd + "/mnt/tmp"
f, err := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE, 0644) f, err := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE, 0644)
CheckSuccess(err) CheckSuccess(err)
fi, err := f.Stat() fi, err := f.Stat()
...@@ -1054,7 +1054,7 @@ func TestUnionFsFlushRename(t *testing.T) { ...@@ -1054,7 +1054,7 @@ func TestUnionFsFlushRename(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
f.Close() f.Close()
dst := wd + "/mount/file" dst := wd + "/mnt/file"
err = os.Rename(fn, dst) err = os.Rename(fn, dst)
CheckSuccess(err) CheckSuccess(err)
...@@ -1070,14 +1070,14 @@ func TestUnionFsTruncGetAttr(t *testing.T) { ...@@ -1070,14 +1070,14 @@ func TestUnionFsTruncGetAttr(t *testing.T) {
defer clean() defer clean()
c := []byte("hello") c := []byte("hello")
f, err := os.OpenFile(wd+"/mount/file", os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0644) f, err := os.OpenFile(wd+"/mnt/file", os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0644)
CheckSuccess(err) CheckSuccess(err)
_, err = f.Write(c) _, err = f.Write(c)
CheckSuccess(err) CheckSuccess(err)
err = f.Close() err = f.Close()
CheckSuccess(err) CheckSuccess(err)
fi, err := os.Lstat(wd + "/mount/file") fi, err := os.Lstat(wd + "/mnt/file")
if fi.Size != int64(len(c)) { if fi.Size != int64(len(c)) {
t.Fatalf("Length mismatch got %d want %d", fi.Size, len(c)) t.Fatalf("Length mismatch got %d want %d", fi.Size, len(c))
} }
...@@ -1093,7 +1093,7 @@ func TestUnionFsPromoteDirTimeStamp(t *testing.T) { ...@@ -1093,7 +1093,7 @@ func TestUnionFsPromoteDirTimeStamp(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
freezeRo(wd + "/ro") freezeRo(wd + "/ro")
err = os.Chmod(wd+"/mount/subdir/file", 0060) err = os.Chmod(wd+"/mnt/subdir/file", 0060)
CheckSuccess(err) CheckSuccess(err)
fRo, err := os.Lstat(wd + "/ro/subdir") fRo, err := os.Lstat(wd + "/ro/subdir")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment