aboutsummaryrefslogtreecommitdiff
path: root/tests/test_helpers
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_helpers')
-rw-r--r--tests/test_helpers/helpers.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_helpers/helpers.go b/tests/test_helpers/helpers.go
index 5c0319e..f92fb79 100644
--- a/tests/test_helpers/helpers.go
+++ b/tests/test_helpers/helpers.go
@@ -400,3 +400,15 @@ func QueryCtlSock(t *testing.T, socketPath string, req ctlsock.RequestStruct) (r
json.Unmarshal(buf, &response)
return response
}
+
+// Extract the exit code from an error value that was returned from
+// exec / cmd.Run()
+func ExtractCmdExitCode(err error) int {
+ if err == nil {
+ return 0
+ }
+ // OMG this is convoluted
+ err2 := err.(*exec.ExitError)
+ code := err2.Sys().(syscall.WaitStatus).ExitStatus()
+ return code
+}