Message ID | 20190927094242.11152-5-mreitz@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | iotests: Allow ./check -o data_file | expand |
On Fri, 2019-09-27 at 11:42 +0200, Max Reitz wrote: > This will allow us to add more options than just -b. > > Signed-off-by: Max Reitz <mreitz@redhat.com> > --- > tests/qemu-iotests/common.rc | 28 ++++++++++++++++++++-------- > 1 file changed, 20 insertions(+), 8 deletions(-) > > diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc > index 12b4751848..3e7adc4834 100644 > --- a/tests/qemu-iotests/common.rc > +++ b/tests/qemu-iotests/common.rc > @@ -282,12 +282,12 @@ _make_test_img() > # extra qemu-img options can be added by tests > # at least one argument (the image size) needs to be added > local extra_img_options="" > - local image_size=$* > local optstr="" > local img_name="" > local use_backing=0 > local backing_file="" > local object_options="" > + local misc_params=() > > if [ -n "$TEST_IMG_FILE" ]; then > img_name=$TEST_IMG_FILE > @@ -303,11 +303,23 @@ _make_test_img() > optstr=$(_optstr_add "$optstr" "key-secret=keysec0") > fi > > - if [ "$1" = "-b" ]; then > - use_backing=1 > - backing_file=$2 > - image_size=$3 > - fi > + for param; do > + if [ "$use_backing" = "1" -a -z "$backing_file" ]; then > + backing_file=$param > + continue > + fi > + > + case "$param" in > + -b) > + use_backing=1 > + ;; > + > + *) > + misc_params=("${misc_params[@]}" "$param") > + ;; > + esac > + done > + > if [ \( "$IMGFMT" = "qcow2" -o "$IMGFMT" = "qed" \) -a -n "$CLUSTER_SIZE" ]; then > optstr=$(_optstr_add "$optstr" "cluster_size=$CLUSTER_SIZE") > fi > @@ -323,9 +335,9 @@ _make_test_img() > # XXX(hch): have global image options? > ( > if [ $use_backing = 1 ]; then > - $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" $image_size 2>&1 > + $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" "${misc_params[@]}" 2>&1 > else > - $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" $image_size 2>&1 > + $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" "${misc_params[@]}" 2>&1 > fi > ) | _filter_img_create > Look all right as far as I understand that code, and this is a very welcome change. Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Best regards, Maxim Levitsky
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index 12b4751848..3e7adc4834 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -282,12 +282,12 @@ _make_test_img() # extra qemu-img options can be added by tests # at least one argument (the image size) needs to be added local extra_img_options="" - local image_size=$* local optstr="" local img_name="" local use_backing=0 local backing_file="" local object_options="" + local misc_params=() if [ -n "$TEST_IMG_FILE" ]; then img_name=$TEST_IMG_FILE @@ -303,11 +303,23 @@ _make_test_img() optstr=$(_optstr_add "$optstr" "key-secret=keysec0") fi - if [ "$1" = "-b" ]; then - use_backing=1 - backing_file=$2 - image_size=$3 - fi + for param; do + if [ "$use_backing" = "1" -a -z "$backing_file" ]; then + backing_file=$param + continue + fi + + case "$param" in + -b) + use_backing=1 + ;; + + *) + misc_params=("${misc_params[@]}" "$param") + ;; + esac + done + if [ \( "$IMGFMT" = "qcow2" -o "$IMGFMT" = "qed" \) -a -n "$CLUSTER_SIZE" ]; then optstr=$(_optstr_add "$optstr" "cluster_size=$CLUSTER_SIZE") fi @@ -323,9 +335,9 @@ _make_test_img() # XXX(hch): have global image options? ( if [ $use_backing = 1 ]; then - $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" $image_size 2>&1 + $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" "${misc_params[@]}" 2>&1 else - $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" $image_size 2>&1 + $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" "${misc_params[@]}" 2>&1 fi ) | _filter_img_create
This will allow us to add more options than just -b. Signed-off-by: Max Reitz <mreitz@redhat.com> --- tests/qemu-iotests/common.rc | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)