summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorEilís 'pidge' Ní Fhlannagáin <pidge@baylibre.com>2024-03-06 14:30:20 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-03-07 12:12:58 +0000
commit287b4f0a8244f7214f6a1aaa84ef16cc528f8326 (patch)
treecfcfc17ae3dd75294dba27430d91e28878ed3bc9 /meta/lib/oeqa
parent7f7032c7613abd62ce510c98211c75fc7c5e7090 (diff)
downloadopenembedded-core-287b4f0a8244f7214f6a1aaa84ef16cc528f8326.tar.gz
oeqa/runtime/login: Add screenshot sample logic/timeout/dbus-wait
This patch uses dbus-wait to wait for matchbox to be up. Once that happens, it sets a timeout of 60 seconds and takes a screenshot and compares it, every 2 seconds. If diff=0 it passes. If the timeout ends, it fails. Signed-off-by: Eilís 'pidge' Ní Fhlannagáin <pidge@baylibre.com>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/runtime/cases/login.py79
1 files changed, 41 insertions, 38 deletions
diff --git a/meta/lib/oeqa/runtime/cases/login.py b/meta/lib/oeqa/runtime/cases/login.py
index edbc48ac20..0a662e5d02 100644
--- a/meta/lib/oeqa/runtime/cases/login.py
+++ b/meta/lib/oeqa/runtime/cases/login.py
@@ -26,7 +26,7 @@ from oeqa.runtime.decorator.package import OEHasPackage
###
class LoginTest(OERuntimeTestCase):
- @OEHasPackage(['matchbox-desktop'])
+ @OEHasPackage(['matchbox-desktop', 'dbus-wait'])
def test_screenshot(self):
if self.td.get('MACHINE') in ("qemuppc64", "qemuarmv5", "qemuriscv32", "qemuriscv64", "qemuloongarch64"):
self.skipTest("{0} is not currently supported.".format(self.td.get('MACHINE')))
@@ -66,45 +66,48 @@ class LoginTest(OERuntimeTestCase):
# Which is ugly and I hate it but it 'works' for various definitions of
# 'works'.
###
+ status, output = self.target.run('dbus-wait org.matchbox_project.desktop Loaded')
+ if status != 0:
+ self.fail('dbus-wait failed. This could mean that the image never loaded the matchbox desktop.')
- # qemumips takes forever to render. We could probably get away with 20
- # here were it not for that.
- time.sleep(40)
-
+ # Start taking screenshots every 2 seconds until diff=0 or timeout is 60 seconds
+ timeout = time.time() + 60
+ diff = True
with tempfile.NamedTemporaryFile(prefix="oeqa-screenshot-login", suffix=".png") as t:
- ret = self.target.runner.run_monitor("screendump", args={"filename": t.name, "format":"png"})
-
- # Find out size of image so we can determine where to blank out clock.
- # qemuarm and qemuppc are odd as it doesn't resize the window and returns
- # incorrect widths
- if self.td.get('MACHINE') == "qemuarm" or self.td.get('MACHINE') == "qemuppc":
- width = "640"
- else:
- cmd = "identify.im7 -ping -format '%w' {0}".format(t.name)
- width = subprocess.check_output(cmd, shell=True, env=ourenv).decode()
-
- rblank = int(float(width))
- lblank = rblank-80
-
- # Use the meta-oe version of convert, along with it's suffix. This blanks out the clock.
- cmd = "convert.im7 {0} -fill white -draw 'rectangle {1},4 {2},28' {3}".format(t.name, str(rblank), str(lblank), t.name)
- convert_out=subprocess.check_output(cmd, shell=True, env=ourenv).decode()
-
-
- bb.utils.mkdirhier(saved_screenshots_dir)
- savedfile = "{0}/saved-{1}-{2}-{3}.png".format(saved_screenshots_dir, \
- datetime.timestamp(datetime.now()), \
- pn, \
- self.td.get('MACHINE'))
- shutil.copy2(t.name, savedfile)
-
- refimage = self.td.get('COREBASE') + "/meta/files/screenshot-tests/" + pn + "-" + self.td.get('MACHINE') +".png"
- if not os.path.exists(refimage):
- self.skipTest("No reference image for comparision (%s)" % refimage)
-
- cmd = "compare.im7 -metric MSE {0} {1} /dev/null".format(t.name, refimage)
- compare_out = subprocess.run(cmd, shell=True, capture_output=True, text=True, env=ourenv)
- diff=float(compare_out.stderr.replace("(", "").replace(")","").split()[1])
+ while diff != 0 or time.time() > timeout:
+ time.sleep(2)
+ ret = self.target.runner.run_monitor("screendump", args={"filename": t.name, "format":"png"})
+
+ # Find out size of image so we can determine where to blank out clock.
+ # qemuarm and qemuppc are odd as it doesn't resize the window and returns
+ # incorrect widths
+ if self.td.get('MACHINE') == "qemuarm" or self.td.get('MACHINE') == "qemuppc":
+ width = "640"
+ else:
+ cmd = "identify.im7 -ping -format '%w' {0}".format(t.name)
+ width = subprocess.check_output(cmd, shell=True, env=ourenv).decode()
+
+ rblank = int(float(width))
+ lblank = rblank-80
+
+ # Use the meta-oe version of convert, along with it's suffix. This blanks out the clock.
+ cmd = "convert.im7 {0} -fill white -draw 'rectangle {1},4 {2},28' {3}".format(t.name, str(rblank), str(lblank), t.name)
+ convert_out=subprocess.check_output(cmd, shell=True, env=ourenv).decode()
+
+ bb.utils.mkdirhier(saved_screenshots_dir)
+ savedfile = "{0}/saved-{1}-{2}-{3}.png".format(saved_screenshots_dir, \
+ datetime.timestamp(datetime.now()), \
+ pn, \
+ self.td.get('MACHINE'))
+ shutil.copy2(t.name, savedfile)
+
+ refimage = self.td.get('COREBASE') + "/meta/files/screenshot-tests/" + pn + "-" + self.td.get('MACHINE') +".png"
+ if not os.path.exists(refimage):
+ self.skipTest("No reference image for comparision (%s)" % refimage)
+
+ cmd = "compare.im7 -metric MSE {0} {1} /dev/null".format(t.name, refimage)
+ compare_out = subprocess.run(cmd, shell=True, capture_output=True, text=True, env=ourenv)
+ diff=float(compare_out.stderr.replace("(", "").replace(")","").split()[1])
if diff > 0:
# Keep a copy of the failed screenshot so we can see what happened.
self.fail("Screenshot diff is {0}. Failed image stored in {1}".format(str(diff), savedfile))