Skip to contentSkip to conversation

support/runtime-test: extend graphic testing for weston + flutter (branch yem/flutter)

PATCH Superseded Yann E. MORIN 1 participant 3 messages Sep 30, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover support/runtime-test: extend graphic testing for weston + flutter (branch yem/flutter)

Hello All!

This little two-patch series extends the runtime tests with a helper to allow easily testing that a graphical application properly renders something, and converts te weston test tousing it,and finally extends the flutter test to use it.

Regards,
Yann E. MORIN.

----------------------------------------------------------------
Yann E. MORIN (2):
support/runtime-test: add helper to test graphics rendering suport/runtime-test: extend flutter test to check rendering is happening

 support/testing/tests/graphics_base.py             | 39 ++++++++++++++
 support/testing/tests/package/test_flutter.py      | 33 ++++++++++--
 .../flutter-gallery.service                        |  1 -
 support/testing/tests/package/test_weston.py       | 61 ++++------------------
 4 files changed, 77 insertions(+), 57 deletions(-)
 create mode 100644 support/testing/tests/graphics_base.py
 delete mode 120000 support/testing/tests/package/test_flutter/overlay/etc/systemd/system/multi-user.target.wants/flutter-gallery.service
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 1/2 support/runtime-test: add helper to test graphics rendering

In 4edb0e3456ef (support/testing/tests/package/test_weston.py: new runtime test),the weston test was introduced, and thus was the first that needed to test that rendering was happening.

Now we also have a test for a flutter application, and we'll want to have it test the rendering too.

Move the corresponding code to a helper that can be reused by other tests, rather than duplicate (or reinvent) it.

Switch weston to using that new helper.

---
 support/testing/tests/graphics_base.py       | 39 +++++++++++++
 support/testing/tests/package/test_weston.py | 61 ++++----------------
 2 files changed, 49 insertions(+), 51 deletions(-)
 create mode 100644 support/testing/tests/graphics_base.py
support/testing/tests/graphics_base.py new file +39 -0
new file mode 100644
index 0000000000..15a4c00bb2
@@ -0,0 +1,39 @@
+class GraphicsBase:
+    def get_n_fb_crc(self, *, count=10, uniq=False, timeout=-1):
+        """
+        Return count DRM CRC from the framebuffer. If uniq is True,
+        only unique CRCs are returned (which may be less than the
+        requested cont).
+        Returns a possibly empty list of integers.
+        Set timeout to -1 for no timeout, or to a positive number for
+        a timeout of that many seconds.
+        """
+        # DRM CRCs are exposed through a sysfs pseudo file
+        try:
+            self.debugfs_mounted
+        except AttributeError:
+            # Note: some init system (e.g. systemd) may have this already
+            # mounted, so check beforehand
+            self.assertRunOk("mountpoint /sys/kernel/debug/ || mount -t debugfs none /sys/kernel/debug/")
+            self.debugfs_mounted = True
+
+        # The first column is the frame number, the second column is the
+        # CRC measure. We use "head" to get the needed CRC count.
+        disp_crc_path = "/sys/kernel/debug/dri/0/crtc-0/crc/data"
+        cmd = f"head -{count} {disp_crc_path}"
+
+        # The DRM CRC sysfs pseudo file lines are terminated by '\n'
+        # and '\0'. We remove the '\0' to have a text-only output.
+        cmd += " | tr -d '\\000'"
+
+        # Finally, we drop the frame counter, and keep only the second
+        # column (CRC values)
+        cmd += " | cut -f 2 -d ' '"
+
+        if uniq:
+            cmd += " | sort -u"
+
+        output, exit_code = self.emulator.run(cmd, timeout=timeout)
+        self.assertTrue(exit_code == 0, f"'{cmd}' failed with exit code {exit_code}")
+
+        return [int(crc, 16) for crc in output]
support/testing/tests/package/test_weston.py +10 -51

105 lines not on this page · raw message

Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

PATCH 2/2 suport/runtime-test: extend flutter test to check rendering is happening

In reply to Yann E. MORIN

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 fultter 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, during, and after the application runs.

---
 support/testing/tests/package/test_flutter.py | 33 ++++++++++++++++---
 .../flutter-gallery.service                   |  1 -
 2 files changed, 28 insertions(+), 6 deletions(-)
 delete mode 120000 support/testing/tests/package/test_flutter/overlay/etc/systemd/system/multi-user.target.wants/flutter-gallery.service
support/testing/tests/package/test_flutter.py +28 -5
index a3e98a43e5..6368bd1372 100644
@@ -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
@@ -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 Aapp. 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 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.assertEqual(gallery_crc, empty_crc, "gallery app did stop rendering")
support/testing/tests/package/test_flutter/overlay/etc/systemd/system/multi-user.target.wants/flutter-gallery.service deleted +0 -1
deleted file mode 120000
index 40993fb16c..0000000000
@@ -1 +0,0 @@
-../../../../usr/lib/systemd/system/flutter-gallery.service
\ No newline at end of file
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot