Re: [PATCH v2 2/3] iotests.py: Add wait_for_runstate()

2020-07-21 Thread Max Reitz
On 20.07.20 18:46, Vladimir Sementsov-Ogievskiy wrote:
> 16.07.2020 16:53, Max Reitz wrote:
>> Signed-off-by: Max Reitz 
>> ---
>>   tests/qemu-iotests/iotests.py | 4 
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/tests/qemu-iotests/iotests.py
>> b/tests/qemu-iotests/iotests.py
>> index 3590ed78a0..fb240a334c 100644
>> --- a/tests/qemu-iotests/iotests.py
>> +++ b/tests/qemu-iotests/iotests.py
>> @@ -803,6 +803,10 @@ class VM(qtest.QEMUQtestMachine):
>>  'Found node %s under %s (but expected %s)' % \
>>  (node['name'], path, expected_node)
>>   +    def wait_for_runstate(self, runstate: str) -> None:
>> +    while self.qmp('query-status')['return']['status'] != runstate:
>> +    pass
> 
> don't we need something like time.sleep(0.5) instead of just pass?

Hm.  Maybe not “need”?  I thought this polling would last a short time
anyway, so it wouldn’t matter if there was high CPU usage during that time.

OTOH, I don’t think a short sleep would hurt.

> Anyway:
> Reviewed-by: Vladimir Sementsov-Ogievskiy 
> 
>> +
>>   index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
>>     class QMPTestCase(unittest.TestCase):
>>
> 
> 




signature.asc
Description: OpenPGP digital signature


Re: [PATCH v2 2/3] iotests.py: Add wait_for_runstate()

2020-07-20 Thread Vladimir Sementsov-Ogievskiy

16.07.2020 16:53, Max Reitz wrote:

Signed-off-by: Max Reitz 
---
  tests/qemu-iotests/iotests.py | 4 
  1 file changed, 4 insertions(+)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 3590ed78a0..fb240a334c 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -803,6 +803,10 @@ class VM(qtest.QEMUQtestMachine):
 'Found node %s under %s (but expected %s)' % \
 (node['name'], path, expected_node)
  
+def wait_for_runstate(self, runstate: str) -> None:

+while self.qmp('query-status')['return']['status'] != runstate:
+pass


don't we need something like time.sleep(0.5) instead of just pass?

Anyway:
Reviewed-by: Vladimir Sementsov-Ogievskiy 


+
  index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
  
  class QMPTestCase(unittest.TestCase):





--
Best regards,
Vladimir



[PATCH v2 2/3] iotests.py: Add wait_for_runstate()

2020-07-16 Thread Max Reitz
Signed-off-by: Max Reitz 
---
 tests/qemu-iotests/iotests.py | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 3590ed78a0..fb240a334c 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -803,6 +803,10 @@ class VM(qtest.QEMUQtestMachine):
'Found node %s under %s (but expected %s)' % \
(node['name'], path, expected_node)
 
+def wait_for_runstate(self, runstate: str) -> None:
+while self.qmp('query-status')['return']['status'] != runstate:
+pass
+
 index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
 
 class QMPTestCase(unittest.TestCase):
-- 
2.26.2