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 <pbonz...@redhat.com> > --- > 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