fusetest

package
v0.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2026 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 20 Imported by: 0

Documentation

Overview

Package fusetest provides test helpers shared across FUSE test packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertStatBlocks

func AssertStatBlocks(t *testing.T, path string, wantBlksize uint32)

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

func AssertStatfsNonZero(t *testing.T, path string)

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

func CheckExists(t *testing.T, path string)

CheckExists asserts that path exists.

func Lchtimes

func Lchtimes(path string, mtime time.Time) error

Lchtimes sets mtime on a symlink without following it (lutimes). Go's os package has no Lchtimes, so we call utimensat directly.

func MountError

func MountError(t *testing.T, err error)

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 RandBytes

func RandBytes(size int) []byte

RandBytes returns size random bytes.

func RunWritableSuite

func RunWritableSuite(t *testing.T, mount MountFunc)

RunWritableSuite runs generic writable filesystem tests against the mount produced by mount.

func SkipUnlessFUSE

func SkipUnlessFUSE(t *testing.T)

SkipUnlessFUSE skips the test when FUSE is not available.

Decision order:

  1. TEST_FUSE=0 (or legacy TEST_NO_FUSE=1) → skip
  2. TEST_FUSE=1 → run (CI should set this after installing fuse3)
  3. Neither set → auto-detect based on platform and fusermount in PATH; skip with a helpful message if not found

func TestMount

func TestMount(t *testing.T, root fs.InodeEmbedder, opts *fs.Options) string

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

func VerifyFile(t *testing.T, path string, want []byte)

VerifyFile reads the file at path and asserts its contents match want.

func WriteFile

func WriteFile(size int, path string) ([]byte, error)

WriteFile writes size random bytes to path and returns the data.

func WriteFileOrFail

func WriteFileOrFail(t *testing.T, size int, path string) []byte

WriteFileOrFail calls WriteFile and fails the test on error.

Types

type MountFunc

type MountFunc func(t *testing.T, cfg writable.Config) string

MountFunc creates a fresh writable FUSE mount and returns the root directory path. Cleanup is handled via t.Cleanup.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL