tets_helpers: handle t=nil in InitFS

The reverse tests call InitFS with t=nil. By
calling panic we get a better error message instead
of a generic nil pointer dereference.
This commit is contained in:
Jakob Unterwurzacher 2017-12-06 23:03:37 +01:00
parent e042eb38fa
commit 6bd2da89d3
1 changed files with 11 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net"
"os"
"os/exec"
@ -110,7 +111,11 @@ func ResetTmpDir(createDirIV bool) {
func InitFS(t *testing.T, extraArgs ...string) string {
dir, err := ioutil.TempDir(TmpDir, "")
if err != nil {
t.Fatal(err)
if t != nil {
t.Fatal(err)
} else {
log.Panic(err)
}
}
args := []string{"-q", "-init", "-extpass", "echo test", "-scryptn=10"}
args = append(args, extraArgs...)
@ -122,7 +127,11 @@ func InitFS(t *testing.T, extraArgs ...string) string {
err = cmd.Run()
if err != nil {
t.Fatalf("InitFS with args %v failed: %v", args, err)
if t != nil {
t.Fatalf("InitFS with args %v failed: %v", args, err)
} else {
log.Panic(err)
}
}
return dir