Commit 4f40cf4c authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

newunionfs: run PosixTest tests.

parent 343e78c2
......@@ -15,6 +15,7 @@ import (
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/internal/testutil"
"github.com/hanwen/go-fuse/nodefs"
"github.com/hanwen/go-fuse/posixtest"
)
type testCase struct {
......@@ -34,11 +35,15 @@ func (tc *testCase) Clean() {
os.RemoveAll(tc.dir)
}
func newTestCase(t *testing.T) *testCase {
func newTestCase(t *testing.T, populate bool) *testCase {
t.Helper()
dir := testutil.TempDir()
dirs := []string{"ro", "rw", "mnt"}
if populate {
dirs = append(dirs, "ro/dir")
}
for _, d := range []string{"ro", "rw", "mnt", "ro/dir"} {
for _, d := range dirs {
if err := os.Mkdir(filepath.Join(dir, d), 0755); err != nil {
t.Fatal("Mkdir", err)
}
......@@ -63,15 +68,17 @@ func newTestCase(t *testing.T) *testCase {
tc.server = server
if err := ioutil.WriteFile(tc.ro+"/dir/ro-file", []byte("bla"), 0644); err != nil {
t.Fatal(err)
if populate {
if err := ioutil.WriteFile(tc.ro+"/dir/ro-file", []byte("bla"), 0644); err != nil {
t.Fatal(err)
}
}
return tc
}
func TestBasic(t *testing.T) {
tc := newTestCase(t)
tc := newTestCase(t, true)
defer tc.Clean()
if fi, err := os.Lstat(tc.mnt + "/dir/ro-file"); err != nil {
......@@ -82,7 +89,7 @@ func TestBasic(t *testing.T) {
}
func TestDelete(t *testing.T) {
tc := newTestCase(t)
tc := newTestCase(t, true)
defer tc.Clean()
if err := os.Remove(tc.mnt + "/dir/ro-file"); err != nil {
......@@ -104,7 +111,7 @@ func TestDelete(t *testing.T) {
}
func TestDeleteMarker(t *testing.T) {
tc := newTestCase(t)
tc := newTestCase(t, true)
defer tc.Clean()
path := "dir/ro-file"
......@@ -125,7 +132,7 @@ func TestDeleteMarker(t *testing.T) {
}
func TestCreate(t *testing.T) {
tc := newTestCase(t)
tc := newTestCase(t, true)
defer tc.Clean()
path := "dir/ro-file"
......@@ -146,7 +153,7 @@ func TestCreate(t *testing.T) {
}
func TestPromote(t *testing.T) {
tc := newTestCase(t)
tc := newTestCase(t, true)
defer tc.Clean()
path := "dir/ro-file"
......@@ -165,7 +172,7 @@ func TestPromote(t *testing.T) {
}
func TestDeleteRevert(t *testing.T) {
tc := newTestCase(t)
tc := newTestCase(t, true)
defer tc.Clean()
path := "dir/ro-file"
......@@ -188,3 +195,28 @@ func TestDeleteRevert(t *testing.T) {
t.Fatalf("Lstat after: got %v, want ENOENT", err)
}
}
func TestPosix(t *testing.T) {
cases := []string{
"SymlinkReadlink",
"FileBasic",
"TruncateFile",
"TruncateNoFile",
"FdLeak",
// "MkdirRmdir",
// "NlinkZero",
"ParallelFileOpen",
// "Link",
// "ReadDir",
}
for _, nm := range cases {
f := posixtest.All[nm]
t.Run(nm, func(t *testing.T) {
tc := newTestCase(t, false)
defer tc.Clean()
f(t, tc.mnt)
})
}
}
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