test_helpers

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2018 License: MIT Imports: 17 Imported by: 0

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 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 InitFS

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

InitFS calls "gocryptfs -init" on a new directory in TmpDir, passing "extraArgs" in addition to useful defaults.

The returned cipherdir has NO trailing slash.

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.

func MountOrExit

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

MountOrExit calls Mount() and exits on failure.

func MountOrFatal

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

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

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) error

UnmountErr tries to unmount "dir" 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

func VerifySize

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

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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