Skip to contentSkip to conversation

tests/acceptance: Add tests for the Pegasos2 machine

PATCH In review Philippe Mathieu-Daudé 4 participants 10 messages May 15, 2021 – Jul 13, 2021

lore
Share & tools
lore
#0 lore raw

cover tests/acceptance: Add tests for the Pegasos2 machine

Philippe Mathieu-Daudé (2):
tests/acceptance: Ignore binary data sent on serial console tests/acceptance: Add tests for the Pegasos2 machine

 tests/acceptance/avocado_qemu/__init__.py |  7 +-
 tests/acceptance/machine_ppc_pegasos.py   | 98 +++++++++++++++++++++++
 2 files changed, 103 insertions(+), 2 deletions(-)
 create mode 100644 tests/acceptance/machine_ppc_pegasos.py
Signature · 1 line
2.26.3
#1 lore raw

PATCH 1/2 tests/acceptance: Ignore binary data sent on serial console

If a guest sends binary data on the serial console, we get:

File "tests/acceptance/avocado_qemu/__init__.py", line 92,
in _console_interaction msg = console.readline().strip()
File "/usr/lib64/python3.8/codecs.py", line 322,
in decode (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9 in position 2: invalid start byte

Since we use the console with readline(), fix it the easiest way possible: ignore binary data (all current tests compare text string anyway).

---
 tests/acceptance/avocado_qemu/__init__.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
tests/acceptance/avocado_qemu/__init__.py +5 -2
index 83b1741ec85..b55578e1cca 100644
@@ -82,14 +82,17 @@ def _console_interaction(test, success_message, failure_message,
     assert not keep_sending or send_string
     if vm is None:
         vm = test.vm
-    console = vm.console_socket.makefile()
+    console = vm.console_socket.makefile(mode='rb', encoding='utf-8')
     console_logger = logging.getLogger('console')
     while True:
         if send_string:
             vm.console_socket.sendall(send_string.encode())
             if not keep_sending:
                 send_string = None # send only once
-        msg = console.readline().strip()
+        try:
+            msg = console.readline().decode().strip()
+        except UnicodeDecodeError:
+            msg = None
         if not msg:
             continue
         console_logger.debug(msg)
Signature · 1 line
2.26.3
Reviewed-by Tested-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] tests/acceptance: Ignore binary data sent on serial console

Quoted 7 lines · Philippe Mathieu-Daudé

If a guest sends binary data on the serial console, we get:

File "tests/acceptance/avocado_qemu/__init__.py", line 92,
in _console_interaction msg = console.readline().strip()
File "/usr/lib64/python3.8/codecs.py", line 322,
in decode (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9 in position 2: invalid start byte

Good catch!

Quoted 9 lines

Since we use the console with readline(), fix it the easiest way possible: ignore binary data (all current tests compare text string anyway).

---
  tests/acceptance/avocado_qemu/__init__.py | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
Quoted 25 lines
tests/acceptance/avocado_qemu/__init__.py +5 -2
index 83b1741ec85..b55578e1cca 100644
@@ -82,14 +82,17 @@ def _console_interaction(test, success_message, failure_message,
      assert not keep_sending or send_string
      if vm is None:
          vm = test.vm
-    console = vm.console_socket.makefile()
+    console = vm.console_socket.makefile(mode='rb', encoding='utf-8')
      console_logger = logging.getLogger('console')
      while True:
          if send_string:
              vm.console_socket.sendall(send_string.encode())
              if not keep_sending:
                  send_string = None # send only once
-        msg = console.readline().strip()
+        try:
+            msg = console.readline().decode().strip()
+        except UnicodeDecodeError:
+            msg = None
          if not msg:
              continue
          console_logger.debug(msg)
#3 lore raw

PATCH 2/2 tests/acceptance: Add tests for the Pegasos2 machine

In reply to Philippe Mathieu-Daudé

Add a pair of tests for the Pegasos2 machine following the steps from:
https://lists.nongnu.org/archive/html/qemu-devel/2021-01/msg01553.html

  $ PEGASOS2_ROM_PATH=/tmp/pegasos2.rom AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
    avocado --show=app,console,tesseract \
      run -t machine:pegasos2 tests/acceptance/
   (1/2) tests/acceptance/machine_ppc_pegasos.py:PPCPegasos2.test_rom_serial_console:
  console: PegasosII Boot Strap (c) 2002-2003 bplan GmbH
  console: Running on CPU PVR:000C0209
  console: Enable L1 ICache...                                                    Done.
  console: Reading W83194 :                                                       FAILED.
  console: Setting Front Side Bus to 133MHz...                                    FAILED.
  console: Configuring DDR...                                                     Done.
  console: Configuring PCI0...                                                    Done.
  console: Configuring PCI1...                                                    Done.
  console: Configuring ETH...                                                     Done.
  console: Releasing IDE reset ...                                                Done.
  console: Configuring Legacy Devices
  console: Initializing KBD...                                                    Done.
  console: Testing 10000000 Bytes, Pass: 00000000 Failed: 00000000
  console: RAM TEST (fill linear)...                                              Done.
  console: FFFFFFFF
  console: SmartFirmware:
  console: cpu0: PowerPC,G4 CPUClock 599 Mhz BUSClock 133 Mhz (Version 0x000C,0x0209)
  console: no/bad nvramrc - performing default startup script
  console: channel 1 unit 0 : atapi | QEMU DVD-ROM                             | 2.5+
  console: ATA device not present or not responding
  console: Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1 (20040405172512)
  PASS (5.23 s)
   (2/2) tests/acceptance/machine_ppc_pegasos.py:PPCPegasos2.test_morphos_cdrom_vga:
  ...
  console: Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1 (20040405172512)
  console: SmartFirmware(tm) Copyright 1996-2001 by CodeGen, Inc.
  console: All Rights Reserved.
  console: Pegasos BIOS Extensions Copyright 2001-2003 by bplan GmbH.
  console: All Rights Reserved.
  console: entering main read/eval loop...
  console: ok boot cd boot.img
  console: ISO-9660 filesystem:  System-ID: "MORPHOS"  Volume-ID: "MorphOSBoot"
  console: " flags=0x2 extent=0x20 size=0x1800
  console: Memory used before SYS_Init: 9MB
  console: PCI ATA/ATAPI Driver@2: PIO Mode 4
  console: PCI ATA/ATAPI Driver@2: UDMA Mode 5
  console: ide.device@2: QEMU     QEMU DVD-ROM     <CDROM>
  console: ide.device@2:  CDRom <CD001>,<MORPHOS > found, bootable
  tesseract: Ambient Screen 4: Saturday, 15 May 2021, 13:36:06 &
  tesseract: keymap
  tesseract: Albanian keyboard with 101/104 keys
  tesseract: ‘American keyboard with Greek input extension, 105 keys
  tesseract: Belarusian keyboard with 105 keys
  tesseract: Belgian keyboard with 105 keys J
  tesseract: British Apple keyboard
  tesseract: British keyboard with 105 keys
  tesseract: Bulgarian keyboard with 104 keys
  tesseract: Canadian keyboard with 105 keys
  tesseract: Colemak layout for keyboards with 101/104 keys
  tesseract: Croatian keyboard with 101/108 keys
  tesseract: Czech keyboard (QWERTY) with 101/104 keys
  tesseract: Czech keyboard (QWERTZ) with 101/104 keys
  tesseract: Danish keyboard with 105 keys
  PASS (28.56 s)
  RESULTS    : PASS 2 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
  JOB TIME   : 34.42 s
---
 tests/acceptance/machine_ppc_pegasos.py | 98 +++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 tests/acceptance/machine_ppc_pegasos.py
tests/acceptance/machine_ppc_pegasos.py new file +98 -0
new file mode 100644
index 00000000000..d36e920ebde
@@ -0,0 +1,98 @@
+# Functional tests for the Pegasos2 machine.
+#
+# Copyright (c) 2021 Philippe Mathieu-Daudé <[email protected]>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or later.
+# See the COPYING file in the top-level directory.
+#
+# 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 exec_command_and_wait_for_pattern
+from avocado_qemu import wait_for_console_pattern
+from tesseract_utils import tesseract_available, tesseract_ocr
+
+PIL_AVAILABLE = True
+try:
+    from PIL import Image
+except ImportError:
+    PIL_AVAILABLE = False
+
+
+@skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+@skipUnless(os.getenv('PEGASOS2_ROM_PATH'), 'PEGASOS2_ROM_PATH not available')
+class PPCPegasos2(Test):
+    timeout = 60
+
+    def test_rom_serial_console(self):
+        """
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:pegasos2
+        :avocado: tags=device:mv64361
+        :avocado: tags=device:vt8231
+        """
+        rom_hash = '3248e02596480f2dba5944bd219ecfad'
+        rom_path = self.fetch_asset('file://' + os.getenv('PEGASOS2_ROM_PATH'),
+                                    asset_hash=rom_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', rom_path)
+        self.vm.launch()
+        msg = 'PegasosII Boot Strap (c) 2002-2003 bplan GmbH'
+        wait_for_console_pattern(self, msg)
+        msg = 'Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1'
+        wait_for_console_pattern(self, msg)
+
+    def test_morphos_cdrom_vga(self):
+        """
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:pegasos2
+        :avocado: tags=device:mv64361
+        :avocado: tags=device:vt8231
+        :avocado: tags=device:ati-vga
+        """
+        rom_hash = '3248e02596480f2dba5944bd219ecfad'
+        rom_path = self.fetch_asset('file://' + os.getenv('PEGASOS2_ROM_PATH'),
+                                    asset_hash=rom_hash, algorithm='md5')
+        iso_url = 'https://www.morphos-team.net/morphos-3.15.iso'
+        iso_hash = 'a19dbfbbc4728e0ba9ceb6335db69ca4'
+        iso_path = self.fetch_asset(iso_url,
+                                    asset_hash=iso_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', rom_path,
+                         '-device', 'ati-vga,romfile=',
+                         '-cdrom', iso_path)
+        self.vm.launch()
+        msg = 'Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1'
+        wait_for_console_pattern(self, msg)
+        wait_for_console_pattern(self, 'entering main read/eval loop...')
+        msg = 'filesystem:  System-ID: "MORPHOS"  Volume-ID: "MorphOSBoot"'
+        exec_command_and_wait_for_pattern(self, 'boot cd boot.img', msg)
+
+        msg = 'ide.device@2:  CDRom <CD001>,<MORPHOS > found, bootable'
+        wait_for_console_pattern(self, msg)
+        if PIL_AVAILABLE:
+            delay_s = 20 if tesseract_available(4) else 8
+
+            self.log.info('VM launched, waiting for display')
+            # TODO: Use avocado.utils.wait.wait_for to catch the
+            #       'displaysurface_create 1120x832' trace-event.
+            time.sleep(delay_s)
+
+            screenshot_path = os.path.join(self.workdir, "dump.ppm")
+            self.vm.command('human-monitor-command',
+                            command_line='screendump %s' % screenshot_path)
+            width, height = Image.open(screenshot_path).size
+            self.assertEqual(width, 2048)
+            self.assertEqual(height, 1152)
+
+            if tesseract_available(4):
+                lines = tesseract_ocr(screenshot_path, tesseract_version=4)
+                text = '\n'.join(lines)
+                msg = 'American keyboard with Greek input extension, 105 keys'
+                self.assertIn(msg, text)
Signature · 1 line
2.26.3
Acked-by on v1 2/2
#4 lore raw
Quoted 64 lines · Philippe Mathieu-Daudé

Add a pair of tests for the Pegasos2 machine following the steps from:
https://lists.nongnu.org/archive/html/qemu-devel/2021-01/msg01553.html

 $ PEGASOS2_ROM_PATH=/tmp/pegasos2.rom AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
   avocado --show=app,console,tesseract \
     run -t machine:pegasos2 tests/acceptance/
  (1/2) tests/acceptance/machine_ppc_pegasos.py:PPCPegasos2.test_rom_serial_console:
 console: PegasosII Boot Strap (c) 2002-2003 bplan GmbH
 console: Running on CPU PVR:000C0209
 console: Enable L1 ICache...                                                    Done.
 console: Reading W83194 :                                                       FAILED.
 console: Setting Front Side Bus to 133MHz...                                    FAILED.
 console: Configuring DDR...                                                     Done.
 console: Configuring PCI0...                                                    Done.
 console: Configuring PCI1...                                                    Done.
 console: Configuring ETH...                                                     Done.
 console: Releasing IDE reset ...                                                Done.
 console: Configuring Legacy Devices
 console: Initializing KBD...                                                    Done.
 console: Testing 10000000 Bytes, Pass: 00000000 Failed: 00000000
 console: RAM TEST (fill linear)...                                              Done.
 console: FFFFFFFF
 console: SmartFirmware:
 console: cpu0: PowerPC,G4 CPUClock 599 Mhz BUSClock 133 Mhz (Version 0x000C,0x0209)
 console: no/bad nvramrc - performing default startup script
 console: channel 1 unit 0 : atapi | QEMU DVD-ROM                             | 2.5+
 console: ATA device not present or not responding
 console: Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1 (20040405172512)
 PASS (5.23 s)
  (2/2) tests/acceptance/machine_ppc_pegasos.py:PPCPegasos2.test_morphos_cdrom_vga:
 ...
 console: Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1 (20040405172512)
 console: SmartFirmware(tm) Copyright 1996-2001 by CodeGen, Inc.
 console: All Rights Reserved.
 console: Pegasos BIOS Extensions Copyright 2001-2003 by bplan GmbH.
 console: All Rights Reserved.
 console: entering main read/eval loop...
 console: ok boot cd boot.img
 console: ISO-9660 filesystem:  System-ID: "MORPHOS"  Volume-ID: "MorphOSBoot"
 console: " flags=0x2 extent=0x20 size=0x1800
 console: Memory used before SYS_Init: 9MB
 console: PCI ATA/ATAPI Driver@2: PIO Mode 4
 console: PCI ATA/ATAPI Driver@2: UDMA Mode 5
 console: ide.device@2: QEMU     QEMU DVD-ROM     <CDROM>
 console: ide.device@2:  CDRom <CD001>,<MORPHOS > found, bootable
 tesseract: Ambient Screen 4: Saturday, 15 May 2021, 13:36:06 &
 tesseract: keymap
 tesseract: Albanian keyboard with 101/104 keys
 tesseract: ‘American keyboard with Greek input extension, 105 keys
 tesseract: Belarusian keyboard with 105 keys
 tesseract: Belgian keyboard with 105 keys J
 tesseract: British Apple keyboard
 tesseract: British keyboard with 105 keys
 tesseract: Bulgarian keyboard with 104 keys
 tesseract: Canadian keyboard with 105 keys
 tesseract: Colemak layout for keyboards with 101/104 keys
 tesseract: Croatian keyboard with 101/108 keys
 tesseract: Czech keyboard (QWERTY) with 101/104 keys
 tesseract: Czech keyboard (QWERTZ) with 101/104 keys
 tesseract: Danish keyboard with 105 keys
 PASS (28.56 s)
 RESULTS    : PASS 2 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
 JOB TIME   : 34.42 s
Quoted 1 line

Thanks a lot for creating this test.

Quoted 110 lines

---
tests/acceptance/machine_ppc_pegasos.py | 98 +++++++++++++++++++++++++

1 file changed, 98 insertions(+)

create mode 100644 tests/acceptance/machine_ppc_pegasos.py

tests/acceptance/machine_ppc_pegasos.py new file +98 -0
new file mode 100644
index 00000000000..d36e920ebde
@@ -0,0 +1,98 @@
+# Functional tests for the Pegasos2 machine.
+#
+# Copyright (c) 2021 Philippe Mathieu-Daudé <[email protected]>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or later.
+# See the COPYING file in the top-level directory.
+#
+# 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 exec_command_and_wait_for_pattern
+from avocado_qemu import wait_for_console_pattern
+from tesseract_utils import tesseract_available, tesseract_ocr
+
+PIL_AVAILABLE = True
+try:
+    from PIL import Image
+except ImportError:
+    PIL_AVAILABLE = False
+
+
+@skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+@skipUnless(os.getenv('PEGASOS2_ROM_PATH'), 'PEGASOS2_ROM_PATH not available')
+class PPCPegasos2(Test):
+    timeout = 60
+
+    def test_rom_serial_console(self):
+        """
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:pegasos2
+        :avocado: tags=device:mv64361
+        :avocado: tags=device:vt8231
+        """
+        rom_hash = '3248e02596480f2dba5944bd219ecfad'
+        rom_path = self.fetch_asset('file://' + os.getenv('PEGASOS2_ROM_PATH'),
+                                    asset_hash=rom_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', rom_path)
+        self.vm.launch()
+        msg = 'PegasosII Boot Strap (c) 2002-2003 bplan GmbH'
+        wait_for_console_pattern(self, msg)
+        msg = 'Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1'
+        wait_for_console_pattern(self, msg)
+
+    def test_morphos_cdrom_vga(self):
+        """
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:pegasos2
+        :avocado: tags=device:mv64361
+        :avocado: tags=device:vt8231
+        :avocado: tags=device:ati-vga
+        """
+        rom_hash = '3248e02596480f2dba5944bd219ecfad'
+        rom_path = self.fetch_asset('file://' + os.getenv('PEGASOS2_ROM_PATH'),
+                                    asset_hash=rom_hash, algorithm='md5')
+        iso_url = 'https://www.morphos-team.net/morphos-3.15.iso'
+        iso_hash = 'a19dbfbbc4728e0ba9ceb6335db69ca4'
+        iso_path = self.fetch_asset(iso_url,
+                                    asset_hash=iso_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', rom_path,
+                         '-device', 'ati-vga,romfile=',
+                         '-cdrom', iso_path)
+        self.vm.launch()
+        msg = 'Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1'
+        wait_for_console_pattern(self, msg)
+        wait_for_console_pattern(self, 'entering main read/eval loop...')
+        msg = 'filesystem:  System-ID: "MORPHOS"  Volume-ID: "MorphOSBoot"'
+        exec_command_and_wait_for_pattern(self, 'boot cd boot.img', msg)
+
+        msg = 'ide.device@2:  CDRom <CD001>,<MORPHOS > found, bootable'
+        wait_for_console_pattern(self, msg)
+        if PIL_AVAILABLE:
+            delay_s = 20 if tesseract_available(4) else 8
+
+            self.log.info('VM launched, waiting for display')
+            # TODO: Use avocado.utils.wait.wait_for to catch the
+            #       'displaysurface_create 1120x832' trace-event.
+            time.sleep(delay_s)
+
+            screenshot_path = os.path.join(self.workdir, "dump.ppm")
+            self.vm.command('human-monitor-command',
+                            command_line='screendump %s' % screenshot_path)
+            width, height = Image.open(screenshot_path).size
+            self.assertEqual(width, 2048)
+            self.assertEqual(height, 1152)
+
+            if tesseract_available(4):
+                lines = tesseract_ocr(screenshot_path, tesseract_version=4)
+                text = '\n'.join(lines)
+                msg = 'American keyboard with Greek input extension, 105 keys'
+                self.assertIn(msg, text)
#5 lore raw
In reply to Philippe Mathieu-Daudé

Hi,

Quoted 104 lines · Philippe Mathieu-Daudé

Add a pair of tests for the Pegasos2 machine following the steps from:
https://lists.nongnu.org/archive/html/qemu-devel/2021-01/msg01553.html

   $ PEGASOS2_ROM_PATH=/tmp/pegasos2.rom AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
     avocado --show=app,console,tesseract \
       run -t machine:pegasos2 tests/acceptance/
    (1/2) tests/acceptance/machine_ppc_pegasos.py:PPCPegasos2.test_rom_serial_console:
   console: PegasosII Boot Strap (c) 2002-2003 bplan GmbH
   console: Running on CPU PVR:000C0209
   console: Enable L1 ICache...                                                    Done.
   console: Reading W83194 :                                                       FAILED.
   console: Setting Front Side Bus to 133MHz...                                    FAILED.
   console: Configuring DDR...                                                     Done.
   console: Configuring PCI0...                                                    Done.
   console: Configuring PCI1...                                                    Done.
   console: Configuring ETH...                                                     Done.
   console: Releasing IDE reset ...                                                Done.
   console: Configuring Legacy Devices
   console: Initializing KBD...                                                    Done.
   console: Testing 10000000 Bytes, Pass: 00000000 Failed: 00000000
   console: RAM TEST (fill linear)...                                              Done.
   console: FFFFFFFF
   console: SmartFirmware:
   console: cpu0: PowerPC,G4 CPUClock 599 Mhz BUSClock 133 Mhz (Version 0x000C,0x0209)
   console: no/bad nvramrc - performing default startup script
   console: channel 1 unit 0 : atapi | QEMU DVD-ROM                             | 2.5+
   console: ATA device not present or not responding
   console: Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1 (20040405172512)
   PASS (5.23 s)
    (2/2) tests/acceptance/machine_ppc_pegasos.py:PPCPegasos2.test_morphos_cdrom_vga:
   ...
   console: Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1 (20040405172512)
   console: SmartFirmware(tm) Copyright 1996-2001 by CodeGen, Inc.
   console: All Rights Reserved.
   console: Pegasos BIOS Extensions Copyright 2001-2003 by bplan GmbH.
   console: All Rights Reserved.
   console: entering main read/eval loop...
   console: ok boot cd boot.img
   console: ISO-9660 filesystem:  System-ID: "MORPHOS"  Volume-ID: "MorphOSBoot"
   console: " flags=0x2 extent=0x20 size=0x1800
   console: Memory used before SYS_Init: 9MB
   console: PCI ATA/ATAPI Driver@2: PIO Mode 4
   console: PCI ATA/ATAPI Driver@2: UDMA Mode 5
   console: ide.device@2: QEMU     QEMU DVD-ROM     <CDROM>
   console: ide.device@2:  CDRom <CD001>,<MORPHOS > found, bootable
   tesseract: Ambient Screen 4: Saturday, 15 May 2021, 13:36:06 &
   tesseract: keymap
   tesseract: Albanian keyboard with 101/104 keys
   tesseract: ‘American keyboard with Greek input extension, 105 keys
   tesseract: Belarusian keyboard with 105 keys
   tesseract: Belgian keyboard with 105 keys J
   tesseract: British Apple keyboard
   tesseract: British keyboard with 105 keys
   tesseract: Bulgarian keyboard with 104 keys
   tesseract: Canadian keyboard with 105 keys
   tesseract: Colemak layout for keyboards with 101/104 keys
   tesseract: Croatian keyboard with 101/108 keys
   tesseract: Czech keyboard (QWERTY) with 101/104 keys
   tesseract: Czech keyboard (QWERTZ) with 101/104 keys
   tesseract: Danish keyboard with 105 keys
   PASS (28.56 s)
   RESULTS    : PASS 2 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
   JOB TIME   : 34.42 s
---
  tests/acceptance/machine_ppc_pegasos.py | 98 +++++++++++++++++++++++++
  1 file changed, 98 insertions(+)

create mode 100644 tests/acceptance/machine_ppc_pegasos.py

tests/acceptance/machine_ppc_pegasos.py new file +28 -0
new file mode 100644
index 00000000000..d36e920ebde
@@ -0,0 +1,98 @@
+# Functional tests for the Pegasos2 machine.
+#
+# Copyright (c) 2021 Philippe Mathieu-Daudé <[email protected]>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or later.
+# See the COPYING file in the top-level directory.
+#
+# 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 exec_command_and_wait_for_pattern
+from avocado_qemu import wait_for_console_pattern
+from tesseract_utils import tesseract_available, tesseract_ocr
+
+PIL_AVAILABLE = True
+try:
+    from PIL import Image
+except ImportError:
+    PIL_AVAILABLE = False
+
+
+@skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+@skipUnless(os.getenv('PEGASOS2_ROM_PATH'), 'PEGASOS2_ROM_PATH not available')
+class PPCPegasos2(Test):

tests/acceptance/machine_ppc_pegasos.py line 38

Quoted 10 lines
tests/acceptance/machine_ppc_pegasos.py new file +10 -0
+    timeout = 60
+
+    def test_rom_serial_console(self):
+        """
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:pegasos2
+        :avocado: tags=device:mv64361
+        :avocado: tags=device:vt8231
+        """
+        rom_hash = '3248e02596480f2dba5944bd219ecfad'

rom_hash the same on both test methods, so it can be an object attribute.

tests/acceptance/machine_ppc_pegasos.py line 40

Quoted 2 lines
tests/acceptance/machine_ppc_pegasos.py new file +2 -0
+        rom_path = self.fetch_asset('file://' + os.getenv('PEGASOS2_ROM_PATH'),
+                                    asset_hash=rom_hash, algorithm='md5')

The tester may have the ROM file hosted elsewhere, so I wouldn't prefix it with 'file://'.

Quoted 10 lines
tests/acceptance/machine_ppc_pegasos.py new file +10 -0
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', rom_path)
+        self.vm.launch()
+        msg = 'PegasosII Boot Strap (c) 2002-2003 bplan GmbH'
+        wait_for_console_pattern(self, msg)
+        msg = 'Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1'
+        wait_for_console_pattern(self, msg)
+
+    def test_morphos_cdrom_vga(self):

tests/acceptance/machine_ppc_pegasos.py line 60

Quoted 10 lines
tests/acceptance/machine_ppc_pegasos.py new file +10 -0
+        """
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:pegasos2
+        :avocado: tags=device:mv64361
+        :avocado: tags=device:vt8231
+        :avocado: tags=device:ati-vga
+        """
+        rom_hash = '3248e02596480f2dba5944bd219ecfad'
+        rom_path = self.fetch_asset('file://' + os.getenv('PEGASOS2_ROM_PATH'),
+                                    asset_hash=rom_hash, algorithm='md5')

Likewise.

- Wainer

Quoted 38 lines
tests/acceptance/machine_ppc_pegasos.py new file +38 -0
+        iso_url = 'https://www.morphos-team.net/morphos-3.15.iso'
+        iso_hash = 'a19dbfbbc4728e0ba9ceb6335db69ca4'
+        iso_path = self.fetch_asset(iso_url,
+                                    asset_hash=iso_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', rom_path,
+                         '-device', 'ati-vga,romfile=',
+                         '-cdrom', iso_path)
+        self.vm.launch()
+        msg = 'Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1'
+        wait_for_console_pattern(self, msg)
+        wait_for_console_pattern(self, 'entering main read/eval loop...')
+        msg = 'filesystem:  System-ID: "MORPHOS"  Volume-ID: "MorphOSBoot"'
+        exec_command_and_wait_for_pattern(self, 'boot cd boot.img', msg)
+
+        msg = 'ide.device@2:  CDRom <CD001>,<MORPHOS > found, bootable'
+        wait_for_console_pattern(self, msg)
+        if PIL_AVAILABLE:
+            delay_s = 20 if tesseract_available(4) else 8
+
+            self.log.info('VM launched, waiting for display')
+            # TODO: Use avocado.utils.wait.wait_for to catch the
+            #       'displaysurface_create 1120x832' trace-event.
+            time.sleep(delay_s)
+
+            screenshot_path = os.path.join(self.workdir, "dump.ppm")
+            self.vm.command('human-monitor-command',
+                            command_line='screendump %s' % screenshot_path)
+            width, height = Image.open(screenshot_path).size
+            self.assertEqual(width, 2048)
+            self.assertEqual(height, 1152)
+
+            if tesseract_available(4):
+                lines = tesseract_ocr(screenshot_path, tesseract_version=4)
+                text = '\n'.join(lines)
+                msg = 'American keyboard with Greek input extension, 105 keys'
+                self.assertIn(msg, text)
#6 lore raw
Quoted 111 lines · Wainer dos Santos Moschetta

Hi,

Quoted 108 lines · Philippe Mathieu-Daudé

Add a pair of tests for the Pegasos2 machine following the steps from:
https://lists.nongnu.org/archive/html/qemu-devel/2021-01/msg01553.html

   $ PEGASOS2_ROM_PATH=/tmp/pegasos2.rom AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
     avocado --show=app,console,tesseract \
       run -t machine:pegasos2 tests/acceptance/
    (1/2) tests/acceptance/machine_ppc_pegasos.py:PPCPegasos2.test_rom_serial_console:
   console: PegasosII Boot Strap (c) 2002-2003 bplan GmbH
   console: Running on CPU PVR:000C0209
   console: Enable L1 ICache...                                                    Done.
   console: Reading W83194 :                                                       FAILED.
   console: Setting Front Side Bus to 133MHz...                                    FAILED.
   console: Configuring DDR...                                                     Done.
   console: Configuring PCI0...                                                    Done.
   console: Configuring PCI1...                                                    Done.
   console: Configuring ETH...                                                     Done.
   console: Releasing IDE reset ...                                                Done.
   console: Configuring Legacy Devices
   console: Initializing KBD...                                                    Done.
   console: Testing 10000000 Bytes, Pass: 00000000 Failed: 00000000
   console: RAM TEST (fill linear)...                                              Done.
   console: FFFFFFFF
   console: SmartFirmware:
   console: cpu0: PowerPC,G4 CPUClock 599 Mhz BUSClock 133 Mhz (Version 0x000C,0x0209)
   console: no/bad nvramrc - performing default startup script
   console: channel 1 unit 0 : atapi | QEMU DVD-ROM                             | 2.5+
   console: ATA device not present or not responding
   console: Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1 (20040405172512)
   PASS (5.23 s)
    (2/2) tests/acceptance/machine_ppc_pegasos.py:PPCPegasos2.test_morphos_cdrom_vga:
   ...
   console: Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1 (20040405172512)
   console: SmartFirmware(tm) Copyright 1996-2001 by CodeGen, Inc.
   console: All Rights Reserved.
   console: Pegasos BIOS Extensions Copyright 2001-2003 by bplan GmbH.
   console: All Rights Reserved.
   console: entering main read/eval loop...
   console: ok boot cd boot.img
   console: ISO-9660 filesystem:  System-ID: "MORPHOS"  Volume-ID: "MorphOSBoot"
   console: " flags=0x2 extent=0x20 size=0x1800
   console: Memory used before SYS_Init: 9MB
   console: PCI ATA/ATAPI Driver@2: PIO Mode 4
   console: PCI ATA/ATAPI Driver@2: UDMA Mode 5
   console: ide.device@2: QEMU     QEMU DVD-ROM     <CDROM>
   console: ide.device@2:  CDRom <CD001>,<MORPHOS > found, bootable
   tesseract: Ambient Screen 4: Saturday, 15 May 2021, 13:36:06 &
   tesseract: keymap
   tesseract: Albanian keyboard with 101/104 keys
   tesseract: ‘American keyboard with Greek input extension, 105 keys
   tesseract: Belarusian keyboard with 105 keys
   tesseract: Belgian keyboard with 105 keys J
   tesseract: British Apple keyboard
   tesseract: British keyboard with 105 keys
   tesseract: Bulgarian keyboard with 104 keys
   tesseract: Canadian keyboard with 105 keys
   tesseract: Colemak layout for keyboards with 101/104 keys
   tesseract: Croatian keyboard with 101/108 keys
   tesseract: Czech keyboard (QWERTY) with 101/104 keys
   tesseract: Czech keyboard (QWERTZ) with 101/104 keys
   tesseract: Danish keyboard with 105 keys
   PASS (28.56 s)
   RESULTS    : PASS 2 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
   JOB TIME   : 34.42 s
---
  tests/acceptance/machine_ppc_pegasos.py | 98 +++++++++++++++++++++++++
  1 file changed, 98 insertions(+)

create mode 100644 tests/acceptance/machine_ppc_pegasos.py

tests/acceptance/machine_ppc_pegasos.py new file +32 -0
new file mode 100644
index 00000000000..d36e920ebde
@@ -0,0 +1,98 @@
+# Functional tests for the Pegasos2 machine.
+#
+# Copyright (c) 2021 Philippe Mathieu-Daudé <[email protected]>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or later.
+# See the COPYING file in the top-level directory.
+#
+# 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 exec_command_and_wait_for_pattern
+from avocado_qemu import wait_for_console_pattern
+from tesseract_utils import tesseract_available, tesseract_ocr
+
+PIL_AVAILABLE = True
+try:
+    from PIL import Image
+except ImportError:
+    PIL_AVAILABLE = False
+
+
+@skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+@skipUnless(os.getenv('PEGASOS2_ROM_PATH'), 'PEGASOS2_ROM_PATH not available')
+class PPCPegasos2(Test):
+    timeout = 60
+
+    def test_rom_serial_console(self):
+        """
Quoted 9 lines

tests/acceptance/machine_ppc_pegasos.py line 38

Quoted 6 lines
tests/acceptance/machine_ppc_pegasos.py new file +6 -0
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:pegasos2
+        :avocado: tags=device:mv64361
+        :avocado: tags=device:vt8231
+        """
+        rom_hash = '3248e02596480f2dba5944bd219ecfad'

rom_hash the same on both test methods, so it can be an object attribute.

Good point, agreed. One more suggestion, is to convert this to a sha1 instead, as it's the default fetch_asset() hash algorithm. The equivalent sha1 hash would be "08dc28afb3d10fb223376a28eebfd07c9f8df9fa".

Quoted 6 lines

tests/acceptance/machine_ppc_pegasos.py line 40

Quoted 2 lines
tests/acceptance/machine_ppc_pegasos.py new file +2 -0
+        rom_path = self.fetch_asset('file://' + os.getenv('PEGASOS2_ROM_PATH'),
+                                    asset_hash=rom_hash, algorithm='md5')

The tester may have the ROM file hosted elsewhere, so I wouldn't prefix it with 'file://'.

While I also agree with your suggestion, since Avocado 85.0, the best way to go about assets that are not publicly available is to reference it by name it and have registered locally with "avocado assets register".

According to [1], users would need to:

1. Download and ELF file that contains the ROM
2. Extract the rom with "tail -c +85581 up050404 | head -c 524288 >pegasos2.rom"

Then, I'd suggest we ask users to run:

3. avocado assets register --hash 08dc28afb3d10fb223376a28eebfd07c9f8df9fa pegasos2.rom file://pwd/pegasos2.rom

With that, we can now simply use:

rom_path = self.fetch_asset('pegasos2.rom', asset_hash=self.rom_hash)

Quoted 55 lines
Quoted 10 lines
tests/acceptance/machine_ppc_pegasos.py new file +10 -0
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', rom_path)
+        self.vm.launch()
+        msg = 'PegasosII Boot Strap (c) 2002-2003 bplan GmbH'
+        wait_for_console_pattern(self, msg)
+        msg = 'Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1'
+        wait_for_console_pattern(self, msg)
+
+    def test_morphos_cdrom_vga(self):

tests/acceptance/machine_ppc_pegasos.py line 60

Quoted 10 lines
tests/acceptance/machine_ppc_pegasos.py new file +10 -0
+        """
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:pegasos2
+        :avocado: tags=device:mv64361
+        :avocado: tags=device:vt8231
+        :avocado: tags=device:ati-vga
+        """
+        rom_hash = '3248e02596480f2dba5944bd219ecfad'
+        rom_path = self.fetch_asset('file://' + os.getenv('PEGASOS2_ROM_PATH'),
+                                    asset_hash=rom_hash, algorithm='md5')

Likewise.

- Wainer

Quoted 30 lines
tests/acceptance/machine_ppc_pegasos.py new file +30 -0
+        iso_url = 'https://www.morphos-team.net/morphos-3.15.iso'
+        iso_hash = 'a19dbfbbc4728e0ba9ceb6335db69ca4'
+        iso_path = self.fetch_asset(iso_url,
+                                    asset_hash=iso_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', rom_path,
+                         '-device', 'ati-vga,romfile=',
+                         '-cdrom', iso_path)
+        self.vm.launch()
+        msg = 'Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1'
+        wait_for_console_pattern(self, msg)
+        wait_for_console_pattern(self, 'entering main read/eval loop...')
+        msg = 'filesystem:  System-ID: "MORPHOS"  Volume-ID: "MorphOSBoot"'
+        exec_command_and_wait_for_pattern(self, 'boot cd boot.img', msg)
+
+        msg = 'ide.device@2:  CDRom <CD001>,<MORPHOS > found, bootable'
+        wait_for_console_pattern(self, msg)
+        if PIL_AVAILABLE:
+            delay_s = 20 if tesseract_available(4) else 8
+
+            self.log.info('VM launched, waiting for display')
+            # TODO: Use avocado.utils.wait.wait_for to catch the
+            #       'displaysurface_create 1120x832' trace-event.
+            time.sleep(delay_s)
+
+            screenshot_path = os.path.join(self.workdir, "dump.ppm")
+            self.vm.command('human-monitor-command',
+                            command_line='screendump %s' % screenshot_path)
+            width, height = Image.open(screenshot_path).size
Quoted 8 lines

tests/acceptance/machine_ppc_pegasos.py line 98

Quoted 8 lines
tests/acceptance/machine_ppc_pegasos.py new file +8 -0
+            self.assertEqual(width, 2048)
+            self.assertEqual(height, 1152)
+
+            if tesseract_available(4):
+                lines = tesseract_ocr(screenshot_path, tesseract_version=4)
+                text = '\n'.join(lines)
+                msg = 'American keyboard with Greek input extension, 105 keys'
+                self.assertIn(msg, text)

Phil,

If you don't mind, I'll send a respin of this test with Wainer's and my suggestions.

Cheers,
- Cleber.

[1] - https://lists.nongnu.org/archive/html/qemu-ppc/2021-01/msg00112.html
[2] - http://web.archive.org/web/20071021223056/http://www.bplan-gmbh.de/up050404/up050404

#7 lore raw
Quoted 123 lines · Cleber Rosa
Quoted 111 lines · Wainer dos Santos Moschetta

Hi,

Quoted 108 lines · Philippe Mathieu-Daudé

Add a pair of tests for the Pegasos2 machine following the steps from:
https://lists.nongnu.org/archive/html/qemu-devel/2021-01/msg01553.html

   $ PEGASOS2_ROM_PATH=/tmp/pegasos2.rom AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
     avocado --show=app,console,tesseract \
       run -t machine:pegasos2 tests/acceptance/
    (1/2) tests/acceptance/machine_ppc_pegasos.py:PPCPegasos2.test_rom_serial_console:
   console: PegasosII Boot Strap (c) 2002-2003 bplan GmbH
   console: Running on CPU PVR:000C0209
   console: Enable L1 ICache...                                                    Done.
   console: Reading W83194 :                                                       FAILED.
   console: Setting Front Side Bus to 133MHz...                                    FAILED.
   console: Configuring DDR...                                                     Done.
   console: Configuring PCI0...                                                    Done.
   console: Configuring PCI1...                                                    Done.
   console: Configuring ETH...                                                     Done.
   console: Releasing IDE reset ...                                                Done.
   console: Configuring Legacy Devices
   console: Initializing KBD...                                                    Done.
   console: Testing 10000000 Bytes, Pass: 00000000 Failed: 00000000
   console: RAM TEST (fill linear)...                                              Done.
   console: FFFFFFFF
   console: SmartFirmware:
   console: cpu0: PowerPC,G4 CPUClock 599 Mhz BUSClock 133 Mhz (Version 0x000C,0x0209)
   console: no/bad nvramrc - performing default startup script
   console: channel 1 unit 0 : atapi | QEMU DVD-ROM                             | 2.5+
   console: ATA device not present or not responding
   console: Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1 (20040405172512)
   PASS (5.23 s)
    (2/2) tests/acceptance/machine_ppc_pegasos.py:PPCPegasos2.test_morphos_cdrom_vga:
   ...
   console: Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1 (20040405172512)
   console: SmartFirmware(tm) Copyright 1996-2001 by CodeGen, Inc.
   console: All Rights Reserved.
   console: Pegasos BIOS Extensions Copyright 2001-2003 by bplan GmbH.
   console: All Rights Reserved.
   console: entering main read/eval loop...
   console: ok boot cd boot.img
   console: ISO-9660 filesystem:  System-ID: "MORPHOS"  Volume-ID: "MorphOSBoot"
   console: " flags=0x2 extent=0x20 size=0x1800
   console: Memory used before SYS_Init: 9MB
   console: PCI ATA/ATAPI Driver@2: PIO Mode 4
   console: PCI ATA/ATAPI Driver@2: UDMA Mode 5
   console: ide.device@2: QEMU     QEMU DVD-ROM     <CDROM>
   console: ide.device@2:  CDRom <CD001>,<MORPHOS > found, bootable
   tesseract: Ambient Screen 4: Saturday, 15 May 2021, 13:36:06 &
   tesseract: keymap
   tesseract: Albanian keyboard with 101/104 keys
   tesseract: ‘American keyboard with Greek input extension, 105 keys
   tesseract: Belarusian keyboard with 105 keys
   tesseract: Belgian keyboard with 105 keys J
   tesseract: British Apple keyboard
   tesseract: British keyboard with 105 keys
   tesseract: Bulgarian keyboard with 104 keys
   tesseract: Canadian keyboard with 105 keys
   tesseract: Colemak layout for keyboards with 101/104 keys
   tesseract: Croatian keyboard with 101/108 keys
   tesseract: Czech keyboard (QWERTY) with 101/104 keys
   tesseract: Czech keyboard (QWERTZ) with 101/104 keys
   tesseract: Danish keyboard with 105 keys
   PASS (28.56 s)
   RESULTS    : PASS 2 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
   JOB TIME   : 34.42 s
---
  tests/acceptance/machine_ppc_pegasos.py | 98 +++++++++++++++++++++++++
  1 file changed, 98 insertions(+)

create mode 100644 tests/acceptance/machine_ppc_pegasos.py

tests/acceptance/machine_ppc_pegasos.py new file +32 -0
new file mode 100644
index 00000000000..d36e920ebde
@@ -0,0 +1,98 @@
+# Functional tests for the Pegasos2 machine.
+#
+# Copyright (c) 2021 Philippe Mathieu-Daudé <[email protected]>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or later.
+# See the COPYING file in the top-level directory.
+#
+# 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 exec_command_and_wait_for_pattern
+from avocado_qemu import wait_for_console_pattern
+from tesseract_utils import tesseract_available, tesseract_ocr
+
+PIL_AVAILABLE = True
+try:
+    from PIL import Image
+except ImportError:
+    PIL_AVAILABLE = False
+
+
+@skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+@skipUnless(os.getenv('PEGASOS2_ROM_PATH'), 'PEGASOS2_ROM_PATH not available')
+class PPCPegasos2(Test):
+    timeout = 60
+
+    def test_rom_serial_console(self):
+        """
Quoted 9 lines

tests/acceptance/machine_ppc_pegasos.py line 38

Quoted 6 lines
tests/acceptance/machine_ppc_pegasos.py new file +6 -0
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:pegasos2
+        :avocado: tags=device:mv64361
+        :avocado: tags=device:vt8231
+        """
+        rom_hash = '3248e02596480f2dba5944bd219ecfad'

rom_hash the same on both test methods, so it can be an object attribute.

Quoted 3 lines

Good point, agreed. One more suggestion, is to convert this to a sha1 instead, as it's the default fetch_asset() hash algorithm. The equivalent sha1 hash would be "08dc28afb3d10fb223376a28eebfd07c9f8df9fa".

IIRC the agreement / recommendation was to use the hash provided with blob first, and if not present, add one using the default (which currently is sha1). I used MD5 because this is what was already available in [1], I haven't generated it. But ...

Quoted 7 lines
Quoted 6 lines

tests/acceptance/machine_ppc_pegasos.py line 40

Quoted 2 lines
tests/acceptance/machine_ppc_pegasos.py new file +2 -0
+        rom_path = self.fetch_asset('file://' + os.getenv('PEGASOS2_ROM_PATH'),
+                                    asset_hash=rom_hash, algorithm='md5')

The tester may have the ROM file hosted elsewhere, so I wouldn't prefix it with 'file://'.

Quoted 8 lines

While I also agree with your suggestion, since Avocado 85.0, the best way to go about assets that are not publicly available is to reference it by name it and have registered locally with "avocado assets register".

According to [1], users would need to:

1. Download and ELF file that contains the ROM
2. Extract the rom with "tail -c +85581 up050404 | head -c 524288 >pegasos2.rom"

... since Wainer suggested that, the up050404 file MD5 is public:
http://www.bplan-gmbh.de/flash_update_for_pegasos_ii_en.html
MD5 checksum:dea2d54d14726bb818e5fa3be9610fcc

So you can use that to verify 'up050404' then os.seek() to extract the rom, no need to verify the rom anymore.

Quoted 3 lines

Then, I'd suggest we ask users to run:

3. avocado assets register --hash 08dc28afb3d10fb223376a28eebfd07c9f8df9fa pegasos2.rom file://pwd/pegasos2.rom

And here we'd register 'up050404'.

Quoted 3 lines

With that, we can now simply use:

rom_path = self.fetch_asset('pegasos2.rom', asset_hash=self.rom_hash)

Wow, this is awesome!

Quoted 66 lines
Quoted 55 lines
Quoted 10 lines
tests/acceptance/machine_ppc_pegasos.py new file +10 -0
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', rom_path)
+        self.vm.launch()
+        msg = 'PegasosII Boot Strap (c) 2002-2003 bplan GmbH'
+        wait_for_console_pattern(self, msg)
+        msg = 'Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1'
+        wait_for_console_pattern(self, msg)
+
+    def test_morphos_cdrom_vga(self):

tests/acceptance/machine_ppc_pegasos.py line 60

Quoted 10 lines
tests/acceptance/machine_ppc_pegasos.py new file +10 -0
+        """
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:pegasos2
+        :avocado: tags=device:mv64361
+        :avocado: tags=device:vt8231
+        :avocado: tags=device:ati-vga
+        """
+        rom_hash = '3248e02596480f2dba5944bd219ecfad'
+        rom_path = self.fetch_asset('file://' + os.getenv('PEGASOS2_ROM_PATH'),
+                                    asset_hash=rom_hash, algorithm='md5')

Likewise.

- Wainer

Quoted 30 lines
tests/acceptance/machine_ppc_pegasos.py new file +30 -0
+        iso_url = 'https://www.morphos-team.net/morphos-3.15.iso'
+        iso_hash = 'a19dbfbbc4728e0ba9ceb6335db69ca4'
+        iso_path = self.fetch_asset(iso_url,
+                                    asset_hash=iso_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', rom_path,
+                         '-device', 'ati-vga,romfile=',
+                         '-cdrom', iso_path)
+        self.vm.launch()
+        msg = 'Welcome to SmartFirmware(tm) for bplan Pegasos2 version 1.1'
+        wait_for_console_pattern(self, msg)
+        wait_for_console_pattern(self, 'entering main read/eval loop...')
+        msg = 'filesystem:  System-ID: "MORPHOS"  Volume-ID: "MorphOSBoot"'
+        exec_command_and_wait_for_pattern(self, 'boot cd boot.img', msg)
+
+        msg = 'ide.device@2:  CDRom <CD001>,<MORPHOS > found, bootable'
+        wait_for_console_pattern(self, msg)
+        if PIL_AVAILABLE:
+            delay_s = 20 if tesseract_available(4) else 8
+
+            self.log.info('VM launched, waiting for display')
+            # TODO: Use avocado.utils.wait.wait_for to catch the
+            #       'displaysurface_create 1120x832' trace-event.
+            time.sleep(delay_s)
+
+            screenshot_path = os.path.join(self.workdir, "dump.ppm")
+            self.vm.command('human-monitor-command',
+                            command_line='screendump %s' % screenshot_path)
+            width, height = Image.open(screenshot_path).size
Quoted 8 lines

tests/acceptance/machine_ppc_pegasos.py line 98

Quoted 8 lines
tests/acceptance/machine_ppc_pegasos.py new file +8 -0
+            self.assertEqual(width, 2048)
+            self.assertEqual(height, 1152)
+
+            if tesseract_available(4):
+                lines = tesseract_ocr(screenshot_path, tesseract_version=4)
+                text = '\n'.join(lines)
+                msg = 'American keyboard with Greek input extension, 105 keys'
+                self.assertIn(msg, text)

Phil,

Quoted 2 lines

If you don't mind, I'll send a respin of this test with Wainer's and my suggestions.

Sure, thank you!

Quoted 7 lines

Cheers,
- Cleber.

[1] - https://lists.nongnu.org/archive/html/qemu-ppc/2021-01/msg00112.html
[2] - http://web.archive.org/web/20071021223056/http://www.bplan-gmbh.de/up050404/up050404

#8 lore raw
In reply to Philippe Mathieu-Daudé

ping?

Quoted 8 lines · Philippe Mathieu-Daudé

Philippe Mathieu-Daudé (2):
tests/acceptance: Ignore binary data sent on serial console tests/acceptance: Add tests for the Pegasos2 machine

 tests/acceptance/avocado_qemu/__init__.py |  7 +-
 tests/acceptance/machine_ppc_pegasos.py   | 98 +++++++++++++++++++++++
 2 files changed, 103 insertions(+), 2 deletions(-)
 create mode 100644 tests/acceptance/machine_ppc_pegasos.py
#9 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

Philippe Mathieu-Daudé (2):
tests/acceptance: Ignore binary data sent on serial console tests/acceptance: Add tests for the Pegasos2 machine

tests/acceptance/avocado_qemu/__init__.py | 7 +-
tests/acceptance/machine_ppc_pegasos.py | 98 +++++++++++++++++++++++

2 files changed, 103 insertions(+), 2 deletions(-)

create mode 100644 tests/acceptance/machine_ppc_pegasos.py

--
2.26.3

Now that pegasos2 is in master should these tests be added too? I can't test if these still apply or work correctly so just sending this as a reminder in case we want this to be part of the next release too but could also be added later if no time for it now.

Regards,
BALATON Zoltan