summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime
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 17:27:51 +0000
commitf6235fef62af1591b2636182f794a858a87b204e (patch)
tree6989f41d3d52d00dcf30b521b38daf1c65ff2438 /meta/lib/oeqa/runtime
parent59c7b5e70628560f0b21ac7d44423976c5fa5050 (diff)
downloadpoky-f6235fef62af1591b2636182f794a858a87b204e.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. (From OE-Core rev: 287b4f0a8244f7214f6a1aaa84ef16cc528f8326) Signed-off-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.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
26### 26###
27 27
28class LoginTest(OERuntimeTestCase): 28class LoginTest(OERuntimeTestCase):
29 @OEHasPackage(['matchbox-desktop']) 29 @OEHasPackage(['matchbox-desktop', 'dbus-wait'])
30 def test_screenshot(self): 30 def test_screenshot(self):
31 if self.td.get('MACHINE') in ("qemuppc64", "qemuarmv5", "qemuriscv32", "qemuriscv64", "qemuloongarch64"): 31 if self.td.get('MACHINE') in ("qemuppc64", "qemuarmv5", "qemuriscv32", "qemuriscv64", "qemuloongarch64"):
32 self.skipTest("{0} is not currently supported.".format(self.td.get('MACHINE'))) 32 self.skipTest("{0} is not currently supported.".format(self.td.get('MACHINE')))
@@ -66,45 +66,48 @@ class LoginTest(OERuntimeTestCase):
66 # Which is ugly and I hate it but it 'works' for various definitions of 66 # Which is ugly and I hate it but it 'works' for various definitions of
67 # 'works'. 67 # 'works'.
68 ### 68 ###
69 status, output = self.target.run('dbus-wait org.matchbox_project.desktop Loaded')
70 if status != 0:
71 self.fail('dbus-wait failed. This could mean that the image never loaded the matchbox desktop.')
69 72
70 # qemumips takes forever to render. We could probably get away with 20 73 # Start taking screenshots every 2 seconds until diff=0 or timeout is 60 seconds
71 # here were it not for that. 74 timeout = time.time() + 60
72 time.sleep(40) 75 diff = True
73
74 with tempfile.NamedTemporaryFile(prefix="oeqa-screenshot-login", suffix=".png") as t: 76 with tempfile.NamedTemporaryFile(prefix="oeqa-screenshot-login", suffix=".png") as t:
75 ret = self.target.runner.run_monitor("screendump", args={"filename": t.name, "format":"png"}) 77 while diff != 0 or time.time() > timeout:
76 78 time.sleep(2)
77 # Find out size of image so we can determine where to blank out clock. 79 ret = self.target.runner.run_monitor("screendump", args={"filename": t.name, "format":"png"})
78 # qemuarm and qemuppc are odd as it doesn't resize the window and returns 80
79 # incorrect widths 81 # Find out size of image so we can determine where to blank out clock.
80 if self.td.get('MACHINE') == "qemuarm" or self.td.get('MACHINE') == "qemuppc": 82 # qemuarm and qemuppc are odd as it doesn't resize the window and returns
81 width = "640" 83 # incorrect widths
82 else: 84 if self.td.get('MACHINE') == "qemuarm" or self.td.get('MACHINE') == "qemuppc":
83 cmd = "identify.im7 -ping -format '%w' {0}".format(t.name) 85 width = "640"
84 width = subprocess.check_output(cmd, shell=True, env=ourenv).decode() 86 else:
85 87 cmd = "identify.im7 -ping -format '%w' {0}".format(t.name)
86 rblank = int(float(width)) 88 width = subprocess.check_output(cmd, shell=True, env=ourenv).decode()
87 lblank = rblank-80 89
88 90 rblank = int(float(width))
89 # Use the meta-oe version of convert, along with it's suffix. This blanks out the clock. 91 lblank = rblank-80
90 cmd = "convert.im7 {0} -fill white -draw 'rectangle {1},4 {2},28' {3}".format(t.name, str(rblank), str(lblank), t.name) 92
91 convert_out=subprocess.check_output(cmd, shell=True, env=ourenv).decode() 93 # Use the meta-oe version of convert, along with it's suffix. This blanks out the clock.
92 94 cmd = "convert.im7 {0} -fill white -draw 'rectangle {1},4 {2},28' {3}".format(t.name, str(rblank), str(lblank), t.name)
93 95 convert_out=subprocess.check_output(cmd, shell=True, env=ourenv).decode()
94 bb.utils.mkdirhier(saved_screenshots_dir) 96
95 savedfile = "{0}/saved-{1}-{2}-{3}.png".format(saved_screenshots_dir, \ 97 bb.utils.mkdirhier(saved_screenshots_dir)
96 datetime.timestamp(datetime.now()), \ 98 savedfile = "{0}/saved-{1}-{2}-{3}.png".format(saved_screenshots_dir, \
97 pn, \ 99 datetime.timestamp(datetime.now()), \
98 self.td.get('MACHINE')) 100 pn, \
99 shutil.copy2(t.name, savedfile) 101 self.td.get('MACHINE'))
100 102 shutil.copy2(t.name, savedfile)
101 refimage = self.td.get('COREBASE') + "/meta/files/screenshot-tests/" + pn + "-" + self.td.get('MACHINE') +".png" 103
102 if not os.path.exists(refimage): 104 refimage = self.td.get('COREBASE') + "/meta/files/screenshot-tests/" + pn + "-" + self.td.get('MACHINE') +".png"
103 self.skipTest("No reference image for comparision (%s)" % refimage) 105 if not os.path.exists(refimage):
104 106 self.skipTest("No reference image for comparision (%s)" % refimage)
105 cmd = "compare.im7 -metric MSE {0} {1} /dev/null".format(t.name, refimage) 107
106 compare_out = subprocess.run(cmd, shell=True, capture_output=True, text=True, env=ourenv) 108 cmd = "compare.im7 -metric MSE {0} {1} /dev/null".format(t.name, refimage)
107 diff=float(compare_out.stderr.replace("(", "").replace(")","").split()[1]) 109 compare_out = subprocess.run(cmd, shell=True, capture_output=True, text=True, env=ourenv)
110 diff=float(compare_out.stderr.replace("(", "").replace(")","").split()[1])
108 if diff > 0: 111 if diff > 0:
109 # Keep a copy of the failed screenshot so we can see what happened. 112 # Keep a copy of the failed screenshot so we can see what happened.
110 self.fail("Screenshot diff is {0}. Failed image stored in {1}".format(str(diff), savedfile)) 113 self.fail("Screenshot diff is {0}. Failed image stored in {1}".format(str(diff), savedfile))