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

@@ -21,6 +21,8 @@ func NewLoopback(size int64) (string, func() error, error) {
}
if err := file.Truncate(size); err != nil {
file.Close()
os.Remove(file.Name())
return "", nil, errors.Wrap(err, "failed to resize temp file")
}
file.Close()
@@ -29,6 +31,7 @@ func NewLoopback(size int64) (string, func() error, error) {
losetup := exec.Command("losetup", "--find", "--show", file.Name())
p, err := losetup.Output()
if err != nil {
os.Remove(file.Name())
return "", nil, errors.Wrap(err, "loopback setup failed")
}