Message ID | 20180628000745.4477-8-mreitz@redhat.com |
---|---|
State | New |
Headers | show |
Series | block: Fix some filename generation issues | expand |
On Thu 28 Jun 2018 02:07:21 AM CEST, Max Reitz wrote: > This function queries a node; since we cannot do that right now, it > executes query-named-block-nodes and returns the matching node's object. > > Signed-off-by: Max Reitz <mreitz@redhat.com> > --- > tests/qemu-iotests/iotests.py | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py > index 5c45788dac..3b18907f6a 100644 > --- a/tests/qemu-iotests/iotests.py > +++ b/tests/qemu-iotests/iotests.py > @@ -465,6 +465,13 @@ class VM(qtest.QEMUQtestMachine): > else: > iotests.log(ev) > > + def node_info(self, node_name): > + nodes = self.qmp('query-named-block-nodes') > + for x in nodes['return']: > + if x['node-name'] == node_name: > + return x > + assert False > + There are cases in which you want to verify that a node doesn't exist anymore (e.g. after you have removed it), so it would be nice to return None if the node doesn't exist. I actually have a similar function (minus the "return None" part) in one of my tests from the blockdev-reopen series, so I could make use of this one instead. Berto
On 2018-08-07 16:49, Alberto Garcia wrote: > On Thu 28 Jun 2018 02:07:21 AM CEST, Max Reitz wrote: >> This function queries a node; since we cannot do that right now, it >> executes query-named-block-nodes and returns the matching node's object. >> >> Signed-off-by: Max Reitz <mreitz@redhat.com> >> --- >> tests/qemu-iotests/iotests.py | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py >> index 5c45788dac..3b18907f6a 100644 >> --- a/tests/qemu-iotests/iotests.py >> +++ b/tests/qemu-iotests/iotests.py >> @@ -465,6 +465,13 @@ class VM(qtest.QEMUQtestMachine): >> else: >> iotests.log(ev) >> >> + def node_info(self, node_name): >> + nodes = self.qmp('query-named-block-nodes') >> + for x in nodes['return']: >> + if x['node-name'] == node_name: >> + return x >> + assert False >> + > > There are cases in which you want to verify that a node doesn't exist > anymore (e.g. after you have removed it), so it would be nice to return > None if the node doesn't exist. Can do (and then maybe add a wrapper function that aborts if the node doesn't exist). Thanks for reviewing! Max > I actually have a similar function (minus the "return None" part) in one > of my tests from the blockdev-reopen series, so I could make use of this > one instead. > > Berto >
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 5c45788dac..3b18907f6a 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -465,6 +465,13 @@ class VM(qtest.QEMUQtestMachine): else: iotests.log(ev) + def node_info(self, node_name): + nodes = self.qmp('query-named-block-nodes') + for x in nodes['return']: + if x['node-name'] == node_name: + return x + assert False + index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
This function queries a node; since we cannot do that right now, it executes query-named-block-nodes and returns the matching node's object. Signed-off-by: Max Reitz <mreitz@redhat.com> --- tests/qemu-iotests/iotests.py | 7 +++++++ 1 file changed, 7 insertions(+)