iotests: Add test for commit in sub directory

Add a test for committing an overlay in a sub directory to one of the
images in its backing chain, using both relative and absolute filenames.

Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Max Reitz 2018-08-06 23:33:07 +02:00 committed by Kevin Wolf
parent 5f71c6b004
commit 6c3e110642
2 changed files with 54 additions and 0 deletions

View File

@ -31,6 +31,11 @@ _cleanup()
_cleanup_test_img
_rm_test_img "$TEST_IMG.base"
_rm_test_img "$TEST_IMG.orig"
_rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base"
_rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.mid"
_rm_test_img "$TEST_DIR/subdir/t.$IMGFMT"
rmdir "$TEST_DIR/subdir" &> /dev/null
}
trap "_cleanup; exit \$status" 0 1 2 3 15
@ -139,6 +144,45 @@ $QEMU_IO -c 'writev 0 64k' "$TEST_IMG" | _filter_qemu_io
$QEMU_IMG commit "$TEST_IMG"
_cleanup
echo
echo 'Testing commit in sub-directory with relative filenames'
echo
pushd "$TEST_DIR" > /dev/null
mkdir subdir
TEST_IMG="subdir/t.$IMGFMT.base" _make_test_img 1M
TEST_IMG="subdir/t.$IMGFMT.mid" _make_test_img -b "t.$IMGFMT.base" -F $IMGFMT
TEST_IMG="subdir/t.$IMGFMT" _make_test_img -b "t.$IMGFMT.mid" -F $IMGFMT
# Should work
$QEMU_IMG commit -b "t.$IMGFMT.mid" "subdir/t.$IMGFMT"
# Might theoretically work, but does not in practice (we have to
# decide between this and the above; and since we always represent
# backing file names as relative to the overlay, we go for the above)
$QEMU_IMG commit -b "subdir/t.$IMGFMT.mid" "subdir/t.$IMGFMT" 2>&1 | \
_filter_imgfmt
# This should work as well
$QEMU_IMG commit -b "$TEST_DIR/subdir/t.$IMGFMT.mid" "subdir/t.$IMGFMT"
popd > /dev/null
# Now let's try with just absolute filenames
# (This will not work with external data files, though, because when
# using relative paths for those, qemu will always resolve them
# relative to its CWD. Therefore, it cannot find those data files now
# that we left $TEST_DIR.)
if _get_data_file '' > /dev/null; then
echo 'Image committed.' # Skip test
else
$QEMU_IMG commit -b "$TEST_DIR/subdir/t.$IMGFMT.mid" \
"$TEST_DIR/subdir/t.$IMGFMT"
fi
# success, all done
echo "*** done"
rm -f $seq.full

View File

@ -1083,4 +1083,14 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=json:{'driv
wrote 65536/65536 bytes at offset 0
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
qemu-img: Block job failed: No space left on device
Testing commit in sub-directory with relative filenames
Formatting 'subdir/t.IMGFMT.base', fmt=IMGFMT size=1048576
Formatting 'subdir/t.IMGFMT.mid', fmt=IMGFMT size=1048576 backing_file=t.IMGFMT.base backing_fmt=IMGFMT
Formatting 'subdir/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=t.IMGFMT.mid backing_fmt=IMGFMT
Image committed.
qemu-img: Did not find 'subdir/t.IMGFMT.mid' in the backing chain of 'subdir/t.IMGFMT'
Image committed.
Image committed.
*** done