mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-06 15:43:51 -09:00
In 4edb0e3456 (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.
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Julien Olivain <ju.o@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
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]
|