aboutsummaryrefslogtreecommitdiff
path: root/tests/test_helpers/helpers.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-04-01 21:23:32 +0200
committerJakob Unterwurzacher2018-04-02 16:38:18 +0200
commitf28d85fad599ffaef9a8e1f353911c81a6605d2f (patch)
tree1acc3514a5dde31e88ad13e8dc48818872e40d0f /tests/test_helpers/helpers.go
parentfb06c65ee90e31d11cf37b3469f7d3336ae51184 (diff)
fsck: add initial implementation
Most corruption cases except xattr should be covered. With test filesystem. The output is still pretty ugly. xattr support will be added in the next commits.
Diffstat (limited to 'tests/test_helpers/helpers.go')
-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
+}