Skip to content

Commit

Permalink
iotests: Replace IMGOPTS= by -o
Browse files Browse the repository at this point in the history
Tests should not overwrite all user-supplied image options, but only add
to it (which will effectively overwrite conflicting values).  Accomplish
this by passing options to _make_test_img via -o instead of $IMGOPTS.

For some tests, there is no functional change because they already only
appended options to IMGOPTS.  For these, this patch is just a
simplification.

For others, this is a change, so they now heed user-specified $IMGOPTS.
Some of those tests do not work with all image options, though, so we
need to disable them accordingly.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-id: 20191107163708.833192-12-mreitz@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
  • Loading branch information
XanClic committed Jan 6, 2020
1 parent 1c6d2f2 commit 407fb56
Show file tree
Hide file tree
Showing 22 changed files with 100 additions and 101 deletions.
9 changes: 6 additions & 3 deletions tests/qemu-iotests/031
Expand Up @@ -40,19 +40,22 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
# This tests qcow2-specific low-level functionality
_supported_fmt qcow2
_supported_proto file
# We want to test compat=0.10, which does not support refcount widths
# other than 16
_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)'

CLUSTER_SIZE=65536

# qcow2.py output depends on the exact options used, so override the command
# line here as an exception
for IMGOPTS in "compat=0.10" "compat=1.1"; do
for compat in "compat=0.10" "compat=1.1"; do

echo
echo ===== Testing with -o $IMGOPTS =====
echo ===== Testing with -o $compat =====
echo
echo === Create image with unknown header extension ===
echo
_make_test_img 64M
_make_test_img -o $compat 64M
$PYTHON qcow2.py "$TEST_IMG" add-header-ext 0x12345678 "This is a test header extension"
$PYTHON qcow2.py "$TEST_IMG" dump-header
_check_test_img
Expand Down
24 changes: 8 additions & 16 deletions tests/qemu-iotests/039
Expand Up @@ -50,8 +50,7 @@ size=128M
echo
echo "== Checking that image is clean on shutdown =="

IMGOPTS="compat=1.1,lazy_refcounts=on"
_make_test_img $size
_make_test_img -o "compat=1.1,lazy_refcounts=on" $size

$QEMU_IO -c "write -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io

Expand All @@ -62,8 +61,7 @@ _check_test_img
echo
echo "== Creating a dirty image file =="

IMGOPTS="compat=1.1,lazy_refcounts=on"
_make_test_img $size
_make_test_img -o "compat=1.1,lazy_refcounts=on" $size

_NO_VALGRIND \
$QEMU_IO -c "write -P 0x5a 0 512" \
Expand Down Expand Up @@ -98,8 +96,7 @@ $QEMU_IO -c "read -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io
echo
echo "== Opening a dirty image read/write should repair it =="

IMGOPTS="compat=1.1,lazy_refcounts=on"
_make_test_img $size
_make_test_img -o "compat=1.1,lazy_refcounts=on" $size

_NO_VALGRIND \
$QEMU_IO -c "write -P 0x5a 0 512" \
Expand All @@ -117,8 +114,7 @@ $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
echo
echo "== Creating an image file with lazy_refcounts=off =="

IMGOPTS="compat=1.1,lazy_refcounts=off"
_make_test_img $size
_make_test_img -o "compat=1.1,lazy_refcounts=off" $size

_NO_VALGRIND \
$QEMU_IO -c "write -P 0x5a 0 512" \
Expand All @@ -132,11 +128,9 @@ _check_test_img
echo
echo "== Committing to a backing file with lazy_refcounts=on =="

IMGOPTS="compat=1.1,lazy_refcounts=on"
TEST_IMG="$TEST_IMG".base _make_test_img $size
TEST_IMG="$TEST_IMG".base _make_test_img -o "compat=1.1,lazy_refcounts=on" $size

IMGOPTS="compat=1.1,lazy_refcounts=on,backing_file=$TEST_IMG.base"
_make_test_img $size
_make_test_img -o "compat=1.1,lazy_refcounts=on,backing_file=$TEST_IMG.base" $size

$QEMU_IO -c "write 0 512" "$TEST_IMG" | _filter_qemu_io
$QEMU_IMG commit "$TEST_IMG"
Expand All @@ -151,8 +145,7 @@ TEST_IMG="$TEST_IMG".base _check_test_img
echo
echo "== Changing lazy_refcounts setting at runtime =="

IMGOPTS="compat=1.1,lazy_refcounts=off"
_make_test_img $size
_make_test_img -o "compat=1.1,lazy_refcounts=off" $size

_NO_VALGRIND \
$QEMU_IO -c "reopen -o lazy-refcounts=on" \
Expand All @@ -164,8 +157,7 @@ $QEMU_IO -c "reopen -o lazy-refcounts=on" \
$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
_check_test_img

IMGOPTS="compat=1.1,lazy_refcounts=on"
_make_test_img $size
_make_test_img -o "compat=1.1,lazy_refcounts=on" $size

_NO_VALGRIND \
$QEMU_IO -c "reopen -o lazy-refcounts=off" \
Expand Down
18 changes: 9 additions & 9 deletions tests/qemu-iotests/059
Expand Up @@ -70,18 +70,18 @@ poke_file "$TEST_IMG" "$grain_table_size_offset" "\x01\x00\x00\x00"

