tests/functional/test_vnc.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
From: Thomas Huth <thuth@redhat.com>
These tests currently fail if VNC support has not been compiled into
the QEMU binary. Let's add some checks to skip the tests in that
case instead.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/functional/test_vnc.py | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/tests/functional/test_vnc.py b/tests/functional/test_vnc.py
index 1916be0103f..8c9953bdb00 100755
--- a/tests/functional/test_vnc.py
+++ b/tests/functional/test_vnc.py
@@ -12,6 +12,7 @@
import socket
from typing import List
+from qemu.machine.machine import VMLaunchFailure
from qemu_test import QemuSystemTest
from qemu_test.ports import Ports
@@ -32,7 +33,14 @@ class Vnc(QemuSystemTest):
def test_no_vnc_change_password(self):
self.vm.add_args('-nodefaults', '-S')
self.vm.launch()
- self.assertFalse(self.vm.qmp('query-vnc')['return']['enabled'])
+
+ query_vnc_response = self.vm.qmp('query-vnc')
+ if 'error' in query_vnc_response:
+ self.assertEqual(query_vnc_response['error']['class'],
+ 'CommandNotFound')
+ self.skipTest('VNC support not available')
+ self.assertFalse(query_vnc_response['return']['enabled'])
+
set_password_response = self.vm.qmp('change-vnc-password',
password='new_password')
self.assertIn('error', set_password_response)
@@ -41,9 +49,19 @@ def test_no_vnc_change_password(self):
self.assertEqual(set_password_response['error']['desc'],
'Could not set password')
+ def launch_guarded(self):
+ try:
+ self.vm.launch()
+ except VMLaunchFailure as excp:
+ if "-vnc: invalid option" in excp.output:
+ self.skipTest("VNC support not available")
+ else:
+ self.log.info("unhandled launch failure: %s", excp.output)
+ raise excp
+
def test_change_password_requires_a_password(self):
self.vm.add_args('-nodefaults', '-S', '-vnc', ':1,to=999')
- self.vm.launch()
+ self.launch_guarded()
self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled'])
set_password_response = self.vm.qmp('change-vnc-password',
password='new_password')
@@ -55,7 +73,7 @@ def test_change_password_requires_a_password(self):
def test_change_password(self):
self.vm.add_args('-nodefaults', '-S', '-vnc', ':1,to=999,password=on')
- self.vm.launch()
+ self.launch_guarded()
self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled'])
self.vm.cmd('change-vnc-password',
password='new_password')
@@ -66,7 +84,7 @@ def do_test_change_listen(self, a, b, c):
self.assertFalse(check_connect(c))
self.vm.add_args('-nodefaults', '-S', '-vnc', f'{VNC_ADDR}:{a - 5900}')
- self.vm.launch()
+ self.launch_guarded()
self.assertEqual(self.vm.qmp('query-vnc')['return']['service'], str(a))
self.assertTrue(check_connect(a))
self.assertFalse(check_connect(b))
--
2.49.0
On Tue, Mar 25, 2025 at 07:47:15AM +0100, Thomas Huth wrote: > From: Thomas Huth <thuth@redhat.com> > > These tests currently fail if VNC support has not been compiled into > the QEMU binary. Let's add some checks to skip the tests in that > case instead. > > Signed-off-by: Thomas Huth <thuth@redhat.com> > --- > tests/functional/test_vnc.py | 26 ++++++++++++++++++++++---- > 1 file changed, 22 insertions(+), 4 deletions(-) Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
© 2016 - 2025 Red Hat, Inc.