From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Andrew Baumann" <Andrew.Baumann@microsoft.com>,
"Igor Mammedov" <imammedo@redhat.com>
Subject: [PATCH 8/8] tests/acceptance: Count Raspberry Pi logos displayed on framebuffer
Date: Sat, 15 Feb 2020 20:22:16 +0100 [thread overview]
Message-ID: <20200215192216.4899-9-f4bug@amsat.org> (raw)
In-Reply-To: <20200215192216.4899-1-f4bug@amsat.org>
Add a test that verifies that each core properly displays the
Raspberry Pi logo on the framebuffer device.
We simply follow the OpenCV "Template Matching with Multiple Objects"
tutorial, replacing Lionel Messi by a raspberrry:
https://docs.opencv.org/4.2.0/d4/dc6/tutorial_py_template_matching.html
When OpenCV and NumPy are installed, this test can be run using:
$ avocado --show=app,framebuffer run -t device:bcm2835-fb tests/acceptance/
JOB ID : 9bbbc54c0a6fa180348d0b5305507f76852b4da2
JOB LOG : avocado/job-results/job-2020-01-31T23.48-9bbbc54/job.log
(1/1) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_framebuffer_logo:
framebuffer: found raspberry at position (x, y) = (0, 0)
framebuffer: found raspberry at position (x, y) = (71, 0)
framebuffer: found raspberry at position (x, y) = (142, 0)
framebuffer: found raspberry at position (x, y) = (213, 0)
PASS (11.06 s)
RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME : 11.39 s
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
The resulting match can be visualised at https://pasteboard.co/ISzNHtx.png
---
tests/acceptance/boot_linux_console.py | 62 ++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index 989db7d461..7c960051a6 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -12,6 +12,7 @@
import lzma
import gzip
import shutil
+import logging
from avocado import skipUnless
from avocado_qemu import Test
@@ -22,6 +23,19 @@
from avocado.utils import archive
+NUMPY_AVAILABLE = True
+try:
+ import numpy as np
+except ImportError:
+ NUMPY_AVAILABLE = False
+
+CV2_AVAILABLE = True
+try:
+ import cv2
+except ImportError:
+ CV2_AVAILABLE = False
+
+
class BootLinuxConsole(Test):
"""
Boots a Linux kernel and checks that the console is operational and the
@@ -451,6 +465,54 @@ def test_arm_raspi2_uart1(self):
"""
self.do_test_arm_raspi(2, 'bcm2835_aux')
+ @skipUnless(NUMPY_AVAILABLE, 'Python NumPy not installed')
+ @skipUnless(CV2_AVAILABLE, 'Python OpenCV not installed')
+ def test_arm_raspi2_framebuffer_logo(self):
+ """
+ :avocado: tags=arch:arm
+ :avocado: tags=machine:raspi2
+ :avocado: tags=device:bcm2835-fb
+ """
+ screendump_path = os.path.join(self.workdir, 'screendump.pbm')
+ rpilogo_url = ('https://github.com/raspberrypi/linux/raw/'
+ 'raspberrypi-kernel_1.20190517-1/'
+ 'drivers/video/logo/logo_linux_clut224.ppm')
+ rpilogo_hash = 'fff3cc20c6030acce0953147f9baac43f44ed6b0'
+ rpilogo_path = self.fetch_asset(rpilogo_url, asset_hash=rpilogo_hash)
+ deb_url = ('http://archive.raspberrypi.org/debian/'
+ 'pool/main/r/raspberrypi-firmware/'
+ 'raspberrypi-kernel_1.20190215-1_armhf.deb')
+ deb_hash = 'cd284220b32128c5084037553db3c482426f3972'
+ deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+ kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
+ dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
+
+ self.vm.set_console()
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
+ 'earlycon=pl011,0x3f201000 console=ttyAMA0')
+ self.vm.add_args('-kernel', kernel_path,
+ '-dtb', dtb_path,
+ '-append', kernel_command_line)
+ self.vm.launch()
+ framebuffer_ready = 'Console: switching to colour frame buffer device'
+ wait_for_console_pattern(self, framebuffer_ready)
+ self.vm.command('human-monitor-command', command_line='stop')
+ self.vm.command('human-monitor-command',
+ command_line='screendump %s' % screendump_path)
+ logger = logging.getLogger('framebuffer')
+
+ cpu_cores_count = 4
+ match_threshold = 0.95
+ screendump_bgr = cv2.imread(screendump_path, cv2.IMREAD_COLOR)
+ rpilogo_bgr = cv2.imread(rpilogo_path, cv2.IMREAD_COLOR)
+ result = cv2.matchTemplate(screendump_bgr, rpilogo_bgr,
+ cv2.TM_CCOEFF_NORMED)
+ loc = np.where(result >= match_threshold)
+ rpilogo_count = 0
+ for rpilogo_count, pt in enumerate(zip(*loc[::-1]), start=1):
+ logger.debug('found raspberry at position (x, y) = %s', pt)
+ self.assertGreaterEqual(rpilogo_count, cpu_cores_count)
+
def test_arm_exynos4210_initrd(self):
"""
:avocado: tags=arch:arm
--
2.21.1
next prev parent reply other threads:[~2020-02-15 19:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-15 19:22 [PATCH 0/8] hw/arm: Add raspi[0123] acceptance tests Philippe Mathieu-Daudé
2020-02-15 19:22 ` [PATCH 1/8] tests/acceptance/boot_linux_console: Use raspi console model as key Philippe Mathieu-Daudé
2020-02-17 8:25 ` Luc Michel
2020-02-15 19:22 ` [PATCH 2/8] tests/acceptance/boot_linux_console: Add raspi version=2 parameter Philippe Mathieu-Daudé
2020-02-17 8:26 ` Luc Michel
2020-02-15 19:22 ` [PATCH 3/8] tests/acceptance/boot_linux_console: Test the raspi1 console Philippe Mathieu-Daudé
2020-02-17 8:27 ` Luc Michel
2020-02-15 19:22 ` [PATCH 4/8] tests/acceptance/boot_linux_console: Test the raspi0 console Philippe Mathieu-Daudé
2020-02-17 8:27 ` Luc Michel
2020-02-15 19:22 ` [PATCH 5/8] tests/acceptance/boot_linux_console: Test the raspi1 AUX console Philippe Mathieu-Daudé
2020-02-17 8:28 ` Luc Michel
2020-02-15 19:22 ` [PATCH 6/8] tests/boot_linux_console: Test booting U-Boot on the Raspberry Pi 2 Philippe Mathieu-Daudé
2020-02-17 8:28 ` Luc Michel
2020-02-15 19:22 ` [PATCH 7/8] tests/boot_linux_console: Test booting U-Boot on the Raspberry Pi 3 Philippe Mathieu-Daudé
2020-02-17 8:28 ` Luc Michel
2020-02-15 19:22 ` Philippe Mathieu-Daudé [this message]
2020-02-17 8:29 ` [PATCH 8/8] tests/acceptance: Count Raspberry Pi logos displayed on framebuffer Luc Michel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200215192216.4899-9-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=Andrew.Baumann@microsoft.com \
--cc=imammedo@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).