On 02/27/2015 12:24 PM, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: John Snow <js...@redhat.com>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@parallels.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 75640b2..294b158 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -203,6 +203,13 @@ class VM(object):
>          self._qmp.clear_events()
>          return events
>  
> +    def event_wait(self, name='BLOCK_JOB_COMPLETED', maxwait=10):
> +        for _ in range(maxwait):
> +            for event in self.get_qmp_events(wait=True):
> +                if event['event'] == name:
> +                    return event
> +            return None
> +
>  index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
>  
>  class QMPTestCase(unittest.TestCase):
> 

For v5, I have already included this upstream and expanded it slightly
to include a proper timeout mechanism as well as a new "match" parameter
that accepts a dict that can be used as a "filter" to only select events
for which 'match' is a recursive subset.

This patch can likely be dropped again.

Reply via email to