summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime
diff options
context:
space:
mode:
authorEilís 'pidge' Ní Fhlannagáin <pidge@baylibre.com>2024-02-29 12:05:07 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-03-07 17:27:51 +0000
commitb49d42ce90f0f910b6a4ec3a5ba26eccc543076c (patch)
treeddd0ac4e9a9d431e6b37c0597cc66b329925f3d7 /meta/lib/oeqa/runtime
parentf4665afc3c48a3351bd249e26338c50a9914bad2 (diff)
downloadpoky-b49d42ce90f0f910b6a4ec3a5ba26eccc543076c.tar.gz
oeqa/runtime/login: Proof of concept for screenshot testcases
This takes the work rburton did on image screenshot testing and expands it. Right now this works with most of the qemu based machines except for - qemuppc64 - qemuarmv5 - qemuriscv32 - qemuloongarch64 See "Known Issues" further down. This test takes a screendump of a qemu image, blanks out the clock and compares it to an image we have on record. If the diff is exact, the test passes. If not, it stores the image in build/failed-images and fails out. In order to enable this test, you will need meta-openembedded/meta-oe in your bblayers.conf for imagemagick and the following in local.conf: IMAGE_CLASSES += "testimage" TEST_SUITES = "login" TESTIMAGEDEPENDS:append:qemuall = " imagemagick-native:do_populate_sysroot " Known Issues ------------ The main issue is that I've yet to find a gating factor that would allow me to tell when the qemu instance is fully up and rendered. I've tried a few tactics here, (dbus-wait, qmp) but for now a disgusting time.sleep(30) is there. You can replicate this by running qemumips. The screen load takes forever, but you even see it on qemux86 where the Home and Workspace Switch icons will sometimes take a while to fully load. Eventually I'm going to have to take multiple screenshots and compare them, but then you get into the issue where the question is, is the diff greater than 0 because it hasn't fully loaded or something is actually incorrect. There are the issues I know about: - runqemu qemuppc64 comes up blank. - qemuarmv5 comes up with multiple heads but sending "head" to screendump. seems to create a png with a bad header. - qemuriscv32 and qemuloongarch64 don't work with testimage apparently? - qemumips64 is missing mouse icon. - qemumips takes forever to render and is missing mouse icon. - qemuarm and qemuppc return incorrect width - All images have home and screen flipper icons not always rendered fully at first. The sleep seems to help this out some, depending on machine load. (From OE-Core rev: dc7cefbaccde50df6c4396e66d50659a45e00631) Signed-off-by: Eilís 'pidge' Ní Fhlannagáin <pidge@baylibre.com> Co-authored-by: Ross Burton <ross.burton@arm.com> Co-authored-by: Eilís 'pidge' Ní Fhlannagáin <pidge@baylibre.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/runtime')
-rw-r--r--meta/lib/oeqa/runtime/cases/login.py107
1 files changed, 107 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/cases/login.py b/meta/lib/oeqa/runtime/cases/login.py
new file mode 100644
index 0000000000..aea3bfc778
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/login.py
@@ -0,0 +1,107 @@
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7import subprocess
8from oeqa.runtime.case import OERuntimeTestCase
9import tempfile
10from oeqa.runtime.decorator.package import OEHasPackage
11
12### Status of qemu images.
13# - runqemu qemuppc64 comes up blank. (skip)
14# - qemuarmv5 comes up with multiple heads but sending "head" to screendump.
15# seems to create a png with a bad header? (skip for now, but come back to fix)
16# - qemuriscv32 and qemuloongarch64 doesn't work with testimage apparently? (skip)
17# - qemumips64 is missing mouse icon.
18# - qemumips takes forever to render and is missing mouse icon.
19# - qemuarm and qemuppc are odd as they don't resize so we need to just set width.
20# - All images have home and screen flipper icons not always rendered fully at first.
21# the sleep seems to help this out some, depending on machine load.
22###
23
24class LoginTest(OERuntimeTestCase):
25 def test_screenshot(self):
26 if self.td.get('MACHINE') in ("qemuppc64", "qemuarmv5", "qemuriscv32", "qemuloongarch64"):
27 self.skipTest("{0} is not currently supported.".format(self.td.get('MACHINE')))
28
29 # Set DEBUG_CREATE_IMAGES to 1 in order to populate the image-test images directory.
30 DEBUG_CREATE_IMAGES="0"
31 # Store failed images so we can debug them.
32 failed_image_dir=self.td.get('TOPDIR') + "/failed-images/"
33
34 ###
35 # This is a really horrible way of doing this but I've not found the
36 # right event to determine "The system is loaded and screen is rendered"
37 #
38 # Using dbus-wait for matchbox is the wrong answer because while it
39 # ensures the system is up, it doesn't mean the screen is rendered.
40 #
41 # Checking the qmp socket doesn't work afaik either.
42 #
43 # One way to do this is to do compares of known good screendumps until
44 # we either get expected or close to expected or we time out. Part of the
45 # issue here with that is that there is a very fine difference in the
46 # diff between a screendump where the icons haven't loaded yet and
47 # one where they won't load. I'll look at that next, but, for now, this.
48 #
49 # Which is ugly and I hate it but it 'works' for various definitions of
50 # 'works'.
51 ###
52
53 import time
54
55 # qemumips takes forever to render. We could probably get away with 20
56 # here were it not for that.
57 time.sleep(40)
58
59 with tempfile.NamedTemporaryFile(prefix="oeqa-screenshot-login", suffix=".png") as t:
60 ret = self.target.runner.run_monitor("screendump", args={"filename": t.name, "format":"png"})
61
62 # Find out size of image so we can determine where to blank out clock.
63 # qemuarm and qemuppc are odd as it doesn't resize the window and returns
64 # incorrect widths
65 if self.td.get('MACHINE')=="qemuarm" or self.td.get('MACHINE')=="qemuppc":
66 width="640"
67 else:
68 cmd = "identify.im7 -ping -format '%w' {0}".format(t.name)
69 width = subprocess.check_output(cmd, shell=True).decode()
70
71 rblank=int(float(width))
72 lblank=rblank-40
73
74 # Use the meta-oe version of convert, along with it's suffix. This blanks out the clock.
75 cmd = "convert.im7 {0} -fill white -draw 'rectangle {1},10 {2},22' {3}".format(t.name, str(rblank), str(lblank), t.name)
76 convert_out=subprocess.check_output(cmd, shell=True).decode()
77
78 if DEBUG_CREATE_IMAGES=="1":
79 # You probably aren't interested in this as it's just to create the images we compare against.
80 import shutil
81 shutil.copy2(t.name, "{0}/meta/files/image-tests/core-image-sato-{1}.png".format(self.td.get('COREBASE'), \
82 self.td.get('MACHINE')))
83 self.skipTest("Created a reference image for {0} and placed it in {1}/meta/files/image-tests/.".format(self.td.get('MACHINE'), self.td.get('COREBASE')))
84 else:
85 # Use the meta-oe version of compare, along with it's suffix.
86 cmd = "compare.im7 -metric MSE {0} {1}/meta/files/image-tests/core-image-sato-{2}.png /dev/null".format(t.name, \
87 self.td.get('COREBASE'), \
88 self.td.get('MACHINE'))
89 compare_out = subprocess.run(cmd, shell=True, capture_output=True, text=True)
90 diff=float(compare_out.stderr.replace("(", "").replace(")","").split()[1])
91 if diff > 0:
92 from datetime import datetime
93 import shutil
94 import os
95 try:
96 os.mkdir(failed_image_dir)
97 except FileExistsError:
98 # directory exists
99 pass
100 # Keep a copy of the failed screenshot so we can see what happened.
101 failedfile="{0}/failed-{1}-core-image-sato-{2}.png".format(failed_image_dir, \
102 datetime.timestamp(datetime.now()), \
103 self.td.get('MACHINE'))
104 shutil.copy2(t.name, failedfile)
105 self.fail("Screenshot diff is {0}. Failed image stored in {1}".format(str(diff), failedfile))
106 else:
107 self.assertEqual(0, diff, "Screenshot diff is {0}.".format(str(diff)))