diff mbox series

[v5,32/44] tests/functional: Convert the vnc test

Message ID 20240830133841.142644-33-thuth@redhat.com
State New
Headers show
Series Convert avocado tests to normal Python unittests | expand

Commit Message

Thomas Huth Aug. 30, 2024, 1:38 p.m. UTC
Nothing thrilling in here, it's just a straight forward conversion.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/meson.build                     |  1 +
 tests/{avocado/vnc.py => functional/test_vnc.py} | 12 +++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)
 rename tests/{avocado/vnc.py => functional/test_vnc.py} (97%)
 mode change 100644 => 100755

Comments

Philippe Mathieu-Daudé Sept. 2, 2024, 9:48 a.m. UTC | #1
On 30/8/24 15:38, Thomas Huth wrote:
> Nothing thrilling in here, it's just a straight forward conversion.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   tests/functional/meson.build                     |  1 +
>   tests/{avocado/vnc.py => functional/test_vnc.py} | 12 +++++++-----
>   2 files changed, 8 insertions(+), 5 deletions(-)
>   rename tests/{avocado/vnc.py => functional/test_vnc.py} (97%)
>   mode change 100644 => 100755
> 
> diff --git a/tests/functional/meson.build b/tests/functional/meson.build
> index 34a9b277f8..58f6bcf95d 100644
> --- a/tests/functional/meson.build
> +++ b/tests/functional/meson.build
> @@ -107,6 +107,7 @@ tests_x86_64_system_quick = [
>     'pc_cpu_hotplug_props',
>     'virtio_version',
>     'x86_cpu_model_versions',
> +  'vnc',
>   ]
>   
>   tests_x86_64_system_thorough = [
> diff --git a/tests/avocado/vnc.py b/tests/functional/test_vnc.py
> old mode 100644
> new mode 100755
> similarity index 97%
> rename from tests/avocado/vnc.py
> rename to tests/functional/test_vnc.py
> index 862c8996a8..b769d3b268
> --- a/tests/avocado/vnc.py
> +++ b/tests/functional/test_vnc.py
> @@ -1,3 +1,5 @@
> +#!/usr/bin/env python3
> +#
>   # Simple functional tests for VNC functionality
>   #
>   # Copyright (c) 2018 Red Hat, Inc.
> @@ -11,7 +13,7 @@
>   import socket
>   from typing import List
>   
> -from avocado_qemu import QemuSystemTest
> +from qemu_test import QemuSystemTest
>   
>   
>   VNC_ADDR = '127.0.0.1'
> @@ -51,10 +53,7 @@ def find_free_ports(count: int) -> List[int]:
>   
>   
>   class Vnc(QemuSystemTest):
> -    """
> -    :avocado: tags=vnc,quick
> -    :avocado: tags=machine:none
> -    """
> +
>       def test_no_vnc(self):
>           self.vm.add_args('-nodefaults', '-S')
>           self.vm.launch()
> @@ -113,3 +112,6 @@ def test_change_listen(self):
>           self.assertFalse(check_connect(a))
>           self.assertTrue(check_connect(b))
>           self.assertTrue(check_connect(c))
> +
> +if __name__ == '__main__':
> +    QemuSystemTest.main()

For a faithful conversion we need to squash:

-- >8 --
diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index 6b00d240dd..a590646adc 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -26,6 +26,7 @@ tests_generic_system = [
    'empty_cpu_model',
    'info_usernet',
    'version',
+  'vnc',
  ]

  tests_generic_linuxuser = [
@@ -123,7 +124,6 @@ tests_x86_64_system_quick = [
    'pc_cpu_hotplug_props',
    'virtio_version',
    'x86_cpu_model_versions',
-  'vnc',
  ]

---

(each test is <1s so I'd keep it generic).

Regardless the variant kept:

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Thomas Huth Sept. 2, 2024, 10:23 a.m. UTC | #2
On 02/09/2024 11.48, Philippe Mathieu-Daudé wrote:
> On 30/8/24 15:38, Thomas Huth wrote:
>> Nothing thrilling in here, it's just a straight forward conversion.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>   tests/functional/meson.build                     |  1 +
>>   tests/{avocado/vnc.py => functional/test_vnc.py} | 12 +++++++-----
>>   2 files changed, 8 insertions(+), 5 deletions(-)
>>   rename tests/{avocado/vnc.py => functional/test_vnc.py} (97%)
>>   mode change 100644 => 100755
>>
>> diff --git a/tests/functional/meson.build b/tests/functional/meson.build
>> index 34a9b277f8..58f6bcf95d 100644
>> --- a/tests/functional/meson.build
>> +++ b/tests/functional/meson.build
>> @@ -107,6 +107,7 @@ tests_x86_64_system_quick = [
>>     'pc_cpu_hotplug_props',
>>     'virtio_version',
>>     'x86_cpu_model_versions',
>> +  'vnc',
>>   ]
>>   tests_x86_64_system_thorough = [
>> diff --git a/tests/avocado/vnc.py b/tests/functional/test_vnc.py
>> old mode 100644
>> new mode 100755
>> similarity index 97%
>> rename from tests/avocado/vnc.py
>> rename to tests/functional/test_vnc.py
>> index 862c8996a8..b769d3b268
>> --- a/tests/avocado/vnc.py
>> +++ b/tests/functional/test_vnc.py
>> @@ -1,3 +1,5 @@
>> +#!/usr/bin/env python3
>> +#
>>   # Simple functional tests for VNC functionality
>>   #
>>   # Copyright (c) 2018 Red Hat, Inc.
>> @@ -11,7 +13,7 @@
>>   import socket
>>   from typing import List
>> -from avocado_qemu import QemuSystemTest
>> +from qemu_test import QemuSystemTest
>>   VNC_ADDR = '127.0.0.1'
>> @@ -51,10 +53,7 @@ def find_free_ports(count: int) -> List[int]:
>>   class Vnc(QemuSystemTest):
>> -    """
>> -    :avocado: tags=vnc,quick
>> -    :avocado: tags=machine:none
>> -    """
>> +
>>       def test_no_vnc(self):
>>           self.vm.add_args('-nodefaults', '-S')
>>           self.vm.launch()
>> @@ -113,3 +112,6 @@ def test_change_listen(self):
>>           self.assertFalse(check_connect(a))
>>           self.assertTrue(check_connect(b))
>>           self.assertTrue(check_connect(c))
>> +
>> +if __name__ == '__main__':
>> +    QemuSystemTest.main()
> 
> For a faithful conversion we need to squash:
> 
> -- >8 --
> diff --git a/tests/functional/meson.build b/tests/functional/meson.build
> index 6b00d240dd..a590646adc 100644
> --- a/tests/functional/meson.build
> +++ b/tests/functional/meson.build
> @@ -26,6 +26,7 @@ tests_generic_system = [
>     'empty_cpu_model',
>     'info_usernet',
>     'version',
> +  'vnc',
>   ]
> 
>   tests_generic_linuxuser = [
> @@ -123,7 +124,6 @@ tests_x86_64_system_quick = [
>     'pc_cpu_hotplug_props',
>     'virtio_version',
>     'x86_cpu_model_versions',
> -  'vnc',
>   ]
> 
> ---
> 
> (each test is <1s so I'd keep it generic).

Unfortunately that doesn't really work - the test cannot be really be run in 
parallel since the find_free_ports() stuff here is racy.

  Thomas
Philippe Mathieu-Daudé Sept. 3, 2024, 1:45 p.m. UTC | #3
On 2/9/24 12:23, Thomas Huth wrote:
> On 02/09/2024 11.48, Philippe Mathieu-Daudé wrote:
>> On 30/8/24 15:38, Thomas Huth wrote:
>>> Nothing thrilling in here, it's just a straight forward conversion.
>>>
>>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>>> ---
>>>   tests/functional/meson.build                     |  1 +
>>>   tests/{avocado/vnc.py => functional/test_vnc.py} | 12 +++++++-----
>>>   2 files changed, 8 insertions(+), 5 deletions(-)
>>>   rename tests/{avocado/vnc.py => functional/test_vnc.py} (97%)
>>>   mode change 100644 => 100755
>>>
>>> diff --git a/tests/functional/meson.build b/tests/functional/meson.build
>>> index 34a9b277f8..58f6bcf95d 100644
>>> --- a/tests/functional/meson.build
>>> +++ b/tests/functional/meson.build
>>> @@ -107,6 +107,7 @@ tests_x86_64_system_quick = [
>>>     'pc_cpu_hotplug_props',
>>>     'virtio_version',
>>>     'x86_cpu_model_versions',
>>> +  'vnc',
>>>   ]
>>>   tests_x86_64_system_thorough = [
>>> diff --git a/tests/avocado/vnc.py b/tests/functional/test_vnc.py
>>> old mode 100644
>>> new mode 100755
>>> similarity index 97%
>>> rename from tests/avocado/vnc.py
>>> rename to tests/functional/test_vnc.py
>>> index 862c8996a8..b769d3b268
>>> --- a/tests/avocado/vnc.py
>>> +++ b/tests/functional/test_vnc.py
>>> @@ -1,3 +1,5 @@
>>> +#!/usr/bin/env python3
>>> +#
>>>   # Simple functional tests for VNC functionality
>>>   #
>>>   # Copyright (c) 2018 Red Hat, Inc.
>>> @@ -11,7 +13,7 @@
>>>   import socket
>>>   from typing import List
>>> -from avocado_qemu import QemuSystemTest
>>> +from qemu_test import QemuSystemTest
>>>   VNC_ADDR = '127.0.0.1'
>>> @@ -51,10 +53,7 @@ def find_free_ports(count: int) -> List[int]:
>>>   class Vnc(QemuSystemTest):
>>> -    """
>>> -    :avocado: tags=vnc,quick
>>> -    :avocado: tags=machine:none
>>> -    """
>>> +
>>>       def test_no_vnc(self):
>>>           self.vm.add_args('-nodefaults', '-S')
>>>           self.vm.launch()
>>> @@ -113,3 +112,6 @@ def test_change_listen(self):
>>>           self.assertFalse(check_connect(a))
>>>           self.assertTrue(check_connect(b))
>>>           self.assertTrue(check_connect(c))
>>> +
>>> +if __name__ == '__main__':
>>> +    QemuSystemTest.main()
>>
>> For a faithful conversion we need to squash:
>>
>> -- >8 --
>> diff --git a/tests/functional/meson.build b/tests/functional/meson.build
>> index 6b00d240dd..a590646adc 100644
>> --- a/tests/functional/meson.build
>> +++ b/tests/functional/meson.build
>> @@ -26,6 +26,7 @@ tests_generic_system = [
>>     'empty_cpu_model',
>>     'info_usernet',
>>     'version',
>> +  'vnc',
>>   ]
>>
>>   tests_generic_linuxuser = [
>> @@ -123,7 +124,6 @@ tests_x86_64_system_quick = [
>>     'pc_cpu_hotplug_props',
>>     'virtio_version',
>>     'x86_cpu_model_versions',
>> -  'vnc',
>>   ]
>>
>> ---
>>
>> (each test is <1s so I'd keep it generic).
> 
> Unfortunately that doesn't really work - the test cannot be really be 
> run in parallel since the find_free_ports() stuff here is racy.

Oh right, I ran check-functional-{arm,mips,...} with at most 3 targets
but never tried the full 'check-functional'.

> 
>   Thomas
> 
>
Philippe Mathieu-Daudé Sept. 3, 2024, 2:14 p.m. UTC | #4
On 3/9/24 15:45, Philippe Mathieu-Daudé wrote:
> On 2/9/24 12:23, Thomas Huth wrote:
>> On 02/09/2024 11.48, Philippe Mathieu-Daudé wrote:
>>> On 30/8/24 15:38, Thomas Huth wrote:
>>>> Nothing thrilling in here, it's just a straight forward conversion.
>>>>
>>>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>>>> ---
>>>>   tests/functional/meson.build                     |  1 +
>>>>   tests/{avocado/vnc.py => functional/test_vnc.py} | 12 +++++++-----
>>>>   2 files changed, 8 insertions(+), 5 deletions(-)
>>>>   rename tests/{avocado/vnc.py => functional/test_vnc.py} (97%)
>>>>   mode change 100644 => 100755
>>>>
>>>> diff --git a/tests/functional/meson.build 
>>>> b/tests/functional/meson.build
>>>> index 34a9b277f8..58f6bcf95d 100644
>>>> --- a/tests/functional/meson.build
>>>> +++ b/tests/functional/meson.build
>>>> @@ -107,6 +107,7 @@ tests_x86_64_system_quick = [
>>>>     'pc_cpu_hotplug_props',
>>>>     'virtio_version',
>>>>     'x86_cpu_model_versions',
>>>> +  'vnc',
>>>>   ]
>>>>   tests_x86_64_system_thorough = [
>>>> diff --git a/tests/avocado/vnc.py b/tests/functional/test_vnc.py
>>>> old mode 100644
>>>> new mode 100755
>>>> similarity index 97%
>>>> rename from tests/avocado/vnc.py
>>>> rename to tests/functional/test_vnc.py
>>>> index 862c8996a8..b769d3b268
>>>> --- a/tests/avocado/vnc.py
>>>> +++ b/tests/functional/test_vnc.py
>>>> @@ -1,3 +1,5 @@
>>>> +#!/usr/bin/env python3
>>>> +#
>>>>   # Simple functional tests for VNC functionality
>>>>   #
>>>>   # Copyright (c) 2018 Red Hat, Inc.
>>>> @@ -11,7 +13,7 @@
>>>>   import socket
>>>>   from typing import List
>>>> -from avocado_qemu import QemuSystemTest
>>>> +from qemu_test import QemuSystemTest
>>>>   VNC_ADDR = '127.0.0.1'
>>>> @@ -51,10 +53,7 @@ def find_free_ports(count: int) -> List[int]:
>>>>   class Vnc(QemuSystemTest):
>>>> -    """
>>>> -    :avocado: tags=vnc,quick
>>>> -    :avocado: tags=machine:none
>>>> -    """
>>>> +
>>>>       def test_no_vnc(self):
>>>>           self.vm.add_args('-nodefaults', '-S')
>>>>           self.vm.launch()
>>>> @@ -113,3 +112,6 @@ def test_change_listen(self):
>>>>           self.assertFalse(check_connect(a))
>>>>           self.assertTrue(check_connect(b))
>>>>           self.assertTrue(check_connect(c))
>>>> +
>>>> +if __name__ == '__main__':
>>>> +    QemuSystemTest.main()
>>>
>>> For a faithful conversion we need to squash:
>>>
>>> -- >8 --
>>> diff --git a/tests/functional/meson.build b/tests/functional/meson.build
>>> index 6b00d240dd..a590646adc 100644
>>> --- a/tests/functional/meson.build
>>> +++ b/tests/functional/meson.build
>>> @@ -26,6 +26,7 @@ tests_generic_system = [
>>>     'empty_cpu_model',
>>>     'info_usernet',
>>>     'version',
>>> +  'vnc',
>>>   ]
>>>
>>>   tests_generic_linuxuser = [
>>> @@ -123,7 +124,6 @@ tests_x86_64_system_quick = [
>>>     'pc_cpu_hotplug_props',
>>>     'virtio_version',
>>>     'x86_cpu_model_versions',
>>> -  'vnc',
>>>   ]
>>>
>>> ---
>>>
>>> (each test is <1s so I'd keep it generic).
>>
>> Unfortunately that doesn't really work - the test cannot be really be 
>> run in parallel since the find_free_ports() stuff here is racy.
> 
> Oh right, I ran check-functional-{arm,mips,...} with at most 3 targets
> but never tried the full 'check-functional'.

Also I just noticed this test doesn't explicit machine, so when
a target don't have a default we get:

  Exit code: 1
  Command: qemu-system-arm -display none -vga none -chardev 
socket,id=mon,fd=14 -mon chardev=mon,mode=control -nodefaults -S
  Output: qemu-system-arm: No machine specified, and there is no default
diff mbox series

Patch

diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index 34a9b277f8..58f6bcf95d 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -107,6 +107,7 @@  tests_x86_64_system_quick = [
   'pc_cpu_hotplug_props',
   'virtio_version',
   'x86_cpu_model_versions',
+  'vnc',
 ]
 
 tests_x86_64_system_thorough = [
diff --git a/tests/avocado/vnc.py b/tests/functional/test_vnc.py
old mode 100644
new mode 100755
similarity index 97%
rename from tests/avocado/vnc.py
rename to tests/functional/test_vnc.py
index 862c8996a8..b769d3b268
--- a/tests/avocado/vnc.py
+++ b/tests/functional/test_vnc.py
@@ -1,3 +1,5 @@ 
+#!/usr/bin/env python3
+#
 # Simple functional tests for VNC functionality
 #
 # Copyright (c) 2018 Red Hat, Inc.
@@ -11,7 +13,7 @@ 
 import socket
 from typing import List
 
-from avocado_qemu import QemuSystemTest
+from qemu_test import QemuSystemTest
 
 
 VNC_ADDR = '127.0.0.1'
@@ -51,10 +53,7 @@  def find_free_ports(count: int) -> List[int]:
 
 
 class Vnc(QemuSystemTest):
-    """
-    :avocado: tags=vnc,quick
-    :avocado: tags=machine:none
-    """
+
     def test_no_vnc(self):
         self.vm.add_args('-nodefaults', '-S')
         self.vm.launch()
@@ -113,3 +112,6 @@  def test_change_listen(self):
         self.assertFalse(check_connect(a))
         self.assertTrue(check_connect(b))
         self.assertTrue(check_connect(c))
+
+if __name__ == '__main__':
+    QemuSystemTest.main()