diff options
| author | Richard Henderson <richard.henderson@linaro.org> | 2025-08-27 19:11:08 +1000 |
|---|---|---|
| committer | Richard Henderson <richard.henderson@linaro.org> | 2025-08-27 19:11:08 +1000 |
| commit | 5fc03d4e28258fdf6a926a59c6b5e1edc23e6d5d (patch) | |
| tree | 9c17fa4348850e26feff0f464f499077907b0aee /tests/functional/generic/test_vnc.py | |
| parent | e771ba98de25c9f43959f79fc7099cf7fbba44cc (diff) | |
| parent | 0ac3c314130eff8e3ea9860fe3202908a7746225 (diff) | |
| download | focaccia-qemu-5fc03d4e28258fdf6a926a59c6b5e1edc23e6d5d.tar.gz focaccia-qemu-5fc03d4e28258fdf6a926a59c6b5e1edc23e6d5d.zip | |
Merge tag 'pull-request-2025-08-27' of https://gitlab.com/thuth/qemu into staging
* Add v10.2 compat machines * Move functional tests to target specific subfolders * Fix some issues in functional tests # -----BEGIN PGP SIGNATURE----- # # iQJFBAABCgAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmiuuP0RHHRodXRoQHJl # ZGhhdC5jb20ACgkQLtnXdP5wLbVMEA//egQiaWsMquQan7D8RWt7TkD2deY2L5Dx # D/pkO3xGA1hxCzD37ptGfFw2NO6cVpH8cjOevrJYUwW1Yefbsf8HqUlC7PrqDjTw # +ztyIPSl7ny3xQxif+1Oc2rmt6MCNCQTw9CLdB0k3D1jr7aY0Z20JrxFrQmExhOe # oSqiILYwiZGfNI4jiQSBYtBVpKrqwCQ+gEs6HyqayQOczaYynHvt8Gqwyp/DpKpY # bfBcqbREK8zYTMMRYl5d/qcJpWgVtCj5OeqDQyhLMSgNt9fGmdKMzjK5Wzgl18gX # 8A9tFK8KreXXLu1UfJWe+/kFAHMWhEWMkOv81Z/gqB4Zmp/eMioKlGDwVBU//PPm # VFigfAPtqBqvOiuJo673ze2AOWMGROtLyZ9nyfv8/MZcQqoYLtvfZMUa08/M74/w # TRSsBMGKk3H2O/prrXjFHK8q0aRXB2Ld3to0TyZOwlB17rhaD5jq/P8ge2UgGRGb # fSghUKGmBAHueZyUdlCer+TEzH8ySl5zmotfiDeQfIYkwQ6rWUQZfehLxoycuHvr # Kl3ZU6RD7fD2kCzRbvUOsyg0H3pihVvzcCL5BMxbGQ1sqZ+WI1dWPoOaUrZ9EvOg # lQtsNMiu2i7bVqaJ27zNR4V3nwU77f/f+6zJwyXtD+6Wb+bFcQu5aYfgjqOr/Tlv # zEVoqp5pRU4= # =pSMT # -----END PGP SIGNATURE----- # gpg: Signature made Wed 27 Aug 2025 05:51:25 PM AEST # gpg: using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5 # gpg: issuer "thuth@redhat.com" # gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [unknown] # gpg: aka "Thomas Huth <thuth@redhat.com>" [unknown] # gpg: aka "Thomas Huth <th.huth@posteo.de>" [unknown] # gpg: aka "Thomas Huth <huth@tuxfamily.org>" [unknown] # gpg: WARNING: The key's User ID is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 27B8 8847 EEE0 2501 18F3 EAB9 2ED9 D774 FE70 2DB5 * tag 'pull-request-2025-08-27' of https://gitlab.com/thuth/qemu: (31 commits) tests/functional: Mark main in QemuBaseTest class as a static method MAINTAINERS: Adjust wildcards for the migration, multiprocess and replay tests tests/functional: Move the generic tests to a subfolder tests/functional: Move xtensa tests into target-specific folder tests/functional: Move x86_64 tests into target-specific folder tests/functional: Move sparc/sparc64 tests into target-specific folders tests/functional: Move sh4/sh4eb tests into target-specific folders tests/functional: Move s390x tests into target-specific folders tests/functional: Move rx test into target-specific folders tests/functional: Move riscv32/riscv64 tests into target-specific folders tests/functional: Move ppc/ppc64 tests into target-specific folders tests/functional: Move or1k tests into target-specific folders tests/functional: Move mips tests into target-specific folders tests/functional: Move microblaze tests into architecture specific folder tests/functional: Move m68k tests into architecture specific folder tests/functional: Move loongarch64 tests into architecture specific folder tests/functional: Move i386 tests into architecture specific folder tests/functional: Move hppa tests into architecture specific folder tests/functional: Move avr tests into architecture specific folder tests/functional: Move arm tests into architecture specific folder ... Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'tests/functional/generic/test_vnc.py')
| -rwxr-xr-x | tests/functional/generic/test_vnc.py | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/tests/functional/generic/test_vnc.py b/tests/functional/generic/test_vnc.py new file mode 100755 index 0000000000..f1dd1597cf --- /dev/null +++ b/tests/functional/generic/test_vnc.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 +# +# Simple functional tests for VNC functionality +# +# Copyright (c) 2018 Red Hat, Inc. +# +# Author: +# Cleber Rosa <crosa@redhat.com> +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. + +import socket + +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: + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: + try: + sock.connect((VNC_ADDR, port)) + except ConnectionRefusedError: + return False + + return True + +class Vnc(QemuSystemTest): + + def test_no_vnc_change_password(self): + self.set_machine('none') + self.vm.add_args('-nodefaults', '-S') + self.vm.launch() + + 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) + self.assertEqual(set_password_response['error']['class'], + 'GenericError') + 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.launch_guarded() + self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled']) + set_password_response = self.vm.qmp('change-vnc-password', + password='new_password') + self.assertIn('error', set_password_response) + self.assertEqual(set_password_response['error']['class'], + 'GenericError') + self.assertEqual(set_password_response['error']['desc'], + '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.launch_guarded() + self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled']) + self.vm.cmd('change-vnc-password', + password='new_password') + + def do_test_change_listen(self, a, b, c): + self.assertFalse(check_connect(a)) + self.assertFalse(check_connect(b)) + self.assertFalse(check_connect(c)) + + self.vm.add_args('-nodefaults', '-S', '-vnc', f'{VNC_ADDR}:{a - 5900}') + self.launch_guarded() + self.assertEqual(self.vm.qmp('query-vnc')['return']['service'], str(a)) + self.assertTrue(check_connect(a)) + self.assertFalse(check_connect(b)) + self.assertFalse(check_connect(c)) + + self.vm.cmd('display-update', type='vnc', + addresses=[{'type': 'inet', 'host': VNC_ADDR, + 'port': str(b)}, + {'type': 'inet', 'host': VNC_ADDR, + 'port': str(c)}]) + self.assertEqual(self.vm.qmp('query-vnc')['return']['service'], str(b)) + self.assertFalse(check_connect(a)) + self.assertTrue(check_connect(b)) + 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) + + +if __name__ == '__main__': + QemuSystemTest.main() |