diff mbox series

[2/2,v2] suport/runtime-test: extend flutter test to check rendering is happening

Message ID 33ee4b08c20f9c4566cfe82c648f01599cab70b5.1696522656.git.yann.morin.1998@free.fr
State New
Headers show
Series support/runtime-test: extend graphic testing for weston + flutter (branch yem/flutter) | expand

Commit Message

Yann E. MORIN Oct. 5, 2023, 4:17 p.m. UTC
Commit 7f0af11cee31 (support/testing/tests/package/test_flutter.py: new
runtime test) added a simple test that just checked that the systemd
unit launching the application, was active.

It is perfectly possible, from a systemd perspective, that the unit is
active, while the application actually crashes.

Instead, what we need to check, is that the application does actually
render "something"; we don't really care what, as long as we know it is
actually rendering, thus the graphical stack is working and the
aplication stack is running.

Extend the flutter runtime test to also check that the framebuffer is
modified by the application when it is running, similarly to what we do
in the weston test.

We drop the activation of the unit and start it manually, as we want to
check the state of the CRC before, while, and after the application
runs.

We also need to disable the blinking cursor on the console, or we would
not be able to detect whether a change in CRC is due to the application
starting rendering, or to the cursor blinking. We tell the kernel to
disable the cursor with the appropriate kernel command line parameter.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Adam Duskett <aduskett@gmail.com>

---
Changes v1 -> v2:
  - don't mistake blinking cursor for application start  (Adam)
  - properly terminate application  (Adam)
---
 support/testing/tests/package/test_flutter.py | 35 +++++++++++++++----
 .../flutter-gallery.service                   |  1 -
 2 files changed, 29 insertions(+), 7 deletions(-)
 delete mode 120000 support/testing/tests/package/test_flutter/overlay/etc/systemd/system/multi-user.target.wants/flutter-gallery.service

Comments

Adam Duskett Oct. 6, 2023, 11:11 a.m. UTC | #1
Looks good to me!

Reviewed-by: Adam Duskett <aduskett@gmail.com>

On Thu, Oct 5, 2023 at 6:17 PM Yann E. MORIN <yann.morin.1998@free.fr>
wrote:

> Commit 7f0af11cee31 (support/testing/tests/package/test_flutter.py: new
> runtime test) added a simple test that just checked that the systemd
> unit launching the application, was active.
>
> It is perfectly possible, from a systemd perspective, that the unit is
> active, while the application actually crashes.
>
> Instead, what we need to check, is that the application does actually
> render "something"; we don't really care what, as long as we know it is
> actually rendering, thus the graphical stack is working and the
> aplication stack is running.
>
> Extend the flutter runtime test to also check that the framebuffer is
> modified by the application when it is running, similarly to what we do
> in the weston test.
>
> We drop the activation of the unit and start it manually, as we want to
> check the state of the CRC before, while, and after the application
> runs.
>
> We also need to disable the blinking cursor on the console, or we would
> not be able to detect whether a change in CRC is due to the application
> starting rendering, or to the cursor blinking. We tell the kernel to
> disable the cursor with the appropriate kernel command line parameter.
>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Cc: Adam Duskett <aduskett@gmail.com>
>
> ---
> Changes v1 -> v2:
>   - don't mistake blinking cursor for application start  (Adam)
>   - properly terminate application  (Adam)
> ---
>  support/testing/tests/package/test_flutter.py | 35 +++++++++++++++----
>  .../flutter-gallery.service                   |  1 -
>  2 files changed, 29 insertions(+), 7 deletions(-)
>  delete mode 120000
> support/testing/tests/package/test_flutter/overlay/etc/systemd/system/multi-user.target.wants/flutter-gallery.service
>
> diff --git a/support/testing/tests/package/test_flutter.py
> b/support/testing/tests/package/test_flutter.py
> index a3e98a43e5..515c95409f 100644
> --- a/support/testing/tests/package/test_flutter.py
> +++ b/support/testing/tests/package/test_flutter.py
> @@ -1,8 +1,11 @@
>  import os
> +import time
>  import infra.basetest
>
> +from ..graphics_base import GraphicsBase
>
> -class TestFlutter(infra.basetest.BRTest):
> +
> +class TestFlutter(infra.basetest.BRTest, GraphicsBase):
>      config = f"""
>          BR2_aarch64=y
>          BR2_TOOLCHAIN_EXTERNAL=y
> @@ -39,7 +42,7 @@ class TestFlutter(infra.basetest.BRTest):
>          self.emulator.boot(
>              arch="aarch64",
>              kernel=kern,
> -            kernel_cmdline=["root=/dev/vda console=ttyAMA0"],
> +            kernel_cmdline=["root=/dev/vda console=ttyAMA0
> vt.global_cursor_default=0"],
>              options=["-M", "virt",
>                       "-cpu", "cortex-a57",
>                       "-m", "512M",
> @@ -48,7 +51,27 @@ class TestFlutter(infra.basetest.BRTest):
>                       "-vnc", "none",
>                       "-drive", f"file={img},if=virtio,format=raw"])
>          self.emulator.login()
> -        cmd = "systemctl is-active flutter-gallery"
> -        output, exit_code = self.emulator.run(cmd, 10)
> -        self.assertEqual(exit_code, 0)
> -        self.assertEqual(output[0], "active")
> +
> +        # Get the CRC from the current ramebuffer
> +        empty_crc = self.get_n_fb_crc(count=1)[0]
> +
> +        # Start the gallery App. It can take a bit of time to start,
> +        # so lets try a few times. 600 samples should cover about 10s
> +        # @60Hz (although, the rendering could be much slower on slow
> +        # machines)
> +        self.assertRunOk("systemctl start flutter-gallery", timeout=10)
> +        for i in range(600):
> +            gallery_crc = self.get_n_fb_crc(count=1)[0]
> +            if gallery_crc != empty_crc:
> +                break
> +            time.sleep(1)
> +        self.assertNotEqual(gallery_crc, empty_crc, "gallery app did not
> render anything on screen")
> +
> +        # Stop the application, and check it restored the framebuffer
> content
> +        self.assertRunOk("systemctl stop flutter-gallery", timeout=10)
> +        for i in range(600):
> +            gallery_crc = self.get_n_fb_crc(count=1)[0]
> +            if gallery_crc == empty_crc:
> +                break
> +            time.sleep(1)
> +        self.assertEqual(gallery_crc, empty_crc, "gallery app did not
> stop rendering")
> diff --git
> a/support/testing/tests/package/test_flutter/overlay/etc/systemd/system/multi-user.target.wants/flutter-gallery.service
> b/support/testing/tests/package/test_flutter/overlay/etc/systemd/system/multi-user.target.wants/flutter-gallery.service
> deleted file mode 120000
> index 40993fb16c..0000000000
> ---
> a/support/testing/tests/package/test_flutter/overlay/etc/systemd/system/multi-user.target.wants/flutter-gallery.service
> +++ /dev/null
> @@ -1 +0,0 @@
> -../../../../usr/lib/systemd/system/flutter-gallery.service
> \ No newline at end of file
> --
> 2.25.1
>
>
diff mbox series

Patch

diff --git a/support/testing/tests/package/test_flutter.py b/support/testing/tests/package/test_flutter.py
index a3e98a43e5..515c95409f 100644
--- a/support/testing/tests/package/test_flutter.py
+++ b/support/testing/tests/package/test_flutter.py
@@ -1,8 +1,11 @@ 
 import os
+import time
 import infra.basetest
 
+from ..graphics_base import GraphicsBase
 
-class TestFlutter(infra.basetest.BRTest):
+
+class TestFlutter(infra.basetest.BRTest, GraphicsBase):
     config = f"""
         BR2_aarch64=y
         BR2_TOOLCHAIN_EXTERNAL=y
