iotests: Use _rm_test_img for deleting test images

Just rm will not delete external data files.  Use _rm_test_img every
time we delete a test image.

(In the process, clean up the indentation of every _cleanup() this patch
touches.)

((Also, use quotes consistently.  I am happy to see unquoted instances
like "rm -rf $TEST_DIR/..." go.))

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-id: 20191107163708.833192-16-mreitz@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Max Reitz 2019-11-07 17:37:01 +01:00
parent 52a97b5a42
commit f91ecbd74e
57 changed files with 118 additions and 95 deletions

View File

@ -30,9 +30,9 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.base"
rm -f "$TEST_IMG.orig"
_cleanup_test_img
_rm_test_img "$TEST_IMG.base"
_rm_test_img "$TEST_IMG.orig"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -28,9 +28,9 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.base"
rm -f "$TEST_IMG.orig"
_cleanup_test_img
_rm_test_img "$TEST_IMG.base"
_rm_test_img "$TEST_IMG.orig"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,12 +29,12 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_DIR/t.$IMGFMT.base_old"
rm -f "$TEST_DIR/t.$IMGFMT.base_new"
_rm_test_img "$TEST_DIR/t.$IMGFMT.base_old"
_rm_test_img "$TEST_DIR/t.$IMGFMT.base_new"
rm -f "$TEST_DIR/subdir/t.$IMGFMT"
rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_old"
rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_new"
_rm_test_img "$TEST_DIR/subdir/t.$IMGFMT"
_rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_old"
_rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_new"
rmdir "$TEST_DIR/subdir" 2> /dev/null
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -32,7 +32,7 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_qemu
rm -f "${TEST_IMG}.copy"
_rm_test_img "${TEST_IMG}.copy"
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -28,7 +28,7 @@ status=1 # failure is the default!
_cleanup()
{
rm -f $TEST_IMG.snap
_rm_test_img "$TEST_IMG.snap"
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,7 +29,9 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG".[123].base
for img in "$TEST_IMG".[123].base; do
_rm_test_img "$img"
done
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -31,7 +31,7 @@ _cleanup()
{
echo "Cleanup"
_cleanup_test_img
rm "${TEST_IMG_FILE2}"
_rm_test_img "${TEST_IMG_FILE2}"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,8 +29,8 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.old"
rm -f "$TEST_IMG.new"
_rm_test_img "$TEST_IMG.old"
_rm_test_img "$TEST_IMG.new"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -28,8 +28,8 @@ status=1 # failure is the default!
_cleanup()
{
rm -f "$TEST_IMG.orig"
_cleanup_test_img
_rm_test_img "$TEST_IMG.orig"
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -42,7 +42,7 @@ _cleanup()
{
nbd_server_stop
_cleanup_test_img
rm -f "$converted_image"
_rm_test_img "$converted_image"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,7 +29,7 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.qcow2"
IMGFMT=qcow2 _rm_test_img "$TEST_IMG.qcow2"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,7 +29,7 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f $TEST_IMG.data
_rm_test_img "$TEST_IMG.data"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,8 +29,10 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.orig" "$TEST_IMG.raw1" "$TEST_IMG.raw2"
_cleanup_test_img
for img in "$TEST_IMG".{orig,raw1,raw2,target}; do
_rm_test_img "$img"
done
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -47,7 +47,7 @@ echo "=== Creating an image with a backing file and deleting that file ==="
echo
TEST_IMG="$TEST_IMG.base" _make_test_img $IMG_SIZE
_make_test_img -b "$TEST_IMG.base" $IMG_SIZE
rm -f "$TEST_IMG.base"
_rm_test_img "$TEST_IMG.base"
# Just open the image and close it right again (this should print an error message)
$QEMU_IO -c quit "$TEST_IMG" 2>&1 | _filter_testdir | _filter_imgfmt

View File

@ -31,7 +31,7 @@ _cleanup()
{
echo "Cleanup"
_cleanup_test_img
rm "${TEST_IMG2}"
_rm_test_img "${TEST_IMG2}"
rm -f "$TEST_DIR/blkdebug.conf"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -28,7 +28,7 @@ status=1 # failure is the default!
_cleanup()
{
rm -f $TEST_IMG.snap
_rm_test_img "$TEST_IMG.snap"
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -28,9 +28,9 @@ status=1 # failure is the default!
_cleanup()
{
rm -rf $TEST_DIR/1.raw
rm -rf $TEST_DIR/2.raw
rm -rf $TEST_DIR/3.raw
_rm_test_img "$TEST_DIR/1.raw"
_rm_test_img "$TEST_DIR/2.raw"
_rm_test_img "$TEST_DIR/3.raw"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -41,10 +41,13 @@ _cleanup()
_cleanup_qemu
for i in $(seq 1 ${SNAPSHOTS})
do
rm -f "${TEST_DIR}/${i}-${snapshot_virt0}"
rm -f "${TEST_DIR}/${i}-${snapshot_virt1}"
_rm_test_img "${TEST_DIR}/${i}-${snapshot_virt0}"
_rm_test_img "${TEST_DIR}/${i}-${snapshot_virt1}"
done
for img in "${TEST_IMG}".{1,2,base}
do
_rm_test_img "$img"
done
rm -f "${TEST_IMG}" "${TEST_IMG}.1" "${TEST_IMG}.2" "${TEST_IMG}.base"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -28,7 +28,7 @@ status=1 # failure is the default!
_cleanup()
{
rm -f $TEST_IMG.snap
_rm_test_img "$TEST_IMG.snap"
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -28,7 +28,7 @@ status=1 # failure is the default!
_cleanup()
{
rm -f $TEST_IMG.snap
_rm_test_img "$TEST_IMG.snap"
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -30,7 +30,7 @@ _cleanup()
{
_cleanup_qemu
_cleanup_test_img
rm -f "$TEST_DIR/source.$IMGFMT"
_rm_test_img "$TEST_DIR/source.$IMGFMT"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -32,8 +32,9 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_qemu
rm -f "${TEST_IMG}.base" "${TEST_IMG}.snp1"
_cleanup_test_img
_rm_test_img "${TEST_IMG}.base"
_rm_test_img "${TEST_IMG}.snp1"
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,7 +29,10 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
_cleanup_test_img
_rm_test_img "$TEST_IMG.compare"
rm -f "$TEST_DIR/blkdebug.conf"
}
trap "_cleanup; exit \$status" 0 1 2 3 15
@ -121,8 +124,6 @@ echo
test_qemu "file.driver=blkdebug,file.image.filename=$TEST_IMG"
rm -f "$TEST_IMG.compare" "$TEST_DIR/blkdebug.conf"
# success, all done
echo "*** done"
rm -f $seq.full

View File

@ -29,8 +29,8 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_qemu
rm -f $TEST_IMG.src
_cleanup_test_img
_rm_test_img "$TEST_IMG.src"
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -28,8 +28,8 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.copy"
_cleanup_test_img
_rm_test_img "$TEST_IMG.copy"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -28,8 +28,10 @@ status=1 # failure is the default!
_cleanup()
{
rm -f "$TEST_IMG".[123]
_cleanup_test_img
for img in "$TEST_IMG".[123]; do
_rm_test_img "$img"
done
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,7 +29,7 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$SRC_IMG"
_rm_test_img "$SRC_IMG"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -30,7 +30,9 @@ _cleanup()
{
_cleanup_qemu
_cleanup_test_img
rm -f "$TEST_DIR"/{b,m,o}.$IMGFMT
for img in "$TEST_DIR"/{b,m,o}.$IMGFMT; do
_rm_test_img "$img"
done
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,7 +29,7 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f $TEST_IMG.snap
_rm_test_img "$TEST_IMG.snap"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -34,7 +34,9 @@ TMP_SNAP2=${TEST_DIR}/tmp2.qcow2
_cleanup()
{
_cleanup_qemu
rm -f "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}"
for img in "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}"; do
_rm_test_img "$img"
done
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -30,13 +30,9 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "${TEST_IMG}.base"
rm -f "${TEST_IMG}.overlay"
rm -f "${TEST_IMG}.convert"
rm -f "${TEST_IMG}.a"
rm -f "${TEST_IMG}.b"
rm -f "${TEST_IMG}.c"
rm -f "${TEST_IMG}.lnk"
for img in "${TEST_IMG}".{base,overlay,convert,a,b,c,lnk}; do
_rm_test_img "$img"
done
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -37,7 +37,9 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_qemu
rm -f "$TEST_IMG"{,.target}{,.backing,.overlay}
for img in "$TEST_IMG"{,.target}{,.backing,.overlay}; do
_rm_test_img "$img"
done
}
trap "_cleanup; exit \$status" 0 1 2 3 15
@ -120,7 +122,9 @@ _send_qemu_cmd $QEMU_HANDLE \
'"status": "null"'
# Remove the source images
rm -f "$TEST_IMG{,.backing,.overlay}"
for img in "$TEST_IMG{,.backing,.overlay}"; do
_rm_test_img "$img"
done
echo

View File

@ -28,7 +28,7 @@ status=1
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.out"
_rm_test_img "$TEST_IMG.out"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -28,7 +28,8 @@ status=1
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.out" "$TEST_IMG.out.dd"
_rm_test_img "$TEST_IMG.out"
_rm_test_img "$TEST_IMG.out.dd"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -30,8 +30,8 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.base"
rm -f "$TEST_IMG.int"
_rm_test_img "$TEST_IMG.base"
_rm_test_img "$TEST_IMG.int"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -28,7 +28,7 @@ status=1
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.out"
_rm_test_img "$TEST_IMG.out"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -28,9 +28,9 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.2"
rm -f "$TEST_IMG.3"
_cleanup_test_img
_rm_test_img "$TEST_IMG.2"
_rm_test_img "$TEST_IMG.3"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,7 +29,8 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_qemu
rm -f "${QEMU_TEST_DIR}/image.base" "${QEMU_TEST_DIR}/image.snp1"
_rm_test_img "${TEST_DIR}/image.base"
_rm_test_img "${TEST_DIR}/image.snp1"
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,7 +29,7 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.converted"
_rm_test_img "$TEST_IMG.converted"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -30,7 +30,7 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.overlay"
_rm_test_img "$TEST_IMG.overlay"
rm -f "$SOCK_DIR/nbd.socket"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -31,7 +31,7 @@ MIG_SOCKET="${SOCK_DIR}/migrate"
_cleanup()
{
rm -f "${MIG_SOCKET}"
rm -f "${TEST_IMG}.dest"
_rm_test_img "${TEST_IMG}.dest"
_cleanup_test_img
_cleanup_qemu
}

View File

@ -28,8 +28,8 @@ status=1 # failure is the default!
_cleanup()
{
rm -f "${TEST_IMG}.mid"
rm -f "${TEST_IMG}.copy"
_rm_test_img "${TEST_IMG}.mid"
_rm_test_img "${TEST_IMG}.copy"
_cleanup_test_img
_cleanup_qemu
}

View File

@ -28,9 +28,9 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.2"
rm -f "$TEST_IMG.3"
_cleanup_test_img
_rm_test_img "$TEST_IMG.2"
_rm_test_img "$TEST_IMG.3"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,7 +29,7 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.converted"
_rm_test_img "$TEST_IMG.converted"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -28,9 +28,9 @@ status=1 # failure is the default!
_cleanup()
{
rm -f "${TEST_IMG}.mid"
rm -f "${TEST_IMG}.ovl2"
rm -f "${TEST_IMG}.ovl3"
_rm_test_img "${TEST_IMG}.mid"
_rm_test_img "${TEST_IMG}.ovl2"
_rm_test_img "${TEST_IMG}.ovl3"
_cleanup_test_img
_cleanup_qemu
}

View File

@ -29,7 +29,7 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.mid"
_rm_test_img "$TEST_IMG.mid"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -43,7 +43,7 @@ esac
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_WRAP"
_rm_test_img "$TEST_WRAP"
rm -f "$BLKDBG_CONF"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -31,7 +31,8 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_qemu
rm -f "${TEST_IMG}" "${BACKING_IMG}"
_rm_test_img "${TEST_IMG}"
_rm_test_img "${BACKING_IMG}"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -40,7 +40,7 @@ esac
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_WRAP"
_rm_test_img "$TEST_WRAP"
rm -f "$BLKDBG_CONF"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,7 +29,7 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.not_base"
_rm_test_img "$TEST_IMG.not_base"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -31,7 +31,8 @@ _cleanup()
{
_cleanup_qemu
_cleanup_test_img
rm -f "$TEST_IMG" "$DEST_IMG"
_rm_test_img "$TEST_IMG"
_rm_test_img "$DEST_IMG"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,7 +29,9 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f $TEST_IMG.[01234]
for img in "$TEST_IMG".[01234]; do
_rm_test_img "$img"
done
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,7 +29,7 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f $TEST_IMG.data
_rm_test_img "$TEST_IMG.data"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,8 +29,8 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f $TEST_IMG.data
rm -f $TEST_IMG.src
_rm_test_img "$TEST_IMG.data"
_rm_test_img "$TEST_IMG.src"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,7 +29,9 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f $TEST_IMG.[01234]
for img in "$TEST_IMG".[01234]; do
_rm_test_img "$img"
done
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -30,8 +30,8 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.base"
rm -f "$TEST_IMG.int"
_rm_test_img "$TEST_IMG.base"
_rm_test_img "$TEST_IMG.int"
}
trap "_cleanup; exit \$status" 0 1 2 3 15

View File

@ -29,7 +29,7 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
rm -f "$TEST_IMG.base_new"
_rm_test_img "$TEST_IMG.base_new"
}
trap "_cleanup; exit \$status" 0 1 2 3 15