iotests: Drop use of bash keyword 'function'

Bash allows functions to be declared with or without the leading
keyword 'function'; but including the keyword does not comply with
POSIX syntax, and is confusing to ksh users where the use of the
keyword changes the scoping rules for functions.  Stick to the
POSIX form through iotests.

Done mechanically with:
  sed -i 's/^function //' $(git ls-files tests/qemu-iotests)

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20181116215002.2124581-1-eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
This commit is contained in:
Eric Blake 2018-11-16 15:50:02 -06:00
parent bb39c47d70
commit 8cedcffdc1
35 changed files with 86 additions and 86 deletions

View File

@ -49,7 +49,7 @@ echo
echo "creating image" echo "creating image"
_make_test_img $size _make_test_img $size
function generate_requests() { generate_requests() {
for i in $(seq 0 63); do for i in $(seq 0 63); do
echo "aio_write ${i}M 512" echo "aio_write ${i}M 512"
echo "aio_write ${i}M 512" echo "aio_write ${i}M 512"

View File

@ -54,7 +54,7 @@ TEST_IMG="$TEST_IMG.base"
_make_test_img $size _make_test_img $size
function backing_io() backing_io()
{ {
local offset=$1 local offset=$1
local sectors=$2 local sectors=$2

View File

@ -51,7 +51,7 @@ TEST_IMG="$TEST_IMG.base"
_make_test_img $size _make_test_img $size
function backing_io() backing_io()
{ {
local offset=$1 local offset=$1
local sectors=$2 local sectors=$2
@ -76,7 +76,7 @@ _make_test_img -b "$TEST_IMG.base" 6G
echo echo
echo "== Some concurrent requests touching the same cluster ==" echo "== Some concurrent requests touching the same cluster =="
function overlay_io() overlay_io()
{ {
# Start with a request touching two clusters # Start with a request touching two clusters
echo aio_write -P 0x80 2020k 80k echo aio_write -P 0x80 2020k 80k
@ -102,7 +102,7 @@ overlay_io | $QEMU_IO "$TEST_IMG" | _filter_qemu_io |\
echo echo
echo "== Verify image content ==" echo "== Verify image content =="
function verify_io() verify_io()
{ {
echo read -P 31 2016k 4k echo read -P 31 2016k 4k
echo read -P 0x80 2020k 80k echo read -P 0x80 2020k 80k

View File

@ -48,7 +48,7 @@ echo "== creating backing file for COW tests =="
_make_test_img $size _make_test_img $size
function backing_io() backing_io()
{ {
local offset=$1 local offset=$1
local sectors=$2 local sectors=$2
@ -73,7 +73,7 @@ _make_test_img -b "$TEST_IMG.base" 6G
echo echo
echo "== Some concurrent requests touching the same cluster ==" echo "== Some concurrent requests touching the same cluster =="
function overlay_io() overlay_io()
{ {
# Allocate middle of cluster 1, then write to somewhere before and after it # Allocate middle of cluster 1, then write to somewhere before and after it
cat <<EOF cat <<EOF
@ -189,7 +189,7 @@ overlay_io | $QEMU_IO blkdebug::"$TEST_IMG" | _filter_qemu_io |\
echo echo
echo "== Verify image content ==" echo "== Verify image content =="
function verify_io() verify_io()
{ {
if ($QEMU_IMG info -U -f "$IMGFMT" "$TEST_IMG" | grep "compat: 0.10" > /dev/null); then if ($QEMU_IMG info -U -f "$IMGFMT" "$TEST_IMG" | grep "compat: 0.10" > /dev/null); then
# For v2 images, discarded clusters are read from the backing file # For v2 images, discarded clusters are read from the backing file

View File

@ -45,7 +45,7 @@ size=128M
_make_test_img $size _make_test_img $size
function qemu_io_cmds() qemu_io_cmds()
{ {
cat <<EOF cat <<EOF
write -P 0x66 0 320k write -P 0x66 0 320k

View File

@ -40,13 +40,13 @@ _supported_fmt qcow2
_supported_proto file _supported_proto file
_supported_os Linux _supported_os Linux
function filter_test_dir() filter_test_dir()
{ {
sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
-e "s#$TEST_DIR#TEST_DIR#g" -e "s#$TEST_DIR#TEST_DIR#g"
} }
function test_qemu_img() test_qemu_img()
{ {
echo qemu-img "$@" | filter_test_dir echo qemu-img "$@" | filter_test_dir
$QEMU_IMG "$@" 2>&1 | filter_test_dir $QEMU_IMG "$@" 2>&1 | filter_test_dir

View File

@ -43,7 +43,7 @@ _supported_os Linux
# other than refcount_bits=16 # other than refcount_bits=16
_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)'
function do_run_qemu() do_run_qemu()
{ {
echo Testing: "$@" echo Testing: "$@"
( (
@ -57,7 +57,7 @@ function do_run_qemu()
echo echo
} }
function run_qemu() run_qemu()
{ {
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu |
_filter_generated_node_ids | _filter_hmp _filter_generated_node_ids | _filter_hmp

View File

@ -36,7 +36,7 @@ _supported_os Linux
# Because anything other than 16 would change the output of query-block # Because anything other than 16 would change the output of query-block
_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)'
function do_run_qemu() do_run_qemu()
{ {
echo Testing: "$@" echo Testing: "$@"
$QEMU -nographic -qmp-pretty stdio -serial none "$@" $QEMU -nographic -qmp-pretty stdio -serial none "$@"
@ -52,7 +52,7 @@ _filter_qmp_events()
| tr '\t' '\n' | tr '\t' '\n'
} }
function run_qemu() run_qemu()
{ {
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | _filter_qemu \ do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | _filter_qemu \
| _filter_actual_image_size \ | _filter_actual_image_size \

View File

@ -40,14 +40,14 @@ _supported_fmt qcow2
_supported_proto file _supported_proto file
_supported_os Linux _supported_os Linux
function do_run_qemu() do_run_qemu()
{ {
echo Testing: "$@" | _filter_imgfmt echo Testing: "$@" | _filter_imgfmt
$QEMU -nographic -qmp stdio -serial none "$@" $QEMU -nographic -qmp stdio -serial none "$@"
echo echo
} }
function run_qemu() run_qemu()
{ {
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp | _filter_qemu_io do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp | _filter_qemu_io
} }

View File

@ -48,7 +48,7 @@ _make_test_img $size
echo echo
echo "== Some concurrent requests involving RMW ==" echo "== Some concurrent requests involving RMW =="
function test_io() test_io()
{ {
echo "open -o driver=$IMGFMT,file.align=4k blkdebug::$TEST_IMG" echo "open -o driver=$IMGFMT,file.align=4k blkdebug::$TEST_IMG"
# A simple RMW request # A simple RMW request
@ -193,7 +193,7 @@ test_io | $QEMU_IO | _filter_qemu_io | \
echo echo
echo "== Verify image content ==" echo "== Verify image content =="
function verify_io() verify_io()
{ {
# A simple RMW request # A simple RMW request
echo read -P 0 0 0x200 echo read -P 0 0 0x200

View File

@ -42,14 +42,14 @@ _supported_fmt raw
_supported_proto file _supported_proto file
_supported_os Linux _supported_os Linux
function do_run_qemu() do_run_qemu()
{ {
echo Testing: "$@" | _filter_imgfmt echo Testing: "$@" | _filter_imgfmt
$QEMU -nographic -qmp stdio -serial none "$@" $QEMU -nographic -qmp stdio -serial none "$@"
echo echo
} }
function run_qemu() run_qemu()
{ {
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp\ do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp\
| _filter_qemu_io | _filter_generated_node_ids | _filter_qemu_io | _filter_generated_node_ids

View File

@ -40,7 +40,7 @@ _supported_fmt qcow2
_supported_proto file nfs _supported_proto file nfs
_supported_os Linux _supported_os Linux
function run_qemu_img() run_qemu_img()
{ {
echo echo
echo Testing: "$@" | _filter_testdir echo Testing: "$@" | _filter_testdir

View File

@ -60,7 +60,7 @@ _supported_os Linux
# ${1}: unique identifier for the snapshot filename # ${1}: unique identifier for the snapshot filename
function create_single_snapshot() create_single_snapshot()
{ {
cmd="{ 'execute': 'blockdev-snapshot-sync', cmd="{ 'execute': 'blockdev-snapshot-sync',
'arguments': { 'device': 'virtio0', 'arguments': { 'device': 'virtio0',
@ -70,7 +70,7 @@ function create_single_snapshot()
} }
# ${1}: unique identifier for the snapshot filename # ${1}: unique identifier for the snapshot filename
function create_group_snapshot() create_group_snapshot()
{ {
cmd="{ 'execute': 'transaction', 'arguments': cmd="{ 'execute': 'transaction', 'arguments':
{'actions': [ {'actions': [
@ -88,7 +88,7 @@ function create_group_snapshot()
# ${1}: unique identifier for the snapshot filename # ${1}: unique identifier for the snapshot filename
# ${2}: extra_params to the blockdev-add command # ${2}: extra_params to the blockdev-add command
# ${3}: filename # ${3}: filename
function do_blockdev_add() do_blockdev_add()
{ {
cmd="{ 'execute': 'blockdev-add', 'arguments': cmd="{ 'execute': 'blockdev-add', 'arguments':
{ 'driver': 'qcow2', 'node-name': 'snap_${1}', ${2} { 'driver': 'qcow2', 'node-name': 'snap_${1}', ${2}
@ -99,7 +99,7 @@ function do_blockdev_add()
} }
# ${1}: unique identifier for the snapshot filename # ${1}: unique identifier for the snapshot filename
function add_snapshot_image() add_snapshot_image()
{ {
base_image="${TEST_DIR}/$((${1}-1))-${snapshot_virt0}" base_image="${TEST_DIR}/$((${1}-1))-${snapshot_virt0}"
snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}" snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}"
@ -110,7 +110,7 @@ function add_snapshot_image()
# ${1}: unique identifier for the snapshot filename # ${1}: unique identifier for the snapshot filename
# ${2}: expected response, defaults to 'return' # ${2}: expected response, defaults to 'return'
function blockdev_snapshot() blockdev_snapshot()
{ {
cmd="{ 'execute': 'blockdev-snapshot', cmd="{ 'execute': 'blockdev-snapshot',
'arguments': { 'node': 'virtio0', 'arguments': { 'node': 'virtio0',

View File

@ -40,7 +40,7 @@ _supported_fmt qcow2 raw
_supported_proto file _supported_proto file
_supported_os Linux _supported_os Linux
function run_qemu_img() run_qemu_img()
{ {
echo echo
echo Testing: "$@" | _filter_testdir echo Testing: "$@" | _filter_testdir

View File

@ -34,14 +34,14 @@ _supported_fmt qcow2
_supported_proto file _supported_proto file
_supported_os Linux _supported_os Linux
function do_run_qemu() do_run_qemu()
{ {
echo Testing: "$@" echo Testing: "$@"
$QEMU -nographic -qmp stdio -serial none "$@" $QEMU -nographic -qmp stdio -serial none "$@"
echo echo
} }
function run_qemu() run_qemu()
{ {
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \ do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
| _filter_qemu | _filter_imgfmt \ | _filter_qemu | _filter_imgfmt \
@ -102,7 +102,7 @@ echo === aio=native without O_DIRECT ===
echo echo
# Skip this test if AIO is not enabled in this build # Skip this test if AIO is not enabled in this build
function run_qemu_filter_aio() run_qemu_filter_aio()
{ {
run_qemu "$@" | \ run_qemu "$@" | \
sed -e 's/is not supported in this build/it requires cache.direct=on, which was not specified/' sed -e 's/is not supported in this build/it requires cache.direct=on, which was not specified/'

View File

@ -45,12 +45,12 @@ _supported_os Linux
_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
"subformat=twoGbMaxExtentSparse" "subformat=twoGbMaxExtentSparse"
function do_run_qemu() do_run_qemu()
{ {
$QEMU -nographic -qmp stdio -serial none "$@" $QEMU -nographic -qmp stdio -serial none "$@"
} }
function run_qemu() run_qemu()
{ {
# Get the "file": "foo" entry ($foo may only contain escaped double quotes, # Get the "file": "foo" entry ($foo may only contain escaped double quotes,
# which is how we can extract it) # which is how we can extract it)
@ -59,7 +59,7 @@ function run_qemu()
| sed -e 's/^.*"file": "\(\(\\"\|[^"]\)*\)".*$/\1/' -e 's/\\"/"/g' | sed -e 's/^.*"file": "\(\(\\"\|[^"]\)*\)".*$/\1/' -e 's/\\"/"/g'
} }
function test_qemu() test_qemu()
{ {
run_qemu -drive "if=none,id=drv0,$1" <<EOF run_qemu -drive "if=none,id=drv0,$1" <<EOF
{ 'execute': 'qmp_capabilities' } { 'execute': 'qmp_capabilities' }

View File

@ -45,7 +45,7 @@ _supported_os Linux
qemu_comm_method=qmp qemu_comm_method=qmp
function run_qemu() run_qemu()
{ {
local raw_img="$1" local raw_img="$1"
local source_img="$2" local source_img="$2"

View File

@ -44,7 +44,7 @@ _supported_os Linux
# manual setting; compat will be overridden as well # manual setting; compat will be overridden as well
_unsupported_imgopts refcount_bits 'compat=0.10' _unsupported_imgopts refcount_bits 'compat=0.10'
function print_refcount_bits() print_refcount_bits()
{ {
$QEMU_IMG info "$TEST_IMG" | sed -n '/refcount bits:/ s/^ *//p' $QEMU_IMG info "$TEST_IMG" | sed -n '/refcount bits:/ s/^ *//p'
} }

View File

@ -45,7 +45,7 @@ _supported_os Linux
_default_cache_mode none _default_cache_mode none
_supported_cache_modes none directsync _supported_cache_modes none directsync
function do_run_qemu() do_run_qemu()
{ {
echo Testing: "$@" echo Testing: "$@"
( (
@ -59,7 +59,7 @@ function do_run_qemu()
echo echo
} }
function run_qemu() run_qemu()
{ {
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp
} }
@ -88,7 +88,7 @@ echo
files="if=none,file=$TEST_IMG,backing.file.filename=$TEST_IMG.base" files="if=none,file=$TEST_IMG,backing.file.filename=$TEST_IMG.base"
ids="node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file" ids="node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file"
function check_cache_all() check_cache_all()
{ {
# cache.direct is supposed to be inherited by both bs->file and # cache.direct is supposed to be inherited by both bs->file and
# bs->backing # bs->backing
@ -231,7 +231,7 @@ drv_bk="if=none,file=json:{'driver':'$IMGFMT',,'file':'backing-file',,'node-name
drv_file="if=none,driver=file,filename=$TEST_IMG,node-name=file" drv_file="if=none,driver=file,filename=$TEST_IMG,node-name=file"
drv_img="if=none,id=blk,file=json:{'driver':'$IMGFMT',,'file':'file',,'backing':'backing',,'node-name':'image'}" drv_img="if=none,id=blk,file=json:{'driver':'$IMGFMT',,'file':'file',,'backing':'backing',,'node-name':'image'}"
function check_cache_all_separate() check_cache_all_separate()
{ {
# Check cache.direct # Check cache.direct

View File

@ -70,7 +70,7 @@ _run_cmd()
(echo "$@"; "$@" 2>&1 1>/dev/null) | _filter_testdir (echo "$@"; "$@" 2>&1 1>/dev/null) | _filter_testdir
} }
function _do_run_qemu() _do_run_qemu()
{ {
( (
if ! test -t 0; then if ! test -t 0; then
@ -82,7 +82,7 @@ function _do_run_qemu()
) | $QEMU -nographic -monitor stdio -serial none "$@" 1>/dev/null ) | $QEMU -nographic -monitor stdio -serial none "$@" 1>/dev/null
} }
function _run_qemu_with_images() _run_qemu_with_images()
{ {
_do_run_qemu \ _do_run_qemu \
$(for i in $@; do echo "-drive if=none,file=$i"; done) 2>&1 \ $(for i in $@; do echo "-drive if=none,file=$i"; done) 2>&1 \

View File

@ -40,7 +40,7 @@ _supported_fmt generic
_supported_proto file _supported_proto file
_supported_os Linux _supported_os Linux
function do_run_qemu() do_run_qemu()
{ {
( (
if ! test -t 0; then if ! test -t 0; then
@ -53,7 +53,7 @@ function do_run_qemu()
echo echo
} }
function run_qemu() run_qemu()
{ {
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_imgfmt \ do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_imgfmt \
| _filter_qemu | _filter_generated_node_ids | _filter_qemu | _filter_generated_node_ids

View File

@ -46,7 +46,7 @@ if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
_notrun "Requires a PC machine" _notrun "Requires a PC machine"
fi fi
function do_run_qemu() do_run_qemu()
{ {
( (
if ! test -t 0; then if ! test -t 0; then
@ -59,7 +59,7 @@ function do_run_qemu()
echo echo
} }
function check_floppy_qtree() check_floppy_qtree()
{ {
echo echo
echo Testing: "$@" | _filter_testdir echo Testing: "$@" | _filter_testdir
@ -75,7 +75,7 @@ function check_floppy_qtree()
_filter_win32 | _filter_qemu _filter_win32 | _filter_qemu
} }
function check_cache_mode() check_cache_mode()
{ {
echo "info block none0" | echo "info block none0" |
QEMU_OPTIONS="" do_run_qemu -drive if=none,file="$TEST_IMG" "$@" | QEMU_OPTIONS="" do_run_qemu -drive if=none,file="$TEST_IMG" "$@" |

View File

@ -50,7 +50,7 @@ _supported_os Linux
# Persistent dirty bitmaps require compat=1.1 # Persistent dirty bitmaps require compat=1.1
_unsupported_imgopts 'compat=0.10' _unsupported_imgopts 'compat=0.10'
function run_qemu() run_qemu()
{ {
$QEMU -nographic -qmp stdio -serial none "$@" 2>&1 \ $QEMU -nographic -qmp stdio -serial none "$@" 2>&1 \
| _filter_testdir | _filter_qmp | _filter_qemu \ | _filter_testdir | _filter_qmp | _filter_qemu \

View File

@ -85,7 +85,7 @@ $QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \
echo echo
echo "== verify image content ==" echo "== verify image content =="
function verify_io() verify_io()
{ {
if ($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | if ($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" |
grep "compat: 0.10" > /dev/null); then grep "compat: 0.10" > /dev/null); then

View File

@ -34,14 +34,14 @@ trap "exit \$status" 0 1 2 3 15
_supported_os Linux _supported_os Linux
function do_run_qemu() do_run_qemu()
{ {
echo Testing: "$@" | _filter_imgfmt echo Testing: "$@" | _filter_imgfmt
$QEMU -nographic -qmp-pretty stdio -serial none "$@" $QEMU -nographic -qmp-pretty stdio -serial none "$@"
echo echo
} }
function run_qemu() run_qemu()
{ {
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp\ do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp\
| _filter_qemu_io | _filter_generated_node_ids \ | _filter_qemu_io | _filter_generated_node_ids \

View File

@ -44,7 +44,7 @@ if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
_notrun "Requires a PC machine" _notrun "Requires a PC machine"
fi fi
function do_run_qemu() do_run_qemu()
{ {
echo Testing: "$@" echo Testing: "$@"
@ -59,7 +59,7 @@ function do_run_qemu()
echo echo
} }
function check_info_block() check_info_block()
{ {
echo "info block" | echo "info block" |
do_run_qemu "$@" | _filter_win32 | _filter_hmp | _filter_qemu | do_run_qemu "$@" | _filter_win32 | _filter_hmp | _filter_qemu |

View File

@ -41,14 +41,14 @@ _supported_fmt qcow2
_supported_proto file _supported_proto file
_supported_os Linux _supported_os Linux
function do_run_qemu() do_run_qemu()
{ {
echo Testing: "$@" echo Testing: "$@"
$QEMU -nographic -qmp-pretty stdio -serial none "$@" $QEMU -nographic -qmp-pretty stdio -serial none "$@"
echo echo
} }
function run_qemu() run_qemu()
{ {
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_imgfmt | _filter_qemu \ do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_imgfmt | _filter_qemu \
| _filter_qmp | _filter_qemu_io \ | _filter_qmp | _filter_qemu_io \

View File

@ -93,7 +93,7 @@ $QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \
echo echo
echo "== verify image content ==" echo "== verify image content =="
function verify_io() verify_io()
{ {
echo read -P 22 0 1000 echo read -P 22 0 1000
echo read -P 33 1000 128k echo read -P 33 1000 128k

View File

@ -42,14 +42,14 @@ _supported_os Linux
# Persistent dirty bitmaps require compat=1.1 # Persistent dirty bitmaps require compat=1.1
_unsupported_imgopts 'compat=0.10' _unsupported_imgopts 'compat=0.10'
function do_run_qemu() do_run_qemu()
{ {
echo Testing: "$@" echo Testing: "$@"
$QEMU -nographic -qmp stdio -serial none "$@" $QEMU -nographic -qmp stdio -serial none "$@"
echo echo
} }
function run_qemu() run_qemu()
{ {
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \ do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
| _filter_qemu | _filter_imgfmt \ | _filter_qemu | _filter_imgfmt \

View File

@ -40,14 +40,14 @@ _supported_fmt generic
_supported_proto file _supported_proto file
_supported_os Linux _supported_os Linux
function do_run_qemu() do_run_qemu()
{ {
echo Testing: "$@" echo Testing: "$@"
$QEMU -nographic -qmp-pretty stdio -serial none "$@" $QEMU -nographic -qmp-pretty stdio -serial none "$@"
echo echo
} }
function run_qemu() run_qemu()
{ {
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \ do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
| _filter_qemu | _filter_imgfmt \ | _filter_qemu | _filter_imgfmt \

View File

@ -41,7 +41,7 @@ _supported_fmt generic
_supported_proto file _supported_proto file
_supported_os Linux _supported_os Linux
function do_run_qemu() do_run_qemu()
{ {
echo Testing: "$@" echo Testing: "$@"
( (
@ -55,13 +55,13 @@ function do_run_qemu()
echo echo
} }
function run_qemu() run_qemu()
{ {
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp | do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp |
_filter_generated_node_ids | _filter_imgfmt _filter_generated_node_ids | _filter_imgfmt
} }
function run_qemu_info_block() run_qemu_info_block()
{ {
echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG" echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG"
} }

View File

@ -23,7 +23,7 @@ nbd_unix_socket="${TEST_DIR}/qemu-nbd.sock"
nbd_tcp_addr="127.0.0.1" nbd_tcp_addr="127.0.0.1"
nbd_pid_file="${TEST_DIR}/qemu-nbd.pid" nbd_pid_file="${TEST_DIR}/qemu-nbd.pid"
function nbd_server_stop() nbd_server_stop()
{ {
local NBD_PID local NBD_PID
if [ -f "$nbd_pid_file" ]; then if [ -f "$nbd_pid_file" ]; then
@ -36,7 +36,7 @@ function nbd_server_stop()
rm -f "$nbd_unix_socket" rm -f "$nbd_unix_socket"
} }
function nbd_server_wait_for_unix_socket() nbd_server_wait_for_unix_socket()
{ {
pid=$1 pid=$1
@ -57,14 +57,14 @@ function nbd_server_wait_for_unix_socket()
exit 1 exit 1
} }
function nbd_server_start_unix_socket() nbd_server_start_unix_socket()
{ {
nbd_server_stop nbd_server_stop
$QEMU_NBD -v -t -k "$nbd_unix_socket" "$@" & $QEMU_NBD -v -t -k "$nbd_unix_socket" "$@" &
nbd_server_wait_for_unix_socket $! nbd_server_wait_for_unix_socket $!
} }
function nbd_server_set_tcp_port() nbd_server_set_tcp_port()
{ {
(ss --help) >/dev/null 2>&1 || _notrun "ss utility not found, skipping test" (ss --help) >/dev/null 2>&1 || _notrun "ss utility not found, skipping test"
@ -80,7 +80,7 @@ function nbd_server_set_tcp_port()
exit 1 exit 1
} }
function nbd_server_wait_for_tcp_socket() nbd_server_wait_for_tcp_socket()
{ {
pid=$1 pid=$1
@ -101,7 +101,7 @@ function nbd_server_wait_for_tcp_socket()
exit 1 exit 1
} }
function nbd_server_start_tcp_socket() nbd_server_start_tcp_socket()
{ {
nbd_server_stop nbd_server_stop
$QEMU_NBD -v -t -b $nbd_tcp_addr -p $nbd_tcp_port "$@" & $QEMU_NBD -v -t -b $nbd_tcp_addr -p $nbd_tcp_port "$@" &

View File

@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
function do_is_allocated() { do_is_allocated() {
local start=$1 local start=$1
local size=$2 local size=$2
local step=$3 local step=$3
@ -27,11 +27,11 @@ function do_is_allocated() {
done done
} }
function is_allocated() { is_allocated() {
do_is_allocated "$@" | $QEMU_IO "$TEST_IMG" | _filter_qemu_io do_is_allocated "$@" | $QEMU_IO "$TEST_IMG" | _filter_qemu_io
} }
function do_io() { do_io() {
local op=$1 local op=$1
local start=$2 local start=$2
local size=$3 local size=$3
@ -45,22 +45,22 @@ function do_io() {
done done
} }
function io_pattern() { io_pattern() {
do_io "$@" | $QEMU_IO "$TEST_IMG" | _filter_qemu_io do_io "$@" | $QEMU_IO "$TEST_IMG" | _filter_qemu_io
} }
function io() { io() {
local start=$2 local start=$2
local pattern=$(( (start >> 9) % 256 )) local pattern=$(( (start >> 9) % 256 ))
do_io "$@" $pattern | $QEMU_IO "$TEST_IMG" | _filter_qemu_io do_io "$@" $pattern | $QEMU_IO "$TEST_IMG" | _filter_qemu_io
} }
function io_zero() { io_zero() {
do_io "$@" 0 | $QEMU_IO "$TEST_IMG" | _filter_qemu_io do_io "$@" 0 | $QEMU_IO "$TEST_IMG" | _filter_qemu_io
} }
function io_test() { io_test() {
local op=$1 local op=$1
local offset=$2 local offset=$2
local cluster_size=$3 local cluster_size=$3
@ -100,7 +100,7 @@ function io_test() {
offset=$((offset + num_large * ( l2_size + half_cluster ))) offset=$((offset + num_large * ( l2_size + half_cluster )))
} }
function io_test2() { io_test2() {
local orig_offset=$1 local orig_offset=$1
local cluster_size=$2 local cluster_size=$2
local num=$3 local num=$3

View File

@ -60,7 +60,7 @@ _in_fd=4
# $3: A string to search for in the response; if found, this indicates # $3: A string to search for in the response; if found, this indicates
# failure and the test is either aborted (if $qemu_error_no_exit # failure and the test is either aborted (if $qemu_error_no_exit
# is not set) or ${QEMU_STATUS[$1]} is set to -1 (otherwise). # is not set) or ${QEMU_STATUS[$1]} is set to -1 (otherwise).
function _timed_wait_for() _timed_wait_for()
{ {
local h=${1} local h=${1}
shift shift
@ -131,7 +131,7 @@ function _timed_wait_for()
# strings the response will be scanned for. The first of the two # strings the response will be scanned for. The first of the two
# indicates success, the latter indicates failure. Failure is handled # indicates success, the latter indicates failure. Failure is handled
# like a timeout. # like a timeout.
function _send_qemu_cmd() _send_qemu_cmd()
{ {
local h=${1} local h=${1}
local count=1 local count=1
@ -186,7 +186,7 @@ function _send_qemu_cmd()
# Returns: # Returns:
# $QEMU_HANDLE: set to a handle value to communicate with this QEMU instance. # $QEMU_HANDLE: set to a handle value to communicate with this QEMU instance.
# #
function _launch_qemu() _launch_qemu()
{ {
local comm= local comm=
local fifo_out= local fifo_out=
@ -262,7 +262,7 @@ function _launch_qemu()
# If $wait is set to anything other than the empty string, the process will not # If $wait is set to anything other than the empty string, the process will not
# be killed but only waited for, and any output will be forwarded to stdout. If # be killed but only waited for, and any output will be forwarded to stdout. If
# $wait is empty, the process will be killed and all output will be suppressed. # $wait is empty, the process will be killed and all output will be suppressed.
function _cleanup_qemu() _cleanup_qemu()
{ {
# QEMU_PID[], QEMU_IN[], QEMU_OUT[] all use same indices # QEMU_PID[], QEMU_IN[], QEMU_OUT[] all use same indices
for i in "${!QEMU_OUT[@]}" for i in "${!QEMU_OUT[@]}"

View File

@ -20,7 +20,7 @@
tls_dir="${TEST_DIR}/tls" tls_dir="${TEST_DIR}/tls"
function tls_x509_cleanup() tls_x509_cleanup()
{ {
rm -f "${tls_dir}"/*.pem rm -f "${tls_dir}"/*.pem
rm -f "${tls_dir}"/*/*.pem rm -f "${tls_dir}"/*/*.pem
@ -29,7 +29,7 @@ function tls_x509_cleanup()
} }
function tls_x509_init() tls_x509_init()
{ {
mkdir -p "${tls_dir}" mkdir -p "${tls_dir}"
@ -58,7 +58,7 @@ EOF
} }
function tls_x509_create_root_ca() tls_x509_create_root_ca()
{ {
name=${1:-ca-cert} name=${1:-ca-cert}
@ -77,7 +77,7 @@ EOF
} }
function tls_x509_create_server() tls_x509_create_server()
{ {
caname=$1 caname=$1
name=$2 name=$2
@ -108,7 +108,7 @@ EOF
} }
function tls_x509_create_client() tls_x509_create_client()
{ {
caname=$1 caname=$1
name=$2 name=$2