Hi,

On 6/24/21 5:27 PM, Philippe Mathieu-Daudé wrote:
Test the PMON firmware. As the firmware is not redistributable,
it has to be downloaded manually first. Then it can be used by
providing its path via the PMON_BIN_PATH environment variable:
In the code it is used PMON2E_BIN_PATH.

   $ PMON2E_BIN_PATH=~/images/fuloong2e/pmon_2e.bin \
     AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
     avocado --show=app,console run tests/acceptance/machine_mips_fuloong2e.py
   Fetching asset from 
tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial
    (1/3) 
tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_serial_console:
   console: PMON2000 MIPS Initializing. Standby...
   console: ERRORPC=00000000 CONFIG=00030932
   console: PRID=00006302
   console: Init SDRAM Done!
   console: Sizing caches...
   console: Init caches...
   console: godson2 caches found
   console: Init caches done, cfg = 00030932
   console: Copy PMON to execute location...
   console: copy text section done.
   console: Copy PMON to execute location done.
   Uncompressing Bios........................OK,Booting Bios
   PASS (0.25 s)
    (2/3) 
tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_framebuffer_console:
   [...]
   Uncompressing Bios........................OK,Booting Bios
   console: FREQ
   console: FREI
   console: DONE
   console: TTYI
   console: TTYD
   console: ENVI
   console: MAPV
   console: Mfg  0, Id 60
   console: STDV
   console: SBDD
   console: PPCIH
   console: PCIS
   console: PCIR
   console: PCIW
   console: NETI
   console: RTCL
   console: PCID
   console: VGAI
   console: Default MODE_ID 2
   console: starting radeon init...
   console: radeon init done
   console: FRBI
   console: cfb_console init,fb=b4000000
   console: Video: Drawing the logo ...
   console: CONSOLE_SIZE 450560HSTI
   PASS (4.10 s)
    (3/3) 
tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial:
   console: Linux version 2.6.27.7lemote (root@debian) (gcc version 4.1.3 
20080623 (prerelease) (Debian 4.1.2-23)) #6 Fri Dec 12 00:11:25 CST 2008
   console: busclock=33000000, cpuclock=-2145008360,memsize=256,highmemsize=0
   console: console [early0] enabled
   console: CPU revision is: 00006302 (ICT Loongson-2)
   PASS (0.19 s)
   RESULTS    : PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | 
CANCEL 0
   JOB TIME   : 5.10 s

Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org>
---
  tests/acceptance/machine_mips_fuloong2e.py | 62 ++++++++++++++++++++++
  1 file changed, 62 insertions(+)

Need to fix the commit message (or the code) as pointed above. With that,

Reviewed-by: Wainer dos Santos Moschetta <waine...@redhat.com>


diff --git a/tests/acceptance/machine_mips_fuloong2e.py 
b/tests/acceptance/machine_mips_fuloong2e.py
index 0ac285e2af1..4854ba98560 100644
--- a/tests/acceptance/machine_mips_fuloong2e.py
+++ b/tests/acceptance/machine_mips_fuloong2e.py
@@ -8,15 +8,77 @@
  # SPDX-License-Identifier: GPL-2.0-or-later
import os
+import time
from avocado import skipUnless
  from avocado_qemu import Test
  from avocado_qemu import wait_for_console_pattern
+from tesseract_utils import tesseract_available, tesseract_ocr
+
  class MipsFuloong2e(Test):
timeout = 60 + @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_serial_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:via686b
+        """
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2
+        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path)
+        self.vm.launch()
+        wait_for_console_pattern(self, 'PMON2000 MIPS Initializing. 
Standby...')
+        wait_for_console_pattern(self, 'Booting Bios')
+
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    # Tesseract 4 adds a new OCR engine based on LSTM neural networks. The
+    # new version is faster and more accurate than version 3. The drawback is
+    # that it is still alpha-level software.
+    @skipUnless(tesseract_available(4), 'tesseract v4 OCR tool not available')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_framebuffer_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:ati-vga
+        """
+        screenshot_path = os.path.join(self.workdir, 'dump.ppm')
+
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2
+        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path,
+                         '-vga', 'std',
+                         '-device', 'ati-vga,model=rv100')
+        self.vm.launch()
+
+        wait_for_console_pattern(self, 'Video: Drawing the logo ...')
+        self.log.info('VM launched, waiting for logo on display')
+        time.sleep(2)
+        wait_for_console_pattern(self, 'CONSOLE_SIZE')
+        self.vm.command('human-monitor-command', command_line='stop')
+        self.vm.command('human-monitor-command',
+                        command_line='screendump %s' % screenshot_path)
+
+        lines = tesseract_ocr(screenshot_path, tesseract_version=4,
+                              tesseract_args='--dpi 128')
+        pmon_version = 'PNON2000 for Loongson, Version 1.1.2' # PNON is enough
+        self.assertIn(pmon_version, lines)
+
      @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
      @skipUnless(os.getenv('RESCUE_YL_PATH'), 'RESCUE_YL_PATH not available')
      def test_linux_kernel_isa_serial(self):


Reply via email to