Skip to content

Commit

Permalink
iotests: bash tests: filter compression type
Browse files Browse the repository at this point in the history
We want iotests pass with both the default zlib compression and with
IMGOPTS='compression_type=zstd'.

Actually the only test that is interested in real compression type in
test output is 287 (test for qcow2 compression type), so implement
specific option for it.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20211223160144.1097696-17-vsementsov@virtuozzo.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
  • Loading branch information
Vladimir Sementsov-Ogievskiy authored and XanClic committed Feb 1, 2022
1 parent 72be51d commit dba5aee
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 21 deletions.
2 changes: 1 addition & 1 deletion tests/qemu-iotests/060.out
Expand Up @@ -17,7 +17,7 @@ virtual size: 64 MiB (67108864 bytes)
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
compression type: COMPRESSION_TYPE
lazy refcounts: false
refcount bits: 16
corrupt: true
Expand Down
12 changes: 6 additions & 6 deletions tests/qemu-iotests/061.out
Expand Up @@ -525,7 +525,7 @@ virtual size: 64 MiB (67108864 bytes)
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
compression type: COMPRESSION_TYPE
lazy refcounts: false
refcount bits: 16
data file: TEST_DIR/t.IMGFMT.data
Expand All @@ -552,7 +552,7 @@ virtual size: 64 MiB (67108864 bytes)
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
compression type: COMPRESSION_TYPE
lazy refcounts: false
refcount bits: 16
data file: foo
Expand All @@ -567,7 +567,7 @@ virtual size: 64 MiB (67108864 bytes)
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
compression type: COMPRESSION_TYPE
lazy refcounts: false
refcount bits: 16
data file raw: false
Expand All @@ -583,7 +583,7 @@ virtual size: 64 MiB (67108864 bytes)
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
compression type: COMPRESSION_TYPE
lazy refcounts: false
refcount bits: 16
data file: TEST_DIR/t.IMGFMT.data
Expand All @@ -597,7 +597,7 @@ virtual size: 64 MiB (67108864 bytes)
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
compression type: COMPRESSION_TYPE
lazy refcounts: false
refcount bits: 16
data file: TEST_DIR/t.IMGFMT.data
Expand All @@ -612,7 +612,7 @@ virtual size: 64 MiB (67108864 bytes)
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
compression type: COMPRESSION_TYPE
lazy refcounts: false
refcount bits: 16
data file: TEST_DIR/t.IMGFMT.data
Expand Down
14 changes: 7 additions & 7 deletions tests/qemu-iotests/082.out
Expand Up @@ -17,7 +17,7 @@ virtual size: 128 MiB (134217728 bytes)
cluster_size: 4096
Format specific information:
compat: 1.1
compression type: zlib
compression type: COMPRESSION_TYPE
lazy refcounts: true
refcount bits: 16
corrupt: false
Expand All @@ -31,7 +31,7 @@ virtual size: 128 MiB (134217728 bytes)
cluster_size: 8192
Format specific information:
compat: 1.1
compression type: zlib
compression type: COMPRESSION_TYPE
lazy refcounts: true
refcount bits: 16
corrupt: false
Expand Down Expand Up @@ -329,7 +329,7 @@ virtual size: 128 MiB (134217728 bytes)
cluster_size: 4096
Format specific information:
compat: 1.1
compression type: zlib
compression type: COMPRESSION_TYPE
lazy refcounts: true
refcount bits: 16
corrupt: false
Expand All @@ -342,7 +342,7 @@ virtual size: 128 MiB (134217728 bytes)
cluster_size: 8192
Format specific information:
compat: 1.1
compression type: zlib
compression type: COMPRESSION_TYPE
lazy refcounts: true
refcount bits: 16
corrupt: false
Expand Down Expand Up @@ -639,7 +639,7 @@ virtual size: 128 MiB (134217728 bytes)
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
compression type: COMPRESSION_TYPE
lazy refcounts: true
refcount bits: 16
corrupt: false
Expand All @@ -652,7 +652,7 @@ virtual size: 130 MiB (136314880 bytes)
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
compression type: COMPRESSION_TYPE
lazy refcounts: false
refcount bits: 16
corrupt: false
Expand All @@ -665,7 +665,7 @@ virtual size: 132 MiB (138412032 bytes)
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
compression type: COMPRESSION_TYPE
lazy refcounts: true
refcount bits: 16
corrupt: false
Expand Down
4 changes: 2 additions & 2 deletions tests/qemu-iotests/198.out
Expand Up @@ -36,7 +36,7 @@ image: json:{ /* filtered */ }
file format: IMGFMT
virtual size: 16 MiB (16777216 bytes)
Format specific information:
compression type: zlib
compression type: COMPRESSION_TYPE
encrypt:
ivgen alg: plain64
hash alg: sha256
Expand Down Expand Up @@ -81,7 +81,7 @@ virtual size: 16 MiB (16777216 bytes)
backing file: TEST_DIR/t.IMGFMT.base
backing file format: IMGFMT
Format specific information:
compression type: zlib
compression type: COMPRESSION_TYPE
encrypt:
ivgen alg: plain64
hash alg: sha256
Expand Down
8 changes: 4 additions & 4 deletions tests/qemu-iotests/287
Expand Up @@ -61,21 +61,21 @@ echo
echo "=== Testing compression type incompatible bit setting for zlib ==="
echo
_make_test_img -o compression_type=zlib 64M
_qcow2_dump_header | grep incompatible_features
_qcow2_dump_header --no-filter-compression | grep incompatible_features