@@ -39,7 +42,7 @@  class TestFlutter(infra.basetest.BRTest):
         self.emulator.boot(
             arch="aarch64",
             kernel=kern,
-            kernel_cmdline=["root=/dev/vda console=ttyAMA0"],
+            kernel_cmdline=["root=/dev/vda console=ttyAMA0 vt.global_cursor_default=0"],
             options=["-M", "virt",
                      "-cpu", "cortex-a57",
                      "-m", "512M",
@@ -48,7 +51,27 @@  class TestFlutter(infra.basetest.BRTest):
                      "-vnc", "none",
                      "-drive", f"file={img},if=virtio,format=raw"])
         self.emulator.login()
-        cmd = "systemctl is-active flutter-gallery"
-        output, exit_code = self.emulator.run(cmd, 10)
-        self.assertEqual(exit_code, 0)
-        self.assertEqual(output[0], "active")
+
+        # Get the CRC from the current ramebuffer
+        empty_crc = self.get_n_fb_crc(count=1)[0]
+
+        # Start the gallery App. It can take a bit of time to start,
+        # so lets try a few times. 600 samples should cover about 10s
+        # @60Hz (although, the rendering could be much slower on slow
+        # machines)
+        self.assertRunOk("systemctl start flutter-gallery", timeout=10)
+        for i in range(600):
+            gallery_crc = self.get_n_fb_crc(count=1)[0]
+            if gallery_crc != empty_crc:
+                break
+            time.sleep(1)
+        self.assertNotEqual(gallery_crc, empty_crc, "gallery app did not render anything on screen")
+
+        # Stop the application, and check it restored the framebuffer content
+        self.assertRunOk("systemctl stop flutter-gallery", timeout=10)
+        for i in range(600):
+            gallery_crc = self.get_n_fb_crc(count=1)[0]
+            if gallery_crc == empty_crc:
+                break
+            time.sleep(1)
+        self.assertEqual(gallery_crc, empty_crc, "gallery app did not stop rendering")
diff --git a/support/testing/tests/package/test_flutter/overlay/etc/systemd/system/multi-user.target.wants/flutter-gallery.service b/support/testing/tests/package/test_flutter/overlay/etc/systemd/system/multi-user.target.wants/flutter-gallery.service
deleted file mode 120000
index 40993fb16c..0000000000
--- a/support/testing/tests/package/test_flutter/overlay/etc/systemd/system/multi-user.target.wants/flutter-gallery.service
+++ /dev/null
@@ -1 +0,0 @@ 
-../../../../usr/lib/systemd/system/flutter-gallery.service
\ No newline at end of file