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 <tophj@linux.vnet.ibm.com>
This commit is contained in:
Christopher Jones 2018-04-18 12:39:21 -04:00
parent e9114e3257
commit f1639bca4b
No known key found for this signature in database
GPG Key ID: 9675B4D446658DE9
2 changed files with 4 additions and 0 deletions

View File

@ -61,10 +61,12 @@ func testLookup(t *testing.T, fsType string) {
} }
if out, err := exec.Command("mkfs", "-t", fsType, deviceName).CombinedOutput(); err != nil { if out, err := exec.Command("mkfs", "-t", fsType, deviceName).CombinedOutput(); err != nil {
// not fatal // not fatal
cleanupDevice()
t.Skipf("could not mkfs (%s) %s: %v (out: %q)", fsType, deviceName, err, string(out)) 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 { if out, err := exec.Command("mount", deviceName, mnt).CombinedOutput(); err != nil {
// not fatal // not fatal
cleanupDevice()
t.Skipf("could not mount %s: %v (out: %q)", deviceName, err, string(out)) t.Skipf("could not mount %s: %v (out: %q)", deviceName, err, string(out))
} }
defer func() { defer func() {

View File

@ -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 { if out, err := exec.Command(mkfs[0], append(mkfs[1:], deviceName)...).CombinedOutput(); err != nil {
// not fatal // not fatal
cleanupDevice()
t.Skipf("could not mkfs (%v) %s: %v (out: %q)", mkfs, deviceName, err, string(out)) 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 { if out, err := exec.Command("mount", deviceName, mnt).CombinedOutput(); err != nil {
// not fatal // not fatal
cleanupDevice()
t.Skipf("could not mount %s: %v (out: %q)", deviceName, err, string(out)) t.Skipf("could not mount %s: %v (out: %q)", deviceName, err, string(out))
} }
defer func() { defer func() {