Skip to content

Commit

Permalink
qemu-iotests: Add _default_cache_mode and _supported_cache_modes
Browse files Browse the repository at this point in the history
This replaces _unsupported_qemu_io_options and check for support of
current cache mode, and allow to provide a default if user didn't
specify.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
Fam Zheng authored and stefanhaRH committed Dec 4, 2013
1 parent 58cc2ae commit f210a83
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
3 changes: 2 additions & 1 deletion tests/qemu-iotests/026
Expand Up @@ -44,7 +44,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
_supported_fmt qcow2
_supported_proto generic
_supported_os Linux

_default_cache_mode "writethrough"
_supported_cache_modes "writethrough" "none"

echo "Errors while writing 128 kB"
echo
Expand Down
3 changes: 2 additions & 1 deletion tests/qemu-iotests/039
Expand Up @@ -44,7 +44,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
_supported_fmt qcow2
_supported_proto generic
_supported_os Linux
_unsupported_qemu_io_options --nocache
_default_cache_mode "writethrough"
_supported_cache_modes "writethrough"

size=128M

Expand Down
4 changes: 2 additions & 2 deletions tests/qemu-iotests/052
Expand Up @@ -41,8 +41,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
_supported_fmt generic
_supported_proto generic
_supported_os Linux
_unsupported_qemu_io_options --nocache

_default_cache_mode "writethrough"
_supported_cache_modes "writethrough"

size=128M
_make_test_img $size
Expand Down
25 changes: 15 additions & 10 deletions tests/qemu-iotests/common.rc
Expand Up @@ -387,18 +387,23 @@ _supported_os()
_notrun "not suitable for this OS: $HOSTOS"
}

_unsupported_qemu_io_options()
_supported_cache_modes()
{
for bad_opt
do
for opt in $QEMU_IO_OPTIONS
do
if [ "$bad_opt" = "$opt" ]
then
_notrun "not suitable for qemu-io option: $bad_opt"
fi
done
for mode; do
if [ "$mode" = "$CACHEMODE" ]; then
return
fi
done
_notrun "not suitable for cache mode: $CACHEMODE"
}

_default_cache_mode()
{
if $CACHEMODE_IS_DEFAULT; then
CACHEMODE="$1"
QEMU_IO="$QEMU_IO --cache $1"
return
fi
}

# this test requires that a specified command (executable) exists
Expand Down

0 comments on commit f210a83

Please sign in to comment.