aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/147
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>2023-10-06 18:41:25 +0300
committerJohn Snow <jsnow@redhat.com>2023-10-12 14:21:44 -0400
commitb6aed193e5ecca32bb07e062f58f0daca06e7009 (patch)
tree869a1bf90b35f8bff095472c3c9f9ccd5631fe26 /tests/qemu-iotests/147
parent25ad2cf6500db3b7f2d88de448791183d7614097 (diff)
downloadqemu-b6aed193e5ecca32bb07e062f58f0daca06e7009.zip
qemu-b6aed193e5ecca32bb07e062f58f0daca06e7009.tar.gz
qemu-b6aed193e5ecca32bb07e062f58f0daca06e7009.tar.bz2
python: use vm.cmd() instead of vm.qmp() where appropriate
In many cases we just want an effect of qmp command and want to raise on failure. Use vm.cmd() method which does exactly this. The commit is generated by command git grep -l '\.qmp(' | xargs ./scripts/python_qmp_updater.py And then, fix self.assertRaises to expect ExecuteError exception in tests/qemu-iotests/124 Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 20231006154125.1068348-16-vsementsov@yandex-team.ru Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/147')
-rwxr-xr-xtests/qemu-iotests/14731
1 files changed, 11 insertions, 20 deletions
diff --git a/tests/qemu-iotests/147 b/tests/qemu-iotests/147
index 08111c5..6d6f077 100755
--- a/tests/qemu-iotests/147
+++ b/tests/qemu-iotests/147
@@ -58,8 +58,7 @@ class NBDBlockdevAddBase(iotests.QMPTestCase):
def client_test(self, filename, address, export=None,
node_name='nbd-blockdev', delete=True):
bao = self.blockdev_add_options(address, export, node_name)
- result = self.vm.qmp('blockdev-add', bao)
- self.assert_qmp(result, 'return', {})
+ self.vm.cmd('blockdev-add', bao)
found = False
result = self.vm.qmp('query-named-block-nodes')
@@ -75,8 +74,7 @@ class NBDBlockdevAddBase(iotests.QMPTestCase):
self.assertTrue(found)
if delete:
- result = self.vm.qmp('blockdev-del', node_name=node_name)
- self.assert_qmp(result, 'return', {})
+ self.vm.cmd('blockdev-del', node_name=node_name)
class QemuNBD(NBDBlockdevAddBase):
@@ -158,17 +156,14 @@ class BuiltinNBD(NBDBlockdevAddBase):
self.assert_qmp(result, 'return', {})
if export_name is None:
- result = self.server.qmp('nbd-server-add', device='nbd-export')
- self.assert_qmp(result, 'return', {})
+ self.server.cmd('nbd-server-add', device='nbd-export')
else:
- result = self.server.qmp('nbd-server-add', device='nbd-export',
- name=export_name)
- self.assert_qmp(result, 'return', {})
+ self.server.cmd('nbd-server-add', device='nbd-export',
+ name=export_name)
if export_name2 is not None:
- result = self.server.qmp('nbd-server-add', device='nbd-export',
- name=export_name2)
- self.assert_qmp(result, 'return', {})
+ self.server.cmd('nbd-server-add', device='nbd-export',
+ name=export_name2)
return True
@@ -176,8 +171,7 @@ class BuiltinNBD(NBDBlockdevAddBase):
self.assertTrue(self._try_server_up(address, export_name, export_name2))
def _server_down(self):
- result = self.server.qmp('nbd-server-stop')
- self.assert_qmp(result, 'return', {})
+ self.server.cmd('nbd-server-stop')
def do_test_inet(self, export_name=None):
while True:
@@ -219,10 +213,8 @@ class BuiltinNBD(NBDBlockdevAddBase):
flatten_sock_addr(address), 'exp1', 'node1', False)
self.client_test('nbd://localhost:%i/%s' % (nbd_port, 'exp2'),
flatten_sock_addr(address), 'exp2', 'node2', False)
- result = self.vm.qmp('blockdev-del', node_name='node1')
- self.assert_qmp(result, 'return', {})
- result = self.vm.qmp('blockdev-del', node_name='node2')
- self.assert_qmp(result, 'return', {})
+ self.vm.cmd('blockdev-del', node_name='node1')
+ self.vm.cmd('blockdev-del', node_name='node2')
self._server_down()
def test_inet6(self):
@@ -273,8 +265,7 @@ class BuiltinNBD(NBDBlockdevAddBase):
result = self.vm.send_fd_scm(fd=sockfd.fileno())
self.assertEqual(result, 0, 'Failed to send socket FD')
- result = self.vm.qmp('getfd', fdname='nbd-fifo')
- self.assert_qmp(result, 'return', {})
+ self.vm.cmd('getfd', fdname='nbd-fifo')
address = { 'type': 'fd',
'data': { 'str': 'nbd-fifo' } }