qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 17/47] qemu-iotests: add tests for streaming err


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH 17/47] qemu-iotests: add tests for streaming error handling
Date: Wed, 01 Aug 2012 12:43:22 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0

Am 24.07.2012 13:03, schrieb Paolo Bonzini:
> Add a test for each of report/ignore/stop.  The tests use blkdebug
> to generate an error in the middle of a script.  The error is
> recoverable (once = "on") so that we can test resuming a job after
> stopping for an error.
> 
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
>  tests/qemu-iotests/030        |  138 
> +++++++++++++++++++++++++++++++++++++++++
>  tests/qemu-iotests/group      |    2 +-
>  tests/qemu-iotests/iotests.py |    7 +++
>  3 files changed, 146 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
> index 0163945..c65bf5e 100755
> --- a/tests/qemu-iotests/030
> +++ b/tests/qemu-iotests/030
> @@ -163,6 +163,144 @@ class TestSingleDrive(ImageStreamingTestCase):
>          result = self.vm.qmp('block-stream', device='nonexistent')
>          self.assert_qmp(result, 'error/class', 'DeviceNotFound')
>  
> +class TestErrors(ImageStreamingTestCase):
> +    image_len = 2 * 1024 * 1024 # MB
> +
> +    # this should match STREAM_BUFFER_SIZE/512 in block/stream.c
> +    STREAM_BUFFER_SIZE = 512 * 1024
> +
> +    def create_blkdebug_file(self, name, event, errno):
> +        file = open(name, 'w')
> +        file.write('''
> +[inject-error]
> +state = "1"
> +event = "%s"
> +errno = "%d"
> +immediately = "off"
> +once = "on"
> +sector = "%d"
> +
> +[set-state]
> +state = "1"
> +event = "%s"
> +new_state = "2"
> +
> +[set-state]
> +state = "2"
> +event = "%s"
> +new_state = "1"
> +''' % (event, errno, self.STREAM_BUFFER_SIZE / 512, event, event))
> +        file.close()
> +
> +    def setUp(self):
> +        self.blkdebug_file = backing_img + ".blkdebug"
> +        self.create_image(backing_img, TestErrors.image_len)
> +        self.create_blkdebug_file(self.blkdebug_file, "read_aio", 5)
> +        qemu_img('create', '-f', iotests.imgfmt,
> +                 '-o', 'backing_file=blkdebug:%s:%s,backing_fmt=raw'
> +                       % (self.blkdebug_file, backing_img),
> +                 test_img)
> +        self.vm = iotests.VM().add_drive(test_img)
> +        self.vm.launch()
> +
> +    def tearDown(self):
> +        self.vm.shutdown()
> +        os.remove(test_img)
> +        os.remove(backing_img)
> +        os.remove(self.blkdebug_file)
> +
> +    def test_report(self):
> +        self.assert_no_active_streams()
> +
> +        result = self.vm.qmp('block-stream', device='drive0')
> +        self.assert_qmp(result, 'return', {})
> +
> +        completed = False
> +        error = False
> +        while not completed:
> +            for event in self.vm.get_qmp_events(wait=True):
> +                if event['event'] == 'BLOCK_JOB_ERROR':
> +                    self.assert_qmp(event, 'data/device', 'drive0')
> +                    self.assert_qmp(event, 'data/operation', 'read')

data/action should be asserted as well (same in the other tests).

What about adding an enospc test as well, once with EIO and once with
ENOSPC?

Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]