diff mbox

[19/22] iotests: add VM.test_launcn()

Message ID 1458072268-53705-20-git-send-email-vsementsov@virtuozzo.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vladimir Sementsov-Ogievskiy March 15, 2016, 8:04 p.m. UTC
Test vm can launch and print output in case of fail. This function is
needed for testing erroneous cases

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 tests/qemu-iotests/iotests.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Eric Blake March 22, 2016, 6:25 p.m. UTC | #1
On 03/15/2016 02:04 PM, Vladimir Sementsov-Ogievskiy wrote:

in subject: s/launcn/launch/

> Test vm can launch and print output in case of fail. This function is
> needed for testing erroneous cases
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  tests/qemu-iotests/iotests.py | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 

> +    def test_launch(self):
> +        '''Launch the VM, an error is expected'''
> +        try:
> +            self.launch()
> +        except:
> +            self._popen.wait()
> +            regex = re.compile(r"qemu-system-\w+")
> +            print "Test launch failed: %d" % self._popen.returncode
> +            print "--- qemu output ---"
> +            for line in open(self._qemu_log_path):
> +                #filter qtest comments
> +                if not "] OPENED" in line:
> +                    print regex.sub("qemu-system-*", line)
> +            print "--- end qemu output ---"
> +            return False
> +
> +        print "Tast launch successed!"

What? Did you mean "Test launch succeeded" ?
diff mbox

Patch

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 6807b07..187b434 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -226,6 +226,26 @@  class VM(object):
             os.remove(self._monitor_path)
             raise
 
+    def test_launch(self):
+        '''Launch the VM, an error is expected'''
+        try:
+            self.launch()
+        except:
+            self._popen.wait()
+            regex = re.compile(r"qemu-system-\w+")
+            print "Test launch failed: %d" % self._popen.returncode
+            print "--- qemu output ---"
+            for line in open(self._qemu_log_path):
+                #filter qtest comments
+                if not "] OPENED" in line:
+                    print regex.sub("qemu-system-*", line)
+            print "--- end qemu output ---"
+            return False
+
+        print "Tast launch successed!"
+        self.shutdown()
+        return True
+
     def shutdown(self):
         '''Terminate the VM and clean up'''
         if not self._popen is None: