All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: "Tomáš Golembiovský" <tgolembi@redhat.com>
Cc: qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Eric Blake <eblake@redhat.com>,
	"Daniel P . Berrange" <berrange@redhat.com>,
	qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v7 2/2] qemu-iotests: test 'offset' and 'size' options in raw driver
Date: Thu, 27 Oct 2016 15:47:25 +0200	[thread overview]
Message-ID: <20161027134725.GC4027@noname.redhat.com> (raw)
In-Reply-To: <e3fcd378ef103281c602c31a63114f0dfdc3d88f.1477568704.git.tgolembi@redhat.com>

Am 27.10.2016 um 14:18 hat Tomáš Golembiovský geschrieben:
> Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>

Like in the implementation, this could use tests for discard and zero
writes (write -z in qemu-io).

>  tests/qemu-iotests/171     | 170 ++++++++++++++++++++++++++++++++++++++++++++
>  tests/qemu-iotests/171.out | 173 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/qemu-iotests/group   |   1 +
>  3 files changed, 344 insertions(+)
>  create mode 100755 tests/qemu-iotests/171
>  create mode 100644 tests/qemu-iotests/171.out
> 
> diff --git a/tests/qemu-iotests/171 b/tests/qemu-iotests/171
> new file mode 100755
> index 0000000..3bdc680
> --- /dev/null
> +++ b/tests/qemu-iotests/171
> @@ -0,0 +1,170 @@
> +#!/bin/bash
> +#
> +# Test 'offset' and 'size' options of the raw driver. Make sure we can't
> +# (or can) read and write outside of the image size.
> +#
> +# Copyright (C) 2016 Red Hat, Inc.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +#
> +
> +# creator
> +owner=tgolembi@redhat.com
> +
> +seq=`basename $0`
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +status=1	# failure is the default!
> +
> +_cleanup()
> +{
> +    _cleanup_test_img
> +}
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +# get standard environment, filters and checks
> +. ./common.rc
> +. ./common.filter
> +
> +_supported_fmt raw
> +_supported_proto file
> +_supported_os Linux
> +
> +
> +# Create options string
> +img_json() {
> +    echo -n 'json:{"driver":"raw", '
> +    echo -n "\"offset\":\"$img_offset\", "
> +    if [ "$img_size" -ne -1 ] ; then
> +        echo -n "\"size\":\"$img_size\", "
> +    fi
> +    echo -n '"file": {'
> +    echo -n    '"driver":"file", '
> +    echo -n    "\"filename\":\"$TEST_IMG\" "
> +    echo -n "} }"
> +}
> +
> +do_general_test() {
> +    echo
> +    echo "write to image"
> +    $QEMU_IO -c "write -P 0x0a 0 $test_size" "$(img_json)" | _filter_qemu_io
> +
> +    echo
> +    echo "check that offset is respected"
> +    $QEMU_IO -c "read -v $((img_offset-2)) 4" $TEST_IMG | _filter_qemu_io
> +
> +    echo
> +    echo "write before image boundary"
> +    $QEMU_IO -c "write $((test_size-1)) 1" "$(img_json)" | _filter_qemu_io
> +
> +    echo
> +    echo "write across image boundary"
> +    $QEMU_IO -c "write $((test_size-1)) 2" "$(img_json)" | _filter_qemu_io
> +
> +    echo
> +    echo "write at image boundary"
> +    $QEMU_IO -c "write $test_size 1" "$(img_json)" | _filter_qemu_io
> +
> +    echo
> +    echo "write after image boundary"
> +    $QEMU_IO -c "write $((test_size+512)) 1" "$(img_json)" | _filter_qemu_io
> +
> +    echo
> +    echo "writev before/after image boundary"
> +    $QEMU_IO -c "writev $((test_size-512)) 512 512" "$(img_json)" | _filter_qemu_io
> +
> +    echo
> +    echo "read the image"
> +    $QEMU_IO -c "read 0 $test_size" "$(img_json)" | _filter_qemu_io

If you move this up, you could use -P 0x0a to verify that you really
read at the right offset. Otherwise you don't have any read with offset
that actually checks what has been read.

The rest looks good at the first sight.

Kevin

      reply	other threads:[~2016-10-27 13:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-27 12:18 [Qemu-devel] [PATCH v7 0/2] Add 'offset' and 'size' options Tomáš Golembiovský
2016-10-27 12:18 ` [Qemu-devel] [PATCH v7 1/2] raw_bsd: add offset and size options Tomáš Golembiovský
2016-10-27 13:32   ` Kevin Wolf
2016-10-27 12:18 ` [Qemu-devel] [PATCH v7 2/2] qemu-iotests: test 'offset' and 'size' options in raw driver Tomáš Golembiovský
2016-10-27 13:47   ` Kevin Wolf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161027134725.GC4027@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=tgolembi@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.