[PATCH] tests/functional: Speed up the avr_mega2560 test

Thomas Huth posted 1 patch 5 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250603184710.25651-1-thuth@redhat.com
Maintainers: Michael Rolnik <mrolnik@gmail.com>
tests/functional/test_avr_mega2560.py | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
[PATCH] tests/functional: Speed up the avr_mega2560 test
Posted by Thomas Huth 5 months, 2 weeks ago
From: Thomas Huth <thuth@redhat.com>

We can simply check for the expected pattern on the console,
no need to wait for two seconds here to search for the pattern
in the log at the end.

While we're at it, also remove the obsolete "timeout" variable
from this test.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/test_avr_mega2560.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/tests/functional/test_avr_mega2560.py b/tests/functional/test_avr_mega2560.py
index 8e47b4200b1..6359b72af39 100755
--- a/tests/functional/test_avr_mega2560.py
+++ b/tests/functional/test_avr_mega2560.py
@@ -18,12 +18,10 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-import time
+from qemu_test import QemuSystemTest, Asset, wait_for_console_pattern
 
-from qemu_test import QemuSystemTest, Asset
 
 class AVR6Machine(QemuSystemTest):
-    timeout = 5
 
     ASSET_ROM = Asset(('https://github.com/seharris/qemu-avr-tests'
                        '/raw/36c3e67b8755dcf/free-rtos/Demo'
@@ -40,13 +38,12 @@ def test_freertos(self):
         self.set_machine('arduino-mega-2560-v3')
         self.vm.add_args('-bios', rom_path)
         self.vm.add_args('-nographic')
+        self.vm.set_console()
         self.vm.launch()
 
-        time.sleep(2)
-        self.vm.shutdown()
+        wait_for_console_pattern(self,
+                        'XABCDEFGHIJKLMNOPQRSTUVWXABCDEFGHIJKLMNOPQRSTUVWXA')
 
-        self.assertIn('ABCDEFGHIJKLMNOPQRSTUVWXABCDEFGHIJKLMNOPQRSTUVWX',
-                self.vm.get_log())
 
 if __name__ == '__main__':
     QemuSystemTest.main()
-- 
2.49.0
Re: [PATCH] tests/functional: Speed up the avr_mega2560 test
Posted by Mark Cave-Ayland 5 months, 2 weeks ago
On 03/06/2025 19:47, Thomas Huth wrote:

> From: Thomas Huth <thuth@redhat.com>
> 
> We can simply check for the expected pattern on the console,
> no need to wait for two seconds here to search for the pattern
> in the log at the end.
> 
> While we're at it, also remove the obsolete "timeout" variable
> from this test.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   tests/functional/test_avr_mega2560.py | 11 ++++-------
>   1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/tests/functional/test_avr_mega2560.py b/tests/functional/test_avr_mega2560.py
> index 8e47b4200b1..6359b72af39 100755
> --- a/tests/functional/test_avr_mega2560.py
> +++ b/tests/functional/test_avr_mega2560.py
> @@ -18,12 +18,10 @@
>   # along with this program.  If not, see <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.gnu.org_licenses_&d=DwIDAg&c=s883GpUCOChKOHiocYtGcg&r=c23RpsaH4D2MKyD3EPJTDa0BAxz6tV8aUJqVSoytEiY&m=wcQJ2Ax5H667-AP7udJl3WHmdxCv36HyQXx3SArS2oY_w3J2H0bxwEXndR1Iy6og&s=01JTQZmaPX871rnZHJx7JQlhG9qCl2pjRZqbhEfUYlA&e= >.
>   #
>   
> -import time
> +from qemu_test import QemuSystemTest, Asset, wait_for_console_pattern
>   
> -from qemu_test import QemuSystemTest, Asset
>   
>   class AVR6Machine(QemuSystemTest):
> -    timeout = 5
>   
>       ASSET_ROM = Asset(('https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_seharris_qemu-2Davr-2Dtests&d=DwIDAg&c=s883GpUCOChKOHiocYtGcg&r=c23RpsaH4D2MKyD3EPJTDa0BAxz6tV8aUJqVSoytEiY&m=wcQJ2Ax5H667-AP7udJl3WHmdxCv36HyQXx3SArS2oY_w3J2H0bxwEXndR1Iy6og&s=87NS3AlsRs7HAlnHypt34ACHv3b34WXbF9gtk3pKOIE&e= '
>                          '/raw/36c3e67b8755dcf/free-rtos/Demo'
> @@ -40,13 +38,12 @@ def test_freertos(self):
>           self.set_machine('arduino-mega-2560-v3')
>           self.vm.add_args('-bios', rom_path)
>           self.vm.add_args('-nographic')
> +        self.vm.set_console()
>           self.vm.launch()
>   
> -        time.sleep(2)
> -        self.vm.shutdown()
> +        wait_for_console_pattern(self,
> +                        'XABCDEFGHIJKLMNOPQRSTUVWXABCDEFGHIJKLMNOPQRSTUVWXA')
>   
> -        self.assertIn('ABCDEFGHIJKLMNOPQRSTUVWXABCDEFGHIJKLMNOPQRSTUVWX',
> -                self.vm.get_log())
>   
>   if __name__ == '__main__':
>       QemuSystemTest.main()

Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>


ATB,

Mark.
Re: [PATCH] tests/functional: Speed up the avr_mega2560 test
Posted by Philippe Mathieu-Daudé 5 months, 2 weeks ago
On 3/6/25 20:47, Thomas Huth wrote:
> From: Thomas Huth <thuth@redhat.com>
> 
> We can simply check for the expected pattern on the console,
> no need to wait for two seconds here to search for the pattern
> in the log at the end.

IIRC this was due to problem with console reader, now fixed.

> While we're at it, also remove the obsolete "timeout" variable
> from this test.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   tests/functional/test_avr_mega2560.py | 11 ++++-------
>   1 file changed, 4 insertions(+), 7 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Thanks!