diff --git a/fs/dtype_linux_test.go b/fs/dtype_linux_test.go index b702e3101..6e893771e 100644 --- a/fs/dtype_linux_test.go +++ b/fs/dtype_linux_test.go @@ -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() { diff --git a/mount/lookup_test/lookup_linux_test.go b/mount/lookup_test/lookup_linux_test.go index 9ce14bfbb..852053369 100644 --- a/mount/lookup_test/lookup_linux_test.go +++ b/mount/lookup_test/lookup_linux_test.go @@ -39,7 +39,7 @@ func testLookup(t *testing.T, fsType 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) } diff --git a/script/setup/install-protobuf b/script/setup/install-protobuf index 9e0413b13..2087e6547 100755 --- a/script/setup/install-protobuf +++ b/script/setup/install-protobuf @@ -2,7 +2,7 @@ # # Downloads and installs protobuf # -set -eux -o pipefail +set -eu -o pipefail PROTOBUF_VERSION=3.5.1 GOARCH=$(go env GOARCH) diff --git a/script/setup/install-runc b/script/setup/install-runc index 9c4eb5efd..3fbdd62c9 100755 --- a/script/setup/install-runc +++ b/script/setup/install-runc @@ -3,7 +3,7 @@ # Builds and installs runc to /usr/local/go/bin based off # the commit defined in vendor.conf # -set -eux -o pipefail +set -eu -o pipefail RUNC_COMMIT=$(grep opencontainers/runc ${GOPATH}/src/github.com/containerd/containerd/vendor.conf | cut -d " " -f 2) diff --git a/snapshots/btrfs/btrfs_test.go b/snapshots/btrfs/btrfs_test.go index 25954b23a..3ab1927d0 100644 --- a/snapshots/btrfs/btrfs_test.go +++ b/snapshots/btrfs/btrfs_test.go @@ -29,20 +29,23 @@ func boltSnapshotter(t *testing.T) func(context.Context, string) (snapshots.Snap return func(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) { - deviceName, cleanupDevice, err := testutil.NewLoopback(150 << 20) // 150 MB + deviceName, cleanupDevice, err := testutil.NewLoopback(650 << 20) // 650 MB if err != nil { return nil, nil, err } if out, err := exec.Command(mkbtrfs, deviceName).CombinedOutput(); err != nil { + cleanupDevice() return nil, nil, errors.Wrapf(err, "failed to make btrfs filesystem (out: %q)", out) } if out, err := exec.Command("mount", deviceName, root).CombinedOutput(); err != nil { + cleanupDevice() return nil, nil, errors.Wrapf(err, "failed to mount device %s (out: %q)", deviceName, out) } snapshotter, err := NewSnapshotter(root) if err != nil { + cleanupDevice() return nil, nil, errors.Wrap(err, "failed to create new snapshotter") } diff --git a/testutil/loopback_linux.go b/testutil/loopback_linux.go index 635a6c31a..cc573bbaf 100644 --- a/testutil/loopback_linux.go +++ b/testutil/loopback_linux.go @@ -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") }