echo
echo "=== Testing monolithicFlat creation and opening ==="
IMGOPTS="subformat=monolithicFlat" _make_test_img 2G
_make_test_img -o "subformat=monolithicFlat" 2G
_img_info
_cleanup_test_img

echo
echo "=== Testing monolithicFlat with zeroed_grain ==="
IMGOPTS="subformat=monolithicFlat,zeroed_grain=on" _make_test_img 2G
_make_test_img -o "subformat=monolithicFlat,zeroed_grain=on" 2G
_cleanup_test_img

echo
echo "=== Testing big twoGbMaxExtentFlat ==="
IMGOPTS="subformat=twoGbMaxExtentFlat" _make_test_img 1000G
_make_test_img -o "subformat=twoGbMaxExtentFlat" 1000G
$QEMU_IMG info $TEST_IMG | _filter_testdir | sed -e 's/cid: [0-9]*/cid: XXXXXXXX/'
_cleanup_test_img

Expand All @@ -101,13 +101,13 @@ _img_info

echo
echo "=== Testing truncated sparse ==="
IMGOPTS="subformat=monolithicSparse" _make_test_img 100G
_make_test_img -o "subformat=monolithicSparse" 100G
truncate -s 10M $TEST_IMG
_img_info

echo
echo "=== Converting to streamOptimized from image with small cluster size==="
TEST_IMG="$TEST_IMG.qcow2" IMGFMT=qcow2 IMGOPTS="cluster_size=4096" _make_test_img 1G
TEST_IMG="$TEST_IMG.qcow2" IMGFMT=qcow2 _make_test_img -o "cluster_size=4096" 1G
$QEMU_IO -f qcow2 -c "write -P 0xa 0 512" "$TEST_IMG.qcow2" | _filter_qemu_io
$QEMU_IO -f qcow2 -c "write -P 0xb 10240 512" "$TEST_IMG.qcow2" | _filter_qemu_io
$QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2" "$TEST_IMG" 2>&1
Expand All @@ -117,7 +117,7 @@ echo "=== Testing monolithicFlat with internally generated JSON file name ==="

echo '--- blkdebug ---'
# Should work, because bdrv_dirname() works fine with blkdebug
IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
_make_test_img -o "subformat=monolithicFlat" 64M
$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \
-c info \
2>&1 \
Expand All @@ -126,7 +126,7 @@ _cleanup_test_img

echo '--- quorum ---'
# Should not work, because bdrv_dirname() does not work with quorum
IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
_make_test_img -o "subformat=monolithicFlat" 64M
cp "$TEST_IMG" "$TEST_IMG.orig"

filename="json:{
Expand Down Expand Up @@ -161,7 +161,7 @@ _cleanup_test_img

echo
echo "=== Testing 4TB monolithicFlat creation and IO ==="
IMGOPTS="subformat=monolithicFlat" _make_test_img 4T
_make_test_img -o "subformat=monolithicFlat" 4T
_img_info
$QEMU_IO -c "write -P 0xa 900G 512" "$TEST_IMG" | _filter_qemu_io
$QEMU_IO -c "read -v 900G 1024" "$TEST_IMG" | _filter_qemu_io
Expand All @@ -170,7 +170,7 @@ _cleanup_test_img
echo
echo "=== Testing qemu-img map on extents ==="
for fmt in monolithicSparse twoGbMaxExtentSparse; do
IMGOPTS="subformat=$fmt" _make_test_img 31G
_make_test_img -o "subformat=$fmt" 31G
$QEMU_IO -c "write 65024 1k" "$TEST_IMG" | _filter_qemu_io
$QEMU_IO -c "write 2147483136 1k" "$TEST_IMG" | _filter_qemu_io
$QEMU_IO -c "write 5G 1k" "$TEST_IMG" | _filter_qemu_io
Expand Down
6 changes: 3 additions & 3 deletions tests/qemu-iotests/060
Expand Up @@ -161,7 +161,7 @@ $QEMU_IO -c 'write 0k 64k' "$BACKING_IMG" | _filter_qemu_io
# compat=0.10 is required in order to make the following discard actually
# unallocate the sector rather than make it a zero sector - we want COW, after
# all.
IMGOPTS='compat=0.10' _make_test_img -b "$BACKING_IMG" 1G
_make_test_img -o 'compat=0.10' -b "$BACKING_IMG" 1G
# Write two clusters, the second one enforces creation of an L2 table after
# the first data cluster.
$QEMU_IO -c 'write 0k 64k' -c 'write 512M 64k' "$TEST_IMG" | _filter_qemu_io
Expand Down Expand Up @@ -401,7 +401,7 @@ echo
echo "=== Discarding a non-covered in-bounds refblock ==="
echo

IMGOPTS='refcount_bits=1' _make_test_img 64M
_make_test_img -o 'refcount_bits=1' 64M

# Pretend there's a refblock somewhere where there is no refblock to
# cover it (but the covering refblock has a valid index in the
Expand All @@ -425,7 +425,7 @@ echo
echo "=== Discarding a refblock covered by an unaligned refblock ==="
echo

IMGOPTS='refcount_bits=1' _make_test_img 64M
_make_test_img -o 'refcount_bits=1' 64M

# Same as above
poke_file "$TEST_IMG" "$(($rt_offset+8))" "\x00\x00\x00\x10\x00\x00\x00\x00"
Expand Down

0 comments on commit 407fb56

Please sign in to comment.