test_helpers: better function comments for InitFS and Mount
It's confusing that you must pass "-extpass" for Mount but not for InitFS. Note that in the comment.
This commit is contained in:
parent
dcd1068517
commit
41dfbe67f8
|
@ -125,10 +125,11 @@ func ResetTmpDir(createDirIV bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitFS calls "gocryptfs -init" on a new directory in TmpDir, passing
|
// InitFS creates a new empty cipherdir and calls
|
||||||
// "extraArgs" in addition to useful defaults.
|
|
||||||
//
|
//
|
||||||
// The returned cipherdir has NO trailing slash.
|
// gocryptfs -q -init -extpass "echo test" -scryptn=10 $extraArgs $cipherdir
|
||||||
|
//
|
||||||
|
// It returns cipherdir without a trailing slash.
|
||||||
func InitFS(t *testing.T, extraArgs ...string) string {
|
func InitFS(t *testing.T, extraArgs ...string) string {
|
||||||
dir, err := ioutil.TempDir(TmpDir, "")
|
dir, err := ioutil.TempDir(TmpDir, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -149,7 +150,7 @@ func InitFS(t *testing.T, extraArgs ...string) string {
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if t != nil {
|
if t != nil {
|
||||||
t.Fatalf("InitFS with args %v failed: %v", args, err)
|
t.Fatalf("InitFS with args %q failed: %v", args, err)
|
||||||
} else {
|
} else {
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,9 @@ type mountInfo struct {
|
||||||
|
|
||||||
// Mount CIPHERDIR "c" on PLAINDIR "p"
|
// Mount CIPHERDIR "c" on PLAINDIR "p"
|
||||||
// Creates "p" if it does not exist.
|
// 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 Mount(c string, p string, showOutput bool, extraArgs ...string) error {
|
func Mount(c string, p string, showOutput bool, extraArgs ...string) error {
|
||||||
args := []string{"-q", "-wpanic", "-nosyslog", "-fg", fmt.Sprintf("-notifypid=%d", os.Getpid())}
|
args := []string{"-q", "-wpanic", "-nosyslog", "-fg", fmt.Sprintf("-notifypid=%d", os.Getpid())}
|
||||||
args = append(args, extraArgs...)
|
args = append(args, extraArgs...)
|
||||||
|
@ -93,6 +96,9 @@ func Mount(c string, p string, showOutput bool, extraArgs ...string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MountOrExit calls Mount() and exits on failure.
|
// 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 MountOrExit(c string, p string, extraArgs ...string) {
|
func MountOrExit(c string, p string, extraArgs ...string) {
|
||||||
err := Mount(c, p, true, extraArgs...)
|
err := Mount(c, p, true, extraArgs...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -102,6 +108,9 @@ func MountOrExit(c string, p string, extraArgs ...string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MountOrFatal calls Mount() and calls t.Fatal() on failure.
|
// 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 MountOrFatal(t *testing.T, c string, p string, extraArgs ...string) {
|
func MountOrFatal(t *testing.T, c string, p string, extraArgs ...string) {
|
||||||
err := Mount(c, p, true, extraArgs...)
|
err := Mount(c, p, true, extraArgs...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue