SYNOPSYS import "clive/fuse/ostest" const WithMtime = true ... var Dirs = [...]string{"/a", "/a/b", "/a/b/c", "/d", "/e", "/e/f"} ... var GetFPaths = []string{"/1", "/a/a2", "/2"} ... var MkdirPaths = []string{"/nd", "/nd/nd2", "/nd/nd22", "/nd/nd23", "/nd3"} ... var RemovePaths = []string{"/d", "/e/f", "/e", "/a/a2"} ... var PutTests = []PutTest{ PutTest{Path: "/n1"}, PutTest{Path: "/n1"}, PutTest{Path: "/a/n2"}, PutTest{Path: "/", Fails: true}, PutTest{Path: "/a", Fails: true}, PutTest{Path: "/a/b/c/d/e/f", Fails: true}, } var StatTests = []StatTest{ {"/a/b/c", `c drwxr-xr-x`, false}, {"/a", `a drwxr-xr-x`, false}, {"/a/b/c/c3", `c3 -rw-r--r-- 44970`, false}, {"/2", `2 -rw-r--r-- 31658`, false}, {"zz", `no stat`, true}, {"/a/b/c/c5", `no stat`, true}, {"/a/b/../", `a drwxr-xr-x`, false}, } var WstatTests = []WstatTest{ WstatTest{ Path: "/d", Mode: 0700, Mtime: 5, }, WstatTest{ Path: "/e/f", Mode: 0704, Mtime: 500, }, WstatTest{ Path: "/e", Mode: 0704, Mtime: 500, }, WstatTest{ Path: "/a/a2", Mode: 0704, Mtime: 500, }, WstatTest{ Path: "/xxx", Fails: true, }, WstatTest{ Path: "/a/xxx", Fails: true, }, } func All(t Fataler, dirs ...string) func AsAFile(t Fataler, dirs ...string) func AsAFs(t Fataler, dirs ...string) func Children(p string) []string func Diff(meta bool, dirs ...string) ([]string, error) func Gets(t Fataler, dirs ...string) func MkChgs(t Fataler, tdir string) func MkChgs2(t Fataler, tdir string) func MkTree(t Fataler, tdir string) func Mkdirs(t Fataler, dirs ...string) func Puts(t Fataler, dirs ...string) func Removes(t Fataler, dirs ...string) func ResetTime() func RmTree(t Fataler, tdir string) func Stats(t Fataler, dirs ...string) func Touch(path string) func Wstats(t Fataler, dirs ...string) type Fataler interface { ... } type PutTest struct { ... } type StatTest struct { ... } type WstatTest struct { ... } DESCRIPTION Utilities to aid in tests of fuse file systems. Mimics zx/fstest but using OS interfaces. CONSTANTS const ( WithMtime = true WithoutMtime = false ) arg to Diff TYPES type Fataler interface { Fatalf(format string, args ...interface{}) Logf(format string, args ...interface{}) Fail() } Usually testing.T or testing.B type PutTest struct { Path string Mode string Fails bool } type StatTest struct { Path string Res string Fails bool } type WstatTest struct { Path string Mode os.FileMode Mtime int64 Fails bool } FUNCTIONS func All(t Fataler, dirs ...string) func AsAFile(t Fataler, dirs ...string) Make sure /foo behaves as a file issuing calls from 3 fds. func AsAFs(t Fataler, dirs ...string) Perform black box testing of dir1 by performing random FS ops in it and a read OS dir and comparing the trees and the results from the operations. There can be at most one invocation of this function at a time. func Children(p string) []string Return a sorted list of child names for dir at p; ignore /Ctl and dot files func Diff(meta bool, dirs ...string) ([]string, error) Compare trees and report differences func Gets(t Fataler, dirs ...string) func MkChgs(t Fataler, tdir string) Make some changes in the test tree. - Touch /a/a1 - Chmod /a/a2 - Remove /a/b/c /a/b/c/c3 - Create /a/n /a/n/m /a/n/m/m1 func MkChgs2(t Fataler, tdir string) Make some changes in the test tree, another version. - Remove /2 - Create /2/n2 - Truncate /1 func MkTree(t Fataler, tdir string) Create a tree with Dirs and Files at tdir at the underlying OS func Mkdirs(t Fataler, dirs ...string) func Puts(t Fataler, dirs ...string) func Removes(t Fataler, dirs ...string) func ResetTime() Reset the time for files created func RmTree(t Fataler, tdir string) func Stats(t Fataler, dirs ...string) func Touch(path string) set a fake mtime that can be predicted. func Wstats(t Fataler, dirs ...string) VARIABLES var ( // directories created Dirs = [...]string{"/a", "/a/b", "/a/b/c", "/d", "/e", "/e/f"} // files created Files = [...]string{"/1", "/a/a1", "/a/a2", "/a/b/c/c3", "/2"} // data stored in each file FileData = map[string][]byte{} Repeats = 1 ) var ( GetFPaths = []string{"/1", "/a/a2", "/2"} GetDPaths = []string{"/"} GetDOuts = map[string]string{ "/": `1 2 a d e`, } BadPaths = []string{"zz", "/a/b/c/c5"} ) var ( MkdirPaths = []string{"/nd", "/nd/nd2", "/nd/nd22", "/nd/nd23", "/nd3"} BadMkdirPaths = []string{"/", "/nd", "/a", "/1"} ) var ( RemovePaths = []string{"/d", "/e/f", "/e", "/a/a2"} BadRemovePaths = []string{"/", "/xxx", "/a"} ) var PutTests = []PutTest{ PutTest{Path: "/n1"}, PutTest{Path: "/n1"}, PutTest{Path: "/a/n2"}, PutTest{Path: "/", Fails: true}, PutTest{Path: "/a", Fails: true}, PutTest{Path: "/a/b/c/d/e/f", Fails: true}, } var StatTests = []StatTest{ {"/a/b/c", `c drwxr-xr-x`, false}, {"/a", `a drwxr-xr-x`, false}, {"/a/b/c/c3", `c3 -rw-r--r-- 44970`, false}, {"/2", `2 -rw-r--r-- 31658`, false}, {"zz", `no stat`, true}, {"/a/b/c/c5", `no stat`, true}, {"/a/b/../", `a drwxr-xr-x`, false}, } var WstatTests = []WstatTest{ WstatTest{ Path: "/d", Mode: 0700, Mtime: 5, }, WstatTest{ Path: "/e/f", Mode: 0704, Mtime: 500, }, WstatTest{ Path: "/e", Mode: 0704, Mtime: 500, }, WstatTest{ Path: "/a/a2", Mode: 0704, Mtime: 500, }, WstatTest{ Path: "/xxx", Fails: true, }, WstatTest{ Path: "/a/xxx", Fails: true, }, } User's manual, 2nd ed. Section 2 Copyright © LSUB 2014-2016