From 214ac585b0324df257add21167a5b1c810b3def8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Doma=C5=84ski?= Date: Fri, 28 Feb 2020 21:50:22 +0100 Subject: [PATCH] tests: don't panic after failing to run Ignition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds a nil check for cmd.Process.Pid to prevent a nil pointer dereference when running Ignition fails. Signed-off-by: Kamil DomaƄski --- tests/filesystem.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/filesystem.go b/tests/filesystem.go index 708ff02ed..f91b5c523 100644 --- a/tests/filesystem.go +++ b/tests/filesystem.go @@ -155,7 +155,9 @@ func runIgnition(t *testing.T, ctx context.Context, stage, root, cwd string, app cmd.Dir = cwd cmd.Env = append(os.Environ(), appendEnv...) out, err := cmd.CombinedOutput() - t.Logf("PID: %d", cmd.Process.Pid) + if cmd != nil && cmd.Process != nil { + t.Logf("PID: %d", cmd.Process.Pid) + } t.Logf("Ignition output:\n%s", string(out)) if strings.Contains(string(out), "panic") { return fmt.Errorf("ignition panicked")