* [PATCH 0/1] tests/acceptance: Count Raspberry Pi logos displayed on framebuffer @ 2020-01-31 23:24 Philippe Mathieu-Daudé 2020-01-31 23:24 ` [PATCH 1/1] " Philippe Mathieu-Daudé 0 siblings, 1 reply; 6+ messages in thread From: Philippe Mathieu-Daudé @ 2020-01-31 23:24 UTC (permalink / raw) To: qemu-devel Cc: Eduardo Habkost, Dr . David Alan Gilbert, Wainer dos Santos Moschetta, Philippe Mathieu-Daudé, qemu-arm, Gerd Hoffmann, Cleber Rosa This is a simple Avocado test that use OpenCV to find the 4 Raspberry Pi logo on the framebuffer screen dump. The resulting match can be visualised at: https://pasteboard.co/ISzNHtx.png It is very fast, around 11 seconds on my laptop. The test probably won't stay in boot_linux_console.py but will go into tests/acceptance/machine_arm_raspi.py, but I wanted to show this test could work to test SMP CPUs. Similar test: "integratorcp: Verify Tux is displayed on framebuffer" https://lists.gnu.org/archive/html/qemu-devel/2020-01/msg08103.html Philippe Mathieu-Daudé (1): tests/acceptance: Count Raspberry Pi logos displayed on framebuffer tests/acceptance/boot_linux_console.py | 62 ++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) -- 2.21.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/1] tests/acceptance: Count Raspberry Pi logos displayed on framebuffer 2020-01-31 23:24 [PATCH 0/1] tests/acceptance: Count Raspberry Pi logos displayed on framebuffer Philippe Mathieu-Daudé @ 2020-01-31 23:24 ` Philippe Mathieu-Daudé 2020-02-03 14:21 ` Wainer dos Santos Moschetta 0 siblings, 1 reply; 6+ messages in thread From: Philippe Mathieu-Daudé @ 2020-01-31 23:24 UTC (permalink / raw) To: qemu-devel Cc: Eduardo Habkost, Dr . David Alan Gilbert, Wainer dos Santos Moschetta, Philippe Mathieu-Daudé, qemu-arm, Gerd Hoffmann, Cleber Rosa 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 e40b84651b..4e69a83a12 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -12,6 +12,7 @@ import os import lzma import gzip import shutil +import logging from avocado import skipUnless from avocado_qemu import Test @@ -21,6 +22,19 @@ from avocado.utils import process 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 @@ -360,6 +374,54 @@ class BootLinuxConsole(Test): """ self.do_test_arm_raspi2(0) + @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 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] tests/acceptance: Count Raspberry Pi logos displayed on framebuffer 2020-01-31 23:24 ` [PATCH 1/1] " Philippe Mathieu-Daudé @ 2020-02-03 14:21 ` Wainer dos Santos Moschetta 2020-02-03 15:48 ` Eduardo Habkost 2020-02-03 16:08 ` Philippe Mathieu-Daudé 0 siblings, 2 replies; 6+ messages in thread From: Wainer dos Santos Moschetta @ 2020-02-03 14:21 UTC (permalink / raw) To: Philippe Mathieu-Daudé, qemu-devel Cc: qemu-arm, Gerd Hoffmann, Dr . David Alan Gilbert, Eduardo Habkost, Cleber Rosa On 1/31/20 9:24 PM, Philippe Mathieu-Daudé wrote: > 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 e40b84651b..4e69a83a12 100644 > --- a/tests/acceptance/boot_linux_console.py > +++ b/tests/acceptance/boot_linux_console.py > @@ -12,6 +12,7 @@ import os > import lzma > import gzip > import shutil > +import logging > > from avocado import skipUnless > from avocado_qemu import Test > @@ -21,6 +22,19 @@ from avocado.utils import process > 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 > + > + Those Python packages are only needed by this new test case, and the test is likely to be moved to a separate file soon. So I suggest to put those availability checks inside the test method, so easing the future removal. And use self.cancel() to cancel the test (if the case). > class BootLinuxConsole(Test): > """ > Boots a Linux kernel and checks that the console is operational and the > @@ -360,6 +374,54 @@ class BootLinuxConsole(Test): > """ > self.do_test_arm_raspi2(0) > > + @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 Won't this fail if host cpu cores are less than 4? Thanks! - Wainer > + 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] tests/acceptance: Count Raspberry Pi logos displayed on framebuffer 2020-02-03 14:21 ` Wainer dos Santos Moschetta @ 2020-02-03 15:48 ` Eduardo Habkost 2020-02-03 16:08 ` Philippe Mathieu-Daudé 1 sibling, 0 replies; 6+ messages in thread From: Eduardo Habkost @ 2020-02-03 15:48 UTC (permalink / raw) To: Wainer dos Santos Moschetta Cc: qemu-devel, Dr . David Alan Gilbert, Philippe Mathieu-Daudé, qemu-arm, Gerd Hoffmann, Cleber Rosa On Mon, Feb 03, 2020 at 12:21:53PM -0200, Wainer dos Santos Moschetta wrote: > > On 1/31/20 9:24 PM, Philippe Mathieu-Daudé wrote: > > 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 e40b84651b..4e69a83a12 100644 > > --- a/tests/acceptance/boot_linux_console.py > > +++ b/tests/acceptance/boot_linux_console.py > > @@ -12,6 +12,7 @@ import os > > import lzma > > import gzip > > import shutil > > +import logging > > from avocado import skipUnless > > from avocado_qemu import Test > > @@ -21,6 +22,19 @@ from avocado.utils import process > > 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 > > + > > + > > > Those Python packages are only needed by this new test case, and the test is > likely to be moved to a separate file soon. So I suggest to put those > availability checks inside the test method, so easing the future removal. > And use self.cancel() to cancel the test (if the case). > > > > class BootLinuxConsole(Test): > > """ > > Boots a Linux kernel and checks that the console is operational and the > > @@ -360,6 +374,54 @@ class BootLinuxConsole(Test): > > """ > > self.do_test_arm_raspi2(0) > > + @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 > > > Won't this fail if host cpu cores are less than 4? The number of cores in the host shouldn't matter. raspi2 has min_cpus = max_cpus = BCM283X_NCPUS = 4. -- Eduardo ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] tests/acceptance: Count Raspberry Pi logos displayed on framebuffer 2020-02-03 14:21 ` Wainer dos Santos Moschetta 2020-02-03 15:48 ` Eduardo Habkost @ 2020-02-03 16:08 ` Philippe Mathieu-Daudé 2020-02-04 16:57 ` Wainer dos Santos Moschetta 1 sibling, 1 reply; 6+ messages in thread From: Philippe Mathieu-Daudé @ 2020-02-03 16:08 UTC (permalink / raw) To: Wainer dos Santos Moschetta, Philippe Mathieu-Daudé, qemu-devel Cc: Cleber Rosa, qemu-arm, Gerd Hoffmann, Eduardo Habkost, Dr . David Alan Gilbert On 2/3/20 3:21 PM, Wainer dos Santos Moschetta wrote: > On 1/31/20 9:24 PM, Philippe Mathieu-Daudé wrote: >> 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 e40b84651b..4e69a83a12 100644 >> --- a/tests/acceptance/boot_linux_console.py >> +++ b/tests/acceptance/boot_linux_console.py >> @@ -12,6 +12,7 @@ import os >> import lzma >> import gzip >> import shutil >> +import logging >> from avocado import skipUnless >> from avocado_qemu import Test >> @@ -21,6 +22,19 @@ from avocado.utils import process >> 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 >> + >> + > > > Those Python packages are only needed by this new test case, and the > test is likely to be moved to a separate file soon. So I suggest to put > those availability checks inside the test method, so easing the future > removal. And use self.cancel() to cancel the test (if the case). Yes I'll move (actually the series is ready, I'll add this on top). > > >> class BootLinuxConsole(Test): >> """ >> Boots a Linux kernel and checks that the console is operational >> and the >> @@ -360,6 +374,54 @@ class BootLinuxConsole(Test): >> """ >> self.do_test_arm_raspi2(0) >> + @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 > > > Won't this fail if host cpu cores are less than 4? This count the TCG vCPU guest emulated by QEMU, and are not related to the host cores. I.E. you can run this test on a single-core powerpc host cpu, QEMU will instantiate 4 virtual cores for the raspberry pi. Also, the Raspberry Pi 2/3 machines are forced to 4 cores, because they only run a certain type of system-on-chip which has 4 cores built-in. >> + 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 > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] tests/acceptance: Count Raspberry Pi logos displayed on framebuffer 2020-02-03 16:08 ` Philippe Mathieu-Daudé @ 2020-02-04 16:57 ` Wainer dos Santos Moschetta 0 siblings, 0 replies; 6+ messages in thread From: Wainer dos Santos Moschetta @ 2020-02-04 16:57 UTC (permalink / raw) To: Philippe Mathieu-Daudé, Philippe Mathieu-Daudé, qemu-devel Cc: Cleber Rosa, qemu-arm, Gerd Hoffmann, Eduardo Habkost, Dr . David Alan Gilbert On 2/3/20 2:08 PM, Philippe Mathieu-Daudé wrote: > On 2/3/20 3:21 PM, Wainer dos Santos Moschetta wrote: >> On 1/31/20 9:24 PM, Philippe Mathieu-Daudé wrote: >>> 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 e40b84651b..4e69a83a12 100644 >>> --- a/tests/acceptance/boot_linux_console.py >>> +++ b/tests/acceptance/boot_linux_console.py >>> @@ -12,6 +12,7 @@ import os >>> import lzma >>> import gzip >>> import shutil >>> +import logging >>> from avocado import skipUnless >>> from avocado_qemu import Test >>> @@ -21,6 +22,19 @@ from avocado.utils import process >>> 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 >>> + >>> + >> >> >> Those Python packages are only needed by this new test case, and the >> test is likely to be moved to a separate file soon. So I suggest to >> put those availability checks inside the test method, so easing the >> future removal. And use self.cancel() to cancel the test (if the case). > > Yes I'll move (actually the series is ready, I'll add this on top). > >> >> >>> class BootLinuxConsole(Test): >>> """ >>> Boots a Linux kernel and checks that the console is >>> operational and the >>> @@ -360,6 +374,54 @@ class BootLinuxConsole(Test): >>> """ >>> self.do_test_arm_raspi2(0) >>> + @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 >> >> >> Won't this fail if host cpu cores are less than 4? > > This count the TCG vCPU guest emulated by QEMU, and are not related to > the host cores. > > I.E. you can run this test on a single-core powerpc host cpu, QEMU > will instantiate 4 virtual cores for the raspberry pi. > > Also, the Raspberry Pi 2/3 machines are forced to 4 cores, because > they only run a certain type of system-on-chip which has 4 cores > built-in. ah, ok, I learned something new today. Thanks! - Wainer > >>> + 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 >> >> > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-02-04 17:00 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-01-31 23:24 [PATCH 0/1] tests/acceptance: Count Raspberry Pi logos displayed on framebuffer Philippe Mathieu-Daudé 2020-01-31 23:24 ` [PATCH 1/1] " Philippe Mathieu-Daudé 2020-02-03 14:21 ` Wainer dos Santos Moschetta 2020-02-03 15:48 ` Eduardo Habkost 2020-02-03 16:08 ` Philippe Mathieu-Daudé 2020-02-04 16:57 ` Wainer dos Santos Moschetta
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).