echo
echo "=== Testing compression type incompatible bit setting for zstd ==="
echo
_make_test_img -o compression_type=zstd 64M
_qcow2_dump_header | grep incompatible_features
_qcow2_dump_header --no-filter-compression | grep incompatible_features

echo
echo "=== Testing zlib with incompatible bit set ==="
echo
_make_test_img -o compression_type=zlib 64M
$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 3
# to make sure the bit was actually set
_qcow2_dump_header | grep incompatible_features
_qcow2_dump_header --no-filter-compression | grep incompatible_features

if $QEMU_IMG info "$TEST_IMG" >/dev/null 2>&1 ; then
echo "Error: The image opened successfully. The image must not be opened."
Expand All @@ -87,7 +87,7 @@ echo
_make_test_img -o compression_type=zstd 64M
$PYTHON qcow2.py "$TEST_IMG" set-header incompatible_features 0
# to make sure the bit was actually unset
_qcow2_dump_header | grep incompatible_features
_qcow2_dump_header --no-filter-compression | grep incompatible_features

if $QEMU_IMG info "$TEST_IMG" >/dev/null 2>&1 ; then
echo "Error: The image opened successfully. The image must not be opened."
Expand Down
8 changes: 8 additions & 0 deletions tests/qemu-iotests/common.filter
Expand Up @@ -247,6 +247,7 @@ _filter_img_info()
-e "/block_state_zero: \\(on\\|off\\)/d" \
-e "/log_size: [0-9]\\+/d" \
-e "s/iters: [0-9]\\+/iters: 1024/" \
-e 's/\(compression type: \)\(zlib\|zstd\)/\1COMPRESSION_TYPE/' \
-e "s/uuid: [-a-f0-9]\\+/uuid: 00000000-0000-0000-0000-000000000000/" | \
while IFS='' read -r line; do
if [[ $format_specific == 1 ]]; then
Expand Down Expand Up @@ -337,5 +338,12 @@ _filter_authz_check_tls()
$SED -e 's/TLS x509 authz check for .* is denied/TLS x509 authz check for DISTINGUISHED-NAME is denied/'
}

_filter_qcow2_compression_type_bit()
{
$SED -e 's/\(incompatible_features\s\+\)\[3\(, \)\?/\1[/' \
-e 's/\(incompatible_features.*\), 3\]/\1]/' \
-e 's/\(incompatible_features.*\), 3\(,.*\)/\1\2/'
}

# make sure this script returns success
true
14 changes: 13 additions & 1 deletion tests/qemu-iotests/common.rc
Expand Up @@ -699,6 +699,7 @@ _img_info()
-e "s#$TEST_DIR#TEST_DIR#g" \
-e "s#$SOCK_DIR/fuse-#TEST_DIR/#g" \
-e "s#$IMGFMT#IMGFMT#g" \
-e 's/\(compression type: \)\(zlib\|zstd\)/\1COMPRESSION_TYPE/' \
-e "/^disk size:/ D" \
-e "/actual-size/ D" | \
while IFS='' read -r line; do
Expand Down Expand Up @@ -998,12 +999,23 @@ _require_one_device_of()

_qcow2_dump_header()
{
if [[ "$1" == "--no-filter-compression" ]]; then
local filter_compression=0
shift
else
local filter_compression=1
fi

img="$1"
if [ -z "$img" ]; then
img="$TEST_IMG"
fi

$PYTHON qcow2.py "$img" dump-header
if [[ $filter_compression == 0 ]]; then
$PYTHON qcow2.py "$img" dump-header
else
$PYTHON qcow2.py "$img" dump-header | _filter_qcow2_compression_type_bit
fi
}

# make sure this script returns success
Expand Down

0 comments on commit dba5aee

Please sign in to comment.