Documentation
¶
Overview ¶
Package fusetest provides test helpers shared across FUSE test packages.
Index ¶
- func AssertStatBlocks(t *testing.T, path string, wantBlksize uint32)
- func AssertStatfsNonZero(t *testing.T, path string)
- func CheckExists(t *testing.T, path string)
- func Lchtimes(path string, mtime time.Time) error
- func MountError(t *testing.T, err error)
- func RandBytes(size int) []byte
- func RunWritableSuite(t *testing.T, mount MountFunc)
- func SkipUnlessFUSE(t *testing.T)
- func TestMount(t *testing.T, root fs.InodeEmbedder, opts *fs.Options) string
- func VerifyFile(t *testing.T, path string, want []byte)
- func WriteFile(size int, path string) ([]byte, error)
- func WriteFileOrFail(t *testing.T, size int, path string) []byte
- type MountFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertStatBlocks ¶
AssertStatBlocks stats path and checks that st_blocks matches the file size rounded up to 512-byte units (the POSIX stat convention) and that st_blksize matches wantBlksize. These are the fields du, ls -s, and stat read to report disk usage per entry.
func AssertStatfsNonZero ¶
AssertStatfsNonZero calls syscall.Statfs on path and verifies the result contains real filesystem data (non-zero block counts with Bfree <= Blocks). This avoids the racy pattern of comparing two Statfs snapshots taken at different times.
func CheckExists ¶
CheckExists asserts that path exists.
func Lchtimes ¶
Lchtimes sets mtime on a symlink without following it (lutimes). Go's os package has no Lchtimes, so we call utimensat directly.
func MountError ¶
MountError handles a FUSE mount error. When TEST_FUSE=1 (CI), a mount failure is fatal because the environment is expected to have working FUSE. When auto-detecting (no TEST_FUSE set), mount failures cause a skip.
func RunWritableSuite ¶
RunWritableSuite runs generic writable filesystem tests against the mount produced by mount.
func SkipUnlessFUSE ¶
SkipUnlessFUSE skips the test when FUSE is not available.
Decision order:
- TEST_FUSE=0 (or legacy TEST_NO_FUSE=1) → skip
- TEST_FUSE=1 → run (CI should set this after installing fuse3)
- Neither set → auto-detect based on platform and fusermount in PATH; skip with a helpful message if not found
func TestMount ¶
TestMount mounts root at a temp directory with the given options and registers an unmount cleanup. Returns the mount directory path. Callers set mount-specific options (timeouts, MaxReadAhead, etc.) before calling; this helper adds NullPermissions, UID, and GID.
func VerifyFile ¶
VerifyFile reads the file at path and asserts its contents match want.