Beispiel #1
0
func TestInitDirs(t *testing.T) {
	os.Args[0] = "mdfs_test"
	os.RemoveAll(tlfsdir)
	defer os.RemoveAll(tlfsdir)
	if err := os.Mkdir(tlfsdir, 0755); err != nil {
		t.Fatalf("lfs: %s", err)
	}
	dfs, err := lfs.New("	cache", tlfsdir, lfs.RW)
	if err != nil {
		t.Fatalf("lfs: %s", err)
	}
	dfs.SaveAttrs(true)
	dfs.Dbg = moreverb && testing.Verbose()
	fs, err := New("example mdfs", dfs)
	if err != nil {
		t.Fatalf("mdfs: %s", err)
	}
	fs.Dbg = testing.Verbose()
	if fs.Dbg {
		defer func() {
			fs.Dbg = false
			dfs.Dbg = false
			fs.Dump(os.Stdout)
			dfs.Dump(os.Stdout)
		}()
	}
	for _, dn := range fstest.Dirs {
		if err := zx.MkdirAll(fs, dn, zx.Dir{"mode": "0755"}); err != nil {
			t.Fatalf("mkdir: %s", err)
		}
	}
}
Beispiel #2
0
// Create a tree with Dirs and Files at tdir at the given zx tree.
func MkZXTree(t Fataler, fs zx.RWTree) {
	for _, dn := range Dirs {
		if err := zx.MkdirAll(fs, dn, zx.Dir{"mode":"0755"}); err != nil {
			t.Fatalf("mkdir: %s", err)
		}
	}
	for i, fn := range Files {
		data := []byte{}
		for k := 0; k < i*1024; k++ {
			txt := fmt.Sprintf("%s %d\n", Files[i], k)
			data = append(data, txt...)
		}
		if err := zx.PutAll(fs, fn, zx.Dir{"mode": "0644"}, data); err != nil {
			t.Fatalf("putall: %s", err)
		}
		FileData[Files[i]] = data
	}
	for _, fn := range Files {
		if err := TouchZX(fs, fn); err != nil {
			t.Fatalf("touch: %s: %s", fn, err)
		}
	}
	for _, dn := range Dirs {
		if err := TouchZX(fs, dn); err != nil {
			t.Fatalf("touch: %s: %s", dn, err)
		}
	}
}
Beispiel #3
0
func TestInitDirs(t *testing.T) {
	fs, err := New("example mfs")
	if err != nil {
		t.Fatalf("mfs: %s", err)
	}
	fs.Dbg = testing.Verbose()
	if fs.Dbg {
		defer fs.Dump(os.Stdout)
	}
	for _, dn := range fstest.Dirs {
		if err := zx.MkdirAll(fs, dn, zx.Dir{"mode": "0755"}); err != nil {
			t.Fatalf("mkdir: %s", err)
		}
	}
}