diff options
| author | Jakob Unterwurzacher | 2017-12-06 23:03:37 +0100 | 
|---|---|---|
| committer | Jakob Unterwurzacher | 2017-12-06 23:03:37 +0100 | 
| commit | 6bd2da89d3753a589a927517771922a0db76bb36 (patch) | |
| tree | 06be6e4eec3700321abec0b096aacd75a0d6b951 /tests | |
| parent | e042eb38fa1990b2539e6e690fd9713487337be1 (diff) | |
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.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_helpers/helpers.go | 13 | 
1 files changed, 11 insertions, 2 deletions
| diff --git a/tests/test_helpers/helpers.go b/tests/test_helpers/helpers.go index 9b81b45..778fd3a 100644 --- a/tests/test_helpers/helpers.go +++ b/tests/test_helpers/helpers.go @@ -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 | 
