aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/test_vnc.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/test_vnc.py')
-rwxr-xr-xtests/functional/test_vnc.py34
1 files changed, 29 insertions, 5 deletions
diff --git a/tests/functional/test_vnc.py b/tests/functional/test_vnc.py
index 1916be0..f1dd159 100755
--- a/tests/functional/test_vnc.py
+++ b/tests/functional/test_vnc.py
@@ -11,11 +11,12 @@
# later. See the COPYING file in the top-level directory.
import socket
-from typing import List
+from qemu.machine.machine import VMLaunchFailure
from qemu_test import QemuSystemTest
from qemu_test.ports import Ports
+
VNC_ADDR = '127.0.0.1'
def check_connect(port: int) -> bool:
@@ -30,9 +31,17 @@ def check_connect(port: int) -> bool:
class Vnc(QemuSystemTest):
def test_no_vnc_change_password(self):
+ self.set_machine('none')
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 +50,22 @@ class Vnc(QemuSystemTest):
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")
+ elif "Cipher backend does not support DES algorithm" in excp.output:
+ self.skipTest("No cryptographic backend available")
+ else:
+ self.log.info("unhandled launch failure: %s", excp.output)
+ raise excp
+
def test_change_password_requires_a_password(self):
+ self.set_machine('none')
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')
@@ -54,8 +76,9 @@ class Vnc(QemuSystemTest):
'Could not set password')
def test_change_password(self):
+ self.set_machine('none')
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 +89,7 @@ class Vnc(QemuSystemTest):
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))
@@ -83,6 +106,7 @@ class Vnc(QemuSystemTest):
self.assertTrue(check_connect(c))
def test_change_listen(self):
+ self.set_machine('none')
with Ports() as ports:
a, b, c = ports.find_free_ports(3)
self.do_test_change_listen(a, b, c)