From f1639bca4ba54224b87d3f857b030a11e941473d Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 18 Apr 2018 12:39:21 -0400 Subject: [PATCH] testing: cleanup loopback devices on test skip Fixes a case where loopback devices wouldn't get cleaned up when a test was being skipped Signed-off-by: Christopher Jones --- mount/lookup_test/lookup_linux_test.go | 2 ++ snapshots/overlay/check_test.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mount/lookup_test/lookup_linux_test.go b/mount/lookup_test/lookup_linux_test.go index 5412d96c6..7d7db2223 100644 --- a/mount/lookup_test/lookup_linux_test.go +++ b/mount/lookup_test/lookup_linux_test.go @@ -61,10 +61,12 @@ func testLookup(t *testing.T, fsType string) { } if out, err := exec.Command("mkfs", "-t", fsType, deviceName).CombinedOutput(); err != nil { // not fatal + cleanupDevice() t.Skipf("could not mkfs (%s) %s: %v (out: %q)", fsType, deviceName, err, string(out)) } if out, err := exec.Command("mount", deviceName, mnt).CombinedOutput(); err != nil { // not fatal + cleanupDevice() t.Skipf("could not mount %s: %v (out: %q)", deviceName, err, string(out)) } defer func() { diff --git a/snapshots/overlay/check_test.go b/snapshots/overlay/check_test.go index ec36d800b..2f83939dc 100644 --- a/snapshots/overlay/check_test.go +++ b/snapshots/overlay/check_test.go @@ -41,10 +41,12 @@ func testOverlaySupported(t testing.TB, expected bool, mkfs ...string) { } if out, err := exec.Command(mkfs[0], append(mkfs[1:], deviceName)...).CombinedOutput(); err != nil { // not fatal + cleanupDevice() t.Skipf("could not mkfs (%v) %s: %v (out: %q)", mkfs, deviceName, err, string(out)) } if out, err := exec.Command("mount", deviceName, mnt).CombinedOutput(); err != nil { // not fatal + cleanupDevice() t.Skipf("could not mount %s: %v (out: %q)", deviceName, err, string(out)) } defer func() {