fuse: bazil.org/fuse/fs/fstestutil Index | Files | Directories

package fstestutil

import "bazil.org/fuse/fs/fstestutil"

Index

Package Files

checkdir.go debug.go doc.go mounted.go mountinfo.go mountinfo_linux.go testfs.go

func CheckDir Uses

func CheckDir(path string, want map[string]FileInfoCheck) error

CheckDir checks the contents of the directory at path, making sure every directory entry listed in want is present. If the check is not nil, it must also pass.

If want contains the impossible filename "", unexpected files are checked with that. If the key is not in want, unexpected files are an error.

Missing entries, that are listed in want but not seen, are an error.

func DebugByDefault Uses

func DebugByDefault()

DebugByDefault changes the default of the `-fuse.debug` flag to true.

This package registers a command line flag `-fuse.debug` and when run with that flag (and activated inside the tests), logs FUSE debug messages.

This is disabled by default, as most callers probably won't care about FUSE details. Use DebugByDefault for tests where you'd normally be passing `-fuse.debug` all the time anyway.

Call from an init function.

type ChildMap Uses

type ChildMap map[string]fs.Node

ChildMap is a directory with child nodes looked up from a map.

func (*ChildMap) Attr Uses

func (f *ChildMap) Attr(ctx context.Context, a *fuse.Attr) error

func (*ChildMap) Lookup Uses

func (f *ChildMap) Lookup(ctx context.Context, name string) (fs.Node, error)

type Dir Uses

type Dir struct{}

Dir can be embedded in a struct to make it look like a directory.

func (Dir) Attr Uses

func (f Dir) Attr(ctx context.Context, a *fuse.Attr) error

type File Uses

type File struct{}

File can be embedded in a struct to make it look like a file.

func (File) Attr Uses

func (f File) Attr(ctx context.Context, a *fuse.Attr) error

type FileInfoCheck Uses

type FileInfoCheck func(fi os.FileInfo) error

FileInfoCheck is a function that validates an os.FileInfo according to some criteria.

type Mount Uses

type Mount struct {
    // Dir is the temporary directory where the filesystem is mounted.
    Dir string

    Conn   *fuse.Conn
    Server *fs.Server

    // Error will receive the return value of Serve.
    Error <-chan error
    // contains filtered or unexported fields
}

Mount contains information about the mount for the test to use.

func Mounted Uses

func Mounted(filesys fs.FS, conf *fs.Config, options ...fuse.MountOption) (*Mount, error)

Mounted mounts the fuse.Server at a temporary directory.

It also waits until the filesystem is known to be visible (OS X workaround).

After successful return, caller must clean up by calling Close.

func MountedFunc Uses

func MountedFunc(fn func(*Mount) fs.FS, conf *fs.Config, options ...fuse.MountOption) (*Mount, error)

MountedFunc mounts a filesystem at a temporary directory. The filesystem used is constructed by calling a function, to allow storing fuse.Conn and fs.Server in the FS.

It also waits until the filesystem is known to be visible (OS X workaround).

After successful return, caller must clean up by calling Close.

func MountedFuncT Uses

func MountedFuncT(t testing.TB, fn func(*Mount) fs.FS, conf *fs.Config, options ...fuse.MountOption) (*Mount, error)

MountedFuncT mounts a filesystem at a temporary directory, directing it's debug log to the testing logger.

See MountedFunc for usage.

The debug log is not enabled by default. Use `-fuse.debug` or call DebugByDefault to enable.

func MountedT Uses

func MountedT(t testing.TB, filesys fs.FS, conf *fs.Config, options ...fuse.MountOption) (*Mount, error)

MountedT mounts the filesystem at a temporary directory, directing it's debug log to the testing logger.

See Mounted for usage.

The debug log is not enabled by default. Use `-fuse.debug` or call DebugByDefault to enable.

func (*Mount) Close Uses

func (mnt *Mount) Close()

Close unmounts the filesystem and waits for fs.Serve to return. Any returned error will be stored in Err. It is safe to call Close multiple times.

type MountInfo Uses

type MountInfo struct {
    FSName string
    Type   string
}

MountInfo describes a mounted file system.

func GetMountInfo Uses

func GetMountInfo(mnt string) (*MountInfo, error)

GetMountInfo finds information about the mount at mnt. It is intended for use by tests only, and only fetches information relevant to the current tests.

type SimpleFS Uses

type SimpleFS struct {
    Node fs.Node
}

SimpleFS is a trivial FS that just implements the Root method.

func (SimpleFS) Root Uses

func (f SimpleFS) Root() (fs.Node, error)

Directories

PathSynopsis
record

Package fstestutil imports 13 packages (graph) and is imported by 55 packages. Updated 2019-09-11. Refresh now. Tools for package owners.