test_helpers

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2020 License: MIT Imports: 21 Imported by: 3

Documentation

Index

Constants

View Source
const GocryptfsBinary = "../../gocryptfs"

GocryptfsBinary is the assumed path to the gocryptfs build.

View Source
const UnmountScript = "../fuse-unmount.bash"

UnmountScript is the fusermount/umount compatibility wrapper script

Variables

View Source
var DefaultCipherDir string

DefaultCipherDir is TmpDir + "/default-cipher"

View Source
var DefaultPlainDir string

DefaultPlainDir is TmpDir + "/default-plain"

View Source
var MountInfo map[string]mountInfo

Indexed by mountpoint. Initialized in doInit().

View Source
var TmpDir string

TmpDir is a unique temporary directory. "go test" runs package tests in parallel. We create a unique TmpDir in init() so the tests do not interfere.

View Source
var X255 string

X255 contains 255 uppercase "X". This can be used as a maximum-length filename.

Functions

func Du

func Du(t *testing.T, fd int) (nBytes int64)

Du returns the disk usage of the file "fd" points to, in bytes. Same as "du --block-size=1".

func ExtractCmdExitCode added in v1.6.1

func ExtractCmdExitCode(err error) int

ExtractCmdExitCode extracts the exit code from an error value that was returned from exec / cmd.Run()

func InitFS

func InitFS(t *testing.T, extraArgs ...string) string

InitFS creates a new empty cipherdir and calls

gocryptfs -q -init -extpass "echo test" -scryptn=10 $extraArgs $cipherdir

It returns cipherdir without a trailing slash.

func ListFds added in v1.6.1

func ListFds(pid int, prefix string) []string

ListFds lists the open file descriptors for process "pid". Pass pid=0 for ourselves. Pass a prefix to ignore all paths that do not start with "prefix".

func Md5fn

func Md5fn(filename string) string

Md5fn returns an md5 string for file "filename"

func Md5hex

func Md5hex(buf []byte) string

Md5hex returns an md5 string for "buf"

func Mount

func Mount(c string, p string, showOutput bool, extraArgs ...string) error

Mount CIPHERDIR "c" on PLAINDIR "p" Creates "p" if it does not exist.

Contrary to InitFS(), you MUST passt "-extpass=echo test" (or another way for getting the master key) explicitely.

func MountOrExit

func MountOrExit(c string, p string, extraArgs ...string)

MountOrExit calls Mount() and exits on failure.

Contrary to InitFS(), you MUST passt "-extpass=echo test" (or another way for getting the master key) explicitely.

func MountOrFatal

func MountOrFatal(t *testing.T, c string, p string, extraArgs ...string)

MountOrFatal calls Mount() and calls t.Fatal() on failure.

Contrary to InitFS(), you MUST passt "-extpass=echo test" (or another way for getting the master key) explicitely.

func QueryCtlSock added in v1.2.1

func QueryCtlSock(t *testing.T, socketPath string, req ctlsock.RequestStruct) (response ctlsock.ResponseStruct)

QueryCtlSock sends a request to the control socket at "socketPath" and returns the response.

func ResetTmpDir

func ResetTmpDir(createDirIV bool)

ResetTmpDir deletes TmpDir, create new dir tree:

TmpDir |-- DefaultPlainDir *-- DefaultCipherDir

*-- gocryptfs.diriv

func TestMkdirRmdir

func TestMkdirRmdir(t *testing.T, plainDir string)

TestMkdirRmdir creates and deletes a directory

func TestRename

func TestRename(t *testing.T, plainDir string)

TestRename creates and renames a file

func UnmountErr

func UnmountErr(dir string) (err error)

UnmountErr tries to unmount "dir", retrying 10 times, and returns the resulting error.

func UnmountPanic

func UnmountPanic(dir string)

UnmountPanic tries to umount "dir" and panics on error.

func VerifyExistence

func VerifyExistence(path string) bool

VerifyExistence checks in 3 ways that "path" exists: stat, open, readdir. Returns true if the path exists, false otherwise. Panics if the result is inconsistent.

func VerifySize

func VerifySize(t *testing.T, path string, want int)

VerifySize checks that the file size equals "want". This checks: 1) Number of bytes returned when reading the whole file 2) Size reported by Stat() 3) Size reported by Fstat()

Types

This section is empty.

Jump to

Keyboard shortcuts

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