Cleanup loop devices after test failure

Cleans up loop devices if part of the test or mount process fails.

Also increases btrfs default file size to 650MB to accommodate
minimum btrfs size on ppc64le and s390x

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
This commit is contained in:
Christopher Jones
2018-01-23 15:27:16 -05:00
parent 051ac5dd63
commit a8c5ff57e5
6 changed files with 13 additions and 5 deletions

View File

@@ -20,16 +20,18 @@ func testSupportsDType(t *testing.T, expected bool, mkfs ...string) {
}
defer os.RemoveAll(mnt)
deviceName, cleanupDevice, err := testutil.NewLoopback(150 << 20) // 150 MB
deviceName, cleanupDevice, err := testutil.NewLoopback(100 << 20) // 100 MB
if err != nil {
t.Fatal(err)
}
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() {