All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/9] tests/acceptance: Add tests for the PReP/40p machine
@ 2019-10-17 16:52 Philippe Mathieu-Daudé
  2019-10-17 16:52 ` [PATCH v3 1/9] Acceptance tests: refactor wait_for_console_pattern Philippe Mathieu-Daudé
                   ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-17 16:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo, PhilMD,
	Kamil Rytarowski, qemu-ppc, Artyom Tarasenko, Cleber Rosa,
	Hervé Poussineau, Alex Bennée, Aurelien Jarno,
	David Gibson

From: PhilMD <f4bug@amsat.org>

Quick tests worth to avoid regressions with the 40p machine.
idea from the "Maintainers, please tell us how to boot your machines"
thread:
https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg04177.html

v3: addressed review comment from v2
v2: Split Travis job, added Hervé R-b tag
v1: https://lists.gnu.org/archive/html/qemu-devel/2019-06/msg05896.html

Regards,

Phil.

Cleber Rosa (1):
  Acceptance tests: refactor wait_for_console_pattern

Philippe Mathieu-Daudé (8):
  tests/acceptance: Fixe wait_for_console_pattern() hangs
  tests/acceptance: Send <carriage return> on serial lines
  tests/acceptance: Refactor exec_command_and_wait_for_pattern()
  tests/acceptance: Add test that runs NetBSD 4.0 installer on PRep/40p
  tests/acceptance: Test Open Firmware on the PReP/40p
  tests/acceptance: Test OpenBIOS on the PReP/40p
  tests/acceptance: Test Sandalfoot initrd on the PReP/40p
  .travis.yml: Let the avocado job run the 40p tests

 .travis.yml                               |   2 +-
 MAINTAINERS                               |   1 +
 tests/acceptance/avocado_qemu/__init__.py |  46 ++++++++
 tests/acceptance/boot_linux_console.py    |  57 +++-------
 tests/acceptance/linux_ssh_mips_malta.py  |  18 +---
 tests/acceptance/ppc_prep_40p.py          | 126 ++++++++++++++++++++++
 6 files changed, 193 insertions(+), 57 deletions(-)
 create mode 100644 tests/acceptance/ppc_prep_40p.py

-- 
2.21.0



^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v3 1/9] Acceptance tests: refactor wait_for_console_pattern
  2019-10-17 16:52 [PATCH v3 0/9] tests/acceptance: Add tests for the PReP/40p machine Philippe Mathieu-Daudé
@ 2019-10-17 16:52 ` Philippe Mathieu-Daudé
  2019-10-20  6:36   ` David Gibson
  2019-10-17 16:52 ` [RFC PATCH v3 2/9] tests/acceptance: Fix wait_for_console_pattern() hangs Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-17 16:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo,
	Philippe Mathieu-Daudé,
	Kamil Rytarowski, qemu-ppc, Artyom Tarasenko, Cleber Rosa,
	Hervé Poussineau, Alex Bennée, Aurelien Jarno,
	David Gibson

From: Cleber Rosa <crosa@redhat.com>

The same utility method is already present in two different test
files, so let's consolidate it into a single utility function.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Message-Id: <20190916164011.7653-1-crosa@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
[PMD: rebased fixing conflicts in linux_ssh_mips_malta.py]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/acceptance/avocado_qemu/__init__.py | 26 +++++++++++++
 tests/acceptance/boot_linux_console.py    | 47 +++++++----------------
 tests/acceptance/linux_ssh_mips_malta.py  | 18 ++-------
 3 files changed, 42 insertions(+), 49 deletions(-)

diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index bd41e0443c..a0fe16e47f 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -8,6 +8,7 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or
 # later.  See the COPYING file in the top-level directory.
 
+import logging
 import os
 import sys
 import uuid
@@ -53,6 +54,31 @@ def pick_default_qemu_bin(arch=None):
         return qemu_bin_from_src_dir_path
 
 
+def wait_for_console_pattern(test, success_message,
+                             failure_message='Kernel panic - not syncing'):
+    """
+    Waits for messages to appear on the console, while logging the content
+
+    :param test: an Avocado test containing a VM that will have its console
+                 read and probed for a success or failure message
+    :type test: :class:`avocado_qemu.Test`
+    :param success_message: if this message appears, test succeeds
+    :param failure_message: if this message appears, test fails
+    """
+    console = test.vm.console_socket.makefile()
+    console_logger = logging.getLogger('console')
+    while True:
+        msg = console.readline().strip()
+        if not msg:
+            continue
+        console_logger.debug(msg)
+        if success_message in msg:
+            break
+        if failure_message in msg:
+            fail = 'Failure message found in console: %s' % failure_message
+            test.fail(fail)
+
+
 class Test(avocado.Test):
     def setUp(self):
         self._vms = {}
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index 8a9a314ab4..9ff2213874 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -9,12 +9,12 @@
 # later.  See the COPYING file in the top-level directory.
 
 import os
-import logging
 import lzma
 import gzip
 import shutil
 
 from avocado_qemu import Test
+from avocado_qemu import wait_for_console_pattern
 from avocado.utils import process
 from avocado.utils import archive
 
@@ -29,31 +29,10 @@ class BootLinuxConsole(Test):
 
     KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
 
-    def wait_for_console_pattern(self, success_message,
-                                 failure_message='Kernel panic - not syncing'):
-        """
-        Waits for messages to appear on the console, while logging the content
-
-        :param success_message: if this message appears, test succeeds
-        :param failure_message: if this message appears, test fails
-        """
-        console = self.vm.console_socket.makefile()
-        console_logger = logging.getLogger('console')
-        while True:
-            msg = console.readline().strip()
-            if not msg:
-                continue
-            console_logger.debug(msg)
-            if success_message in msg:
-                break
-            if failure_message in msg:
-                fail = 'Failure message found in console: %s' % failure_message
-                self.fail(fail)
-
     def exec_command_and_wait_for_pattern(self, command, success_message):
         command += '\n'
         self.vm.console_socket.sendall(command.encode())
-        self.wait_for_console_pattern(success_message)
+        wait_for_console_pattern(self, success_message)
 
     def extract_from_deb(self, deb, path):
         """
@@ -89,7 +68,7 @@ class BootLinuxConsole(Test):
                          '-append', kernel_command_line)
         self.vm.launch()
         console_pattern = 'Kernel command line: %s' % kernel_command_line
-        self.wait_for_console_pattern(console_pattern)
+        wait_for_console_pattern(self, console_pattern)
 
     def test_mips_malta(self):
         """
@@ -112,7 +91,7 @@ class BootLinuxConsole(Test):
                          '-append', kernel_command_line)
         self.vm.launch()
         console_pattern = 'Kernel command line: %s' % kernel_command_line
-        self.wait_for_console_pattern(console_pattern)
+        wait_for_console_pattern(self, console_pattern)
 
     def test_mips64el_malta(self):
         """
@@ -145,7 +124,7 @@ class BootLinuxConsole(Test):
                          '-append', kernel_command_line)
         self.vm.launch()
         console_pattern = 'Kernel command line: %s' % kernel_command_line
-        self.wait_for_console_pattern(console_pattern)
+        wait_for_console_pattern(self, console_pattern)
 
     def test_mips_malta_cpio(self):
         """
@@ -181,7 +160,7 @@ class BootLinuxConsole(Test):
                          '-append', kernel_command_line,
                          '-no-reboot')
         self.vm.launch()
-        self.wait_for_console_pattern('Boot successful.')
+        wait_for_console_pattern(self, 'Boot successful.')
 
         self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo',
                                                'BogoMIPS')
@@ -208,7 +187,7 @@ class BootLinuxConsole(Test):
                          '-append', kernel_command_line)
         self.vm.launch()
         console_pattern = 'Kernel command line: %s' % kernel_command_line
-        self.wait_for_console_pattern(console_pattern)
+        wait_for_console_pattern(self, console_pattern)
 
     def test_mips_malta32el_nanomips_4k(self):
         """
@@ -266,7 +245,7 @@ class BootLinuxConsole(Test):
                          '-append', kernel_command_line)
         self.vm.launch()
         console_pattern = 'Kernel command line: %s' % kernel_command_line
-        self.wait_for_console_pattern(console_pattern)
+        wait_for_console_pattern(self, console_pattern)
 
     def test_arm_virt(self):
         """
@@ -287,7 +266,7 @@ class BootLinuxConsole(Test):
                          '-append', kernel_command_line)
         self.vm.launch()
         console_pattern = 'Kernel command line: %s' % kernel_command_line
-        self.wait_for_console_pattern(console_pattern)
+        wait_for_console_pattern(self, console_pattern)
 
     def test_arm_emcraft_sf2(self):
         """
@@ -314,7 +293,7 @@ class BootLinuxConsole(Test):
                          '-drive', 'file=' + spi_path + ',if=mtd,format=raw',
                          '-no-reboot')
         self.vm.launch()
-        self.wait_for_console_pattern('init started: BusyBox')
+        wait_for_console_pattern(self, 'init started: BusyBox')
 
     def test_s390x_s390_ccw_virtio(self):
         """
@@ -335,7 +314,7 @@ class BootLinuxConsole(Test):
                          '-append', kernel_command_line)
         self.vm.launch()
         console_pattern = 'Kernel command line: %s' % kernel_command_line
-        self.wait_for_console_pattern(console_pattern)
+        wait_for_console_pattern(self, console_pattern)
 
     def test_alpha_clipper(self):
         """
@@ -357,7 +336,7 @@ class BootLinuxConsole(Test):
                          '-append', kernel_command_line)
         self.vm.launch()
         console_pattern = 'Kernel command line: %s' % kernel_command_line
-        self.wait_for_console_pattern(console_pattern)
+        wait_for_console_pattern(self, console_pattern)
 
     def test_ppc64_pseries(self):
         """
@@ -377,4 +356,4 @@ class BootLinuxConsole(Test):
                          '-append', kernel_command_line)
         self.vm.launch()
         console_pattern = 'Kernel command line: %s' % kernel_command_line
-        self.wait_for_console_pattern(console_pattern)
+        wait_for_console_pattern(self, console_pattern)
diff --git a/tests/acceptance/linux_ssh_mips_malta.py b/tests/acceptance/linux_ssh_mips_malta.py
index 25a1df5098..ffbb06f846 100644
--- a/tests/acceptance/linux_ssh_mips_malta.py
+++ b/tests/acceptance/linux_ssh_mips_malta.py
@@ -13,6 +13,7 @@ import time
 
 from avocado import skipUnless
 from avocado_qemu import Test
+from avocado_qemu import wait_for_console_pattern
 from avocado.utils import process
 from avocado.utils import archive
 from avocado.utils import ssh
@@ -40,19 +41,6 @@ class LinuxSSH(Test):
     def setUp(self):
         super(LinuxSSH, self).setUp()
 
-    def wait_for_console_pattern(self, success_message,
-                                 failure_message='Oops'):
-        console = self.vm.console_socket.makefile()
-        console_logger = logging.getLogger('console')
-        while True:
-            msg = console.readline()
-            console_logger.debug(msg.strip())
-            if success_message in msg:
-                break
-            if failure_message in msg:
-                fail = 'Failure message found in console: %s' % failure_message
-                self.fail(fail)
-
     def get_portfwd(self):
         res = self.vm.command('human-monitor-command',
                               command_line='info usernet')
@@ -109,7 +97,7 @@ class LinuxSSH(Test):
 
         self.log.info('VM launched, waiting for sshd')
         console_pattern = 'Starting OpenBSD Secure Shell server: sshd'
-        self.wait_for_console_pattern(console_pattern)
+        wait_for_console_pattern(self, console_pattern, 'Oops')
         self.log.info('sshd ready')
 
         self.ssh_connect('root', 'root')
@@ -117,7 +105,7 @@ class LinuxSSH(Test):
     def shutdown_via_ssh(self):
         self.ssh_command('poweroff')
         self.ssh_disconnect_vm()
-        self.wait_for_console_pattern('Power down')
+        wait_for_console_pattern(self, 'Power down', 'Oops')
 
     def ssh_command_output_contains(self, cmd, exp):
         stdout, _ = self.ssh_command(cmd)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH v3 2/9] tests/acceptance: Fix wait_for_console_pattern() hangs
  2019-10-17 16:52 [PATCH v3 0/9] tests/acceptance: Add tests for the PReP/40p machine Philippe Mathieu-Daudé
  2019-10-17 16:52 ` [PATCH v3 1/9] Acceptance tests: refactor wait_for_console_pattern Philippe Mathieu-Daudé
@ 2019-10-17 16:52 ` Philippe Mathieu-Daudé
  2019-10-17 16:52 ` [PATCH v3 3/9] tests/acceptance: Send <carriage return> on serial lines Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-17 16:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo,
	Philippe Mathieu-Daudé,
	Kamil Rytarowski, qemu-ppc, Artyom Tarasenko, Cleber Rosa,
	Hervé Poussineau, Alex Bennée, Aurelien Jarno,
	David Gibson

From: Philippe Mathieu-Daudé <philmd@redhat.com>

Because of a possible deadlock (QEMU waiting for the socket to
become writable) let's close the console socket as soon as we
stop to use it.

Suggested-by: Cleber Rosa <crosa@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/acceptance/avocado_qemu/__init__.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index a0fe16e47f..39f72945cd 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -75,6 +75,7 @@ def wait_for_console_pattern(test, success_message,
         if success_message in msg:
             break
         if failure_message in msg:
+            console.close()
             fail = 'Failure message found in console: %s' % failure_message
             test.fail(fail)
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v3 3/9] tests/acceptance: Send <carriage return> on serial lines
  2019-10-17 16:52 [PATCH v3 0/9] tests/acceptance: Add tests for the PReP/40p machine Philippe Mathieu-Daudé
  2019-10-17 16:52 ` [PATCH v3 1/9] Acceptance tests: refactor wait_for_console_pattern Philippe Mathieu-Daudé
  2019-10-17 16:52 ` [RFC PATCH v3 2/9] tests/acceptance: Fix wait_for_console_pattern() hangs Philippe Mathieu-Daudé
@ 2019-10-17 16:52 ` Philippe Mathieu-Daudé
  2019-10-20 10:09   ` David Gibson
  2019-10-17 16:52 ` [PATCH v3 4/9] tests/acceptance: Refactor exec_command_and_wait_for_pattern() Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-17 16:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo,
	Philippe Mathieu-Daudé,
	Kamil Rytarowski, qemu-ppc, Artyom Tarasenko, Cleber Rosa,
	Hervé Poussineau, Alex Bennée, Aurelien Jarno,
	David Gibson

Some firmwares don't parse the <Newline> control character and
expect a <carriage return>.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/acceptance/boot_linux_console.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index 9ff2213874..bf9861296a 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -30,7 +30,7 @@ class BootLinuxConsole(Test):
     KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
 
     def exec_command_and_wait_for_pattern(self, command, success_message):
-        command += '\n'
+        command += '\r\n'
         self.vm.console_socket.sendall(command.encode())
         wait_for_console_pattern(self, success_message)
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v3 4/9] tests/acceptance: Refactor exec_command_and_wait_for_pattern()
  2019-10-17 16:52 [PATCH v3 0/9] tests/acceptance: Add tests for the PReP/40p machine Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2019-10-17 16:52 ` [PATCH v3 3/9] tests/acceptance: Send <carriage return> on serial lines Philippe Mathieu-Daudé
@ 2019-10-17 16:52 ` Philippe Mathieu-Daudé
  2019-10-20 10:10   ` David Gibson
  2019-10-17 16:52 ` [PATCH v3 5/9] tests/acceptance: Add test that runs NetBSD 4.0 installer on PRep/40p Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-17 16:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo,
	Philippe Mathieu-Daudé,
	Kamil Rytarowski, qemu-ppc, Artyom Tarasenko, Cleber Rosa,
	Hervé Poussineau, Alex Bennée, Aurelien Jarno,
	David Gibson

From: Philippe Mathieu-Daudé <philmd@redhat.com>

The same utility method is already present in two different test
files, so let's consolidate it into a single utility function.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/acceptance/avocado_qemu/__init__.py | 19 +++++++++++++++++++
 tests/acceptance/boot_linux_console.py    | 12 ++++--------
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index 39f72945cd..4d7d6b640a 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -80,6 +80,25 @@ def wait_for_console_pattern(test, success_message,
             test.fail(fail)
 
 
+def exec_command_and_wait_for_pattern(test, command,
+                                      success_message, failure_message):
+    """
+    Send a command to a console (appending CRLF characters), then wait
+    for success_message to appear on the console, while logging the.
+    content. Mark the test as failed if failure_message is found instead.
+
+    :param test: an Avocado test containing a VM that will have its console
+                 read and probed for a success or failure message
+    :type test: :class:`avocado_qemu.Test`
+    :param command: the command to send
+    :param success_message: if this message appears, test succeeds
+    :param failure_message: if this message appears, test fails
+    """
+    command += '\r\n'
+    self.vm.console_socket.sendall(command.encode())
+    wait_for_console_pattern(self, success_message)
+
+
 class Test(avocado.Test):
     def setUp(self):
         self._vms = {}
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index bf9861296a..cc4d9be625 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -14,6 +14,7 @@ import gzip
 import shutil
 
 from avocado_qemu import Test
+from avocado_qemu import exec_command_and_wait_for_pattern
 from avocado_qemu import wait_for_console_pattern
 from avocado.utils import process
 from avocado.utils import archive
@@ -29,11 +30,6 @@ class BootLinuxConsole(Test):
 
     KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
 
-    def exec_command_and_wait_for_pattern(self, command, success_message):
-        command += '\r\n'
-        self.vm.console_socket.sendall(command.encode())
-        wait_for_console_pattern(self, success_message)
-
     def extract_from_deb(self, deb, path):
         """
         Extracts a file from a deb package into the test workdir
@@ -162,11 +158,11 @@ class BootLinuxConsole(Test):
         self.vm.launch()
         wait_for_console_pattern(self, 'Boot successful.')
 
-        self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo',
+        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
                                                'BogoMIPS')
-        self.exec_command_and_wait_for_pattern('uname -a',
+        exec_command_and_wait_for_pattern(self, 'uname -a',
                                                'Debian')
-        self.exec_command_and_wait_for_pattern('reboot',
+        exec_command_and_wait_for_pattern(self, 'reboot',
                                                'reboot: Restarting system')
 
     def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash):
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v3 5/9] tests/acceptance: Add test that runs NetBSD 4.0 installer on PRep/40p
  2019-10-17 16:52 [PATCH v3 0/9] tests/acceptance: Add tests for the PReP/40p machine Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2019-10-17 16:52 ` [PATCH v3 4/9] tests/acceptance: Refactor exec_command_and_wait_for_pattern() Philippe Mathieu-Daudé
@ 2019-10-17 16:52 ` Philippe Mathieu-Daudé
  2019-10-17 16:52 ` [PATCH v3 6/9] tests/acceptance: Test Open Firmware on the PReP/40p Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-17 16:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo,
	Philippe Mathieu-Daudé,
	Kamil Rytarowski, qemu-ppc, Artyom Tarasenko, Cleber Rosa,
	Hervé Poussineau, Alex Bennée, Aurelien Jarno,
	David Gibson

As of this commit, NetBSD 4.0 is very old. However it is enough to
test the PRep/40p machine.

User case from:
http://mail-index.netbsd.org/port-prep/2017/04/11/msg000112.html

Reviewed-by: Hervé Poussineau <hpoussin@reactos.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Artyom Tarasenko <atar4qemu@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
Installers after 4.0 doesn't work anymore, not sure if this is a
problem from the QEMU model or from NetBSD.

v3: use avocado_qemu.wait_for_console_pattern (Cleber)
---
 MAINTAINERS                      |  1 +
 tests/acceptance/ppc_prep_40p.py | 43 ++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 tests/acceptance/ppc_prep_40p.py

diff --git a/MAINTAINERS b/MAINTAINERS
index fe4dc51b08..83ec5cbf42 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1068,6 +1068,7 @@ F: hw/timer/m48t59-isa.c
 F: include/hw/isa/pc87312.h
 F: include/hw/timer/m48t59.h
 F: pc-bios/ppc_rom.bin
+F: tests/acceptance/machine_ppc_prep_40p.py
 
 sPAPR
 M: David Gibson <david@gibson.dropbear.id.au>
diff --git a/tests/acceptance/ppc_prep_40p.py b/tests/acceptance/ppc_prep_40p.py
new file mode 100644
index 0000000000..2978416b02
--- /dev/null
+++ b/tests/acceptance/ppc_prep_40p.py
@@ -0,0 +1,43 @@
+# Functional test that boots a PReP/40p machine and checks its serial console.
+#
+# Copyright (c) Philippe Mathieu-Daudé <f4bug@amsat.org>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later. See the COPYING file in the top-level directory.
+
+import os
+import logging
+
+from avocado import skipIf
+from avocado_qemu import Test
+from avocado_qemu import wait_for_console_pattern
+
+
+class IbmPrep40pMachine(Test):
+
+    timeout = 60
+
+    @skipIf(os.getenv('CONTINUOUS_INTEGRATION'), 'Running on Travis-CI')
+    def test_factory_firmware_and_netbsd(self):
+        """
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:40p
+        :avocado: tags=slowness:high
+        """
+        bios_url = ('ftp://ftp.boulder.ibm.com/rs6000/firmware/'
+                    '7020-40p/P12H0456.IMG')
+        bios_hash = '1775face4e6dc27f3a6ed955ef6eb331bf817f03'
+        bios_path = self.fetch_asset(bios_url, asset_hash=bios_hash)
+        drive_url = ('https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/'
+                     'NetBSD-4.0/prep/installation/floppy/generic_com0.fs')
+        drive_hash = 'dbcfc09912e71bd5f0d82c7c1ee43082fb596ceb'
+        drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash)
+
+        self.vm.set_machine('40p')
+        self.vm.set_console()
+        self.vm.add_args('-bios', bios_path,
+                         '-fda', drive_path)
+        self.vm.launch()
+        os_banner = 'NetBSD 4.0 (GENERIC) #0: Sun Dec 16 00:49:40 PST 2007'
+        wait_for_console_pattern(self, os_banner)
+        wait_for_console_pattern(self, 'Model: IBM PPS Model 6015')
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v3 6/9] tests/acceptance: Test Open Firmware on the PReP/40p
  2019-10-17 16:52 [PATCH v3 0/9] tests/acceptance: Add tests for the PReP/40p machine Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2019-10-17 16:52 ` [PATCH v3 5/9] tests/acceptance: Add test that runs NetBSD 4.0 installer on PRep/40p Philippe Mathieu-Daudé
@ 2019-10-17 16:52 ` Philippe Mathieu-Daudé
  2019-10-17 16:52 ` [PATCH v3 7/9] tests/acceptance: Test OpenBIOS " Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-17 16:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo,
	Philippe Mathieu-Daudé,
	Kamil Rytarowski, qemu-ppc, Artyom Tarasenko, Cleber Rosa,
	Hervé Poussineau, Alex Bennée, Aurelien Jarno,
	David Gibson

User case from:
https://tyom.blogspot.com/2019/04/aixprep-under-qemu-how-to.html

Acked-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Artyom Tarasenko <atar4qemu@gmail.com>
Tested-by: Cleber Rosa <crosa@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
v3: use avocado_qemu.wait_for_console_pattern (Cleber)
---
 tests/acceptance/ppc_prep_40p.py | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tests/acceptance/ppc_prep_40p.py b/tests/acceptance/ppc_prep_40p.py
index 2978416b02..7b8d0e55a9 100644
--- a/tests/acceptance/ppc_prep_40p.py
+++ b/tests/acceptance/ppc_prep_40p.py
@@ -41,3 +41,24 @@ class IbmPrep40pMachine(Test):
         os_banner = 'NetBSD 4.0 (GENERIC) #0: Sun Dec 16 00:49:40 PST 2007'
         wait_for_console_pattern(self, os_banner)
         wait_for_console_pattern(self, 'Model: IBM PPS Model 6015')
+
+    def test_openfirmware(self):
+        """
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:40p
+        """
+        bios_url = ('https://github.com/artyom-tarasenko/openfirmware/'
+                    'releases/download/40p-20190413/q40pofw-serial.rom')
+        bios_hash = '880c80172ea5b2247c0ac2a8bf36bbe385192c72'
+        bios_path = self.fetch_asset(bios_url, asset_hash=bios_hash)
+
+        self.vm.set_machine('40p')
+        self.vm.set_console()
+        self.vm.add_args('-bios', bios_path)
+
+        self.vm.launch()
+        wait_for_console_pattern(self, 'QEMU PReP/40p')
+        fw_banner = 'Open Firmware, built  April 13, 2019 09:29:23'
+        wait_for_console_pattern(self, fw_banner)
+        prompt_msg = 'Type any key to interrupt automatic startup'
+        wait_for_console_pattern(self, prompt_msg)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v3 7/9] tests/acceptance: Test OpenBIOS on the PReP/40p
  2019-10-17 16:52 [PATCH v3 0/9] tests/acceptance: Add tests for the PReP/40p machine Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2019-10-17 16:52 ` [PATCH v3 6/9] tests/acceptance: Test Open Firmware on the PReP/40p Philippe Mathieu-Daudé
@ 2019-10-17 16:52 ` Philippe Mathieu-Daudé
  2019-10-17 16:52 ` [PATCH v3 8/9] tests/acceptance: Test Sandalfoot initrd " Philippe Mathieu-Daudé
  2019-10-17 16:52 ` [PATCH v3 9/9] .travis.yml: Let the avocado job run the 40p tests Philippe Mathieu-Daudé
  8 siblings, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-17 16:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo,
	Philippe Mathieu-Daudé,
	Kamil Rytarowski, qemu-ppc, Artyom Tarasenko, Cleber Rosa,
	Hervé Poussineau, Alex Bennée, Aurelien Jarno,
	David Gibson

User case from:
https://mail.coreboot.org/pipermail/openbios/2018-May/010360.html

Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
v3:
- use avocado_qemu.wait_for_console_pattern (Cleber)
- use MD5 hash
---
 tests/acceptance/ppc_prep_40p.py | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/tests/acceptance/ppc_prep_40p.py b/tests/acceptance/ppc_prep_40p.py
index 7b8d0e55a9..0ebedd16c8 100644
--- a/tests/acceptance/ppc_prep_40p.py
+++ b/tests/acceptance/ppc_prep_40p.py
@@ -62,3 +62,35 @@ class IbmPrep40pMachine(Test):
         wait_for_console_pattern(self, fw_banner)
         prompt_msg = 'Type any key to interrupt automatic startup'
         wait_for_console_pattern(self, prompt_msg)
+
+    def test_openbios_192m(self):
+        """
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:40p
+        """
+        self.vm.set_machine('40p')
+        self.vm.set_console()
+        self.vm.add_args('-m', '192') # test fw_cfg
+
+        self.vm.launch()
+        wait_for_console_pattern(self, '>> OpenBIOS')
+        wait_for_console_pattern(self, '>> Memory: 192M')
+        wait_for_console_pattern(self, '>> CPU type PowerPC,604')
+
+    def test_openbios_and_netbsd(self):
+        """
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:40p
+        """
+        drive_url = ('https://ftp.netbsd.org/pub/NetBSD/iso/7.1.2/'
+                     'NetBSD-7.1.2-prep.iso')
+        drive_hash = 'ac6fa2707d888b36d6fa64de6e7fe48e'
+        drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash,
+                                      algorithm='md5')
+        self.vm.set_machine('40p')
+        self.vm.set_console()
+        self.vm.add_args('-cdrom', drive_path,
+                         '-boot', 'd')
+
+        self.vm.launch()
+        wait_for_console_pattern(self, 'NetBSD/prep BOOT, Revision 1.9')
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v3 8/9] tests/acceptance: Test Sandalfoot initrd on the PReP/40p
  2019-10-17 16:52 [PATCH v3 0/9] tests/acceptance: Add tests for the PReP/40p machine Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2019-10-17 16:52 ` [PATCH v3 7/9] tests/acceptance: Test OpenBIOS " Philippe Mathieu-Daudé
@ 2019-10-17 16:52 ` Philippe Mathieu-Daudé
  2019-10-17 16:52 ` [PATCH v3 9/9] .travis.yml: Let the avocado job run the 40p tests Philippe Mathieu-Daudé
  8 siblings, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-17 16:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo,
	Philippe Mathieu-Daudé,
	Kamil Rytarowski, qemu-ppc, Artyom Tarasenko, Cleber Rosa,
	Hervé Poussineau, Alex Bennée, Aurelien Jarno,
	David Gibson

User case from:
https://mail.coreboot.org/pipermail/openbios/2018-May/010360.html

Sandalfoot info:
http://www.juneau-lug.org/sandalfoot.php

Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
v3:
- use avocado_qemu.wait_for_console_pattern (Cleber)
- use exec_command_and_wait_for_pattern
---
 tests/acceptance/ppc_prep_40p.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tests/acceptance/ppc_prep_40p.py b/tests/acceptance/ppc_prep_40p.py
index 0ebedd16c8..d022fe5ab0 100644
--- a/tests/acceptance/ppc_prep_40p.py
+++ b/tests/acceptance/ppc_prep_40p.py
@@ -10,6 +10,7 @@ import logging
 
 from avocado import skipIf
 from avocado_qemu import Test
+from avocado_qemu import exec_command_and_wait_for_pattern
 from avocado_qemu import wait_for_console_pattern
 
 
@@ -94,3 +95,32 @@ class IbmPrep40pMachine(Test):
 
         self.vm.launch()
         wait_for_console_pattern(self, 'NetBSD/prep BOOT, Revision 1.9')
+
+    def test_sandalfoot_busybox(self):
+        """
+        :avocado: tags=arch:ppc
+        :avocado: tags=machine:40p
+        """
+        drive_url = ('http://www.juneau-lug.org/zImage.initrd.sandalfoot')
+        drive_hash = 'dacacfc4085ea51d34d99ef70e972b849e2c6949'
+        drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash)
+
+        self.vm.set_machine('40p')
+        self.vm.set_console()
+        self.vm.add_args('-cdrom', drive_path,
+                         '-boot', 'd')
+
+        self.vm.launch()
+        wait_for_console_pattern(self, 'Now booting the kernel')
+
+        msg = 'Please press Enter to activate this console.'
+        wait_for_console_pattern(self, msg)
+
+        version = 'BusyBox v0.60.0 (2001.08.19-09:26+0000) Built-in shell (ash)'
+        exec_command_and_wait_for_pattern(self, '', version)
+
+        uname = 'Linux ppc 2.4.18 #5 Wed May 21 23:50:43 AKDT 2003 ppc unknown'
+        exec_command_and_wait_for_pattern(self, 'uname -a', uname)
+
+        cpu = 'PReP IBM 6015/7020 (Sandalfoot/Sandalbow)'
+        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', cpu)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v3 9/9] .travis.yml: Let the avocado job run the 40p tests
  2019-10-17 16:52 [PATCH v3 0/9] tests/acceptance: Add tests for the PReP/40p machine Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2019-10-17 16:52 ` [PATCH v3 8/9] tests/acceptance: Test Sandalfoot initrd " Philippe Mathieu-Daudé
@ 2019-10-17 16:52 ` Philippe Mathieu-Daudé
  8 siblings, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-17 16:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Kamil Rytarowski, qemu-ppc, Artyom Tarasenko, Cleber Rosa,
	Hervé Poussineau, Alex Bennée, Aurelien Jarno,
	David Gibson

Acked-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index d0b9e099b9..69a37f7387 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -267,7 +267,7 @@ matrix:
 
     # Acceptance (Functional) tests
     - env:
-        - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,ppc64-softmmu,m68k-softmmu"
+        - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,ppc-softmmu,ppc64-softmmu,m68k-softmmu"
         - TEST_CMD="make check-acceptance"
       after_failure:
         - cat tests/results/latest/job.log
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 1/9] Acceptance tests: refactor wait_for_console_pattern
  2019-10-17 16:52 ` [PATCH v3 1/9] Acceptance tests: refactor wait_for_console_pattern Philippe Mathieu-Daudé
@ 2019-10-20  6:36   ` David Gibson
  0 siblings, 0 replies; 15+ messages in thread
From: David Gibson @ 2019-10-20  6:36 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo,
	Philippe Mathieu-Daudé,
	qemu-devel, Kamil Rytarowski, qemu-ppc, Artyom Tarasenko,
	Cleber Rosa, Hervé Poussineau, Alex Bennée,
	Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 11328 bytes --]

On Thu, Oct 17, 2019 at 06:52:31PM +0200, Philippe Mathieu-Daudé wrote:
> From: Cleber Rosa <crosa@redhat.com>
> 
> The same utility method is already present in two different test
> files, so let's consolidate it into a single utility function.
> 
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> Message-Id: <20190916164011.7653-1-crosa@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> [PMD: rebased fixing conflicts in linux_ssh_mips_malta.py]
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  tests/acceptance/avocado_qemu/__init__.py | 26 +++++++++++++
>  tests/acceptance/boot_linux_console.py    | 47 +++++++----------------
>  tests/acceptance/linux_ssh_mips_malta.py  | 18 ++-------
>  3 files changed, 42 insertions(+), 49 deletions(-)
> 
> diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
> index bd41e0443c..a0fe16e47f 100644
> --- a/tests/acceptance/avocado_qemu/__init__.py
> +++ b/tests/acceptance/avocado_qemu/__init__.py
> @@ -8,6 +8,7 @@
>  # This work is licensed under the terms of the GNU GPL, version 2 or
>  # later.  See the COPYING file in the top-level directory.
>  
> +import logging
>  import os
>  import sys
>  import uuid
> @@ -53,6 +54,31 @@ def pick_default_qemu_bin(arch=None):
>          return qemu_bin_from_src_dir_path
>  
>  
> +def wait_for_console_pattern(test, success_message,
> +                             failure_message='Kernel panic - not syncing'):
> +    """
> +    Waits for messages to appear on the console, while logging the content
> +
> +    :param test: an Avocado test containing a VM that will have its console
> +                 read and probed for a success or failure message
> +    :type test: :class:`avocado_qemu.Test`
> +    :param success_message: if this message appears, test succeeds
> +    :param failure_message: if this message appears, test fails
> +    """
> +    console = test.vm.console_socket.makefile()
> +    console_logger = logging.getLogger('console')
> +    while True:
> +        msg = console.readline().strip()
> +        if not msg:
> +            continue
> +        console_logger.debug(msg)
> +        if success_message in msg:
> +            break
> +        if failure_message in msg:
> +            fail = 'Failure message found in console: %s' % failure_message
> +            test.fail(fail)
> +
> +
>  class Test(avocado.Test):
>      def setUp(self):
>          self._vms = {}
> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
> index 8a9a314ab4..9ff2213874 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -9,12 +9,12 @@
>  # later.  See the COPYING file in the top-level directory.
>  
>  import os
> -import logging
>  import lzma
>  import gzip
>  import shutil
>  
>  from avocado_qemu import Test
> +from avocado_qemu import wait_for_console_pattern
>  from avocado.utils import process
>  from avocado.utils import archive
>  
> @@ -29,31 +29,10 @@ class BootLinuxConsole(Test):
>  
>      KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
>  
> -    def wait_for_console_pattern(self, success_message,
> -                                 failure_message='Kernel panic - not syncing'):
> -        """
> -        Waits for messages to appear on the console, while logging the content
> -
> -        :param success_message: if this message appears, test succeeds
> -        :param failure_message: if this message appears, test fails
> -        """
> -        console = self.vm.console_socket.makefile()
> -        console_logger = logging.getLogger('console')
> -        while True:
> -            msg = console.readline().strip()
> -            if not msg:
> -                continue
> -            console_logger.debug(msg)
> -            if success_message in msg:
> -                break
> -            if failure_message in msg:
> -                fail = 'Failure message found in console: %s' % failure_message
> -                self.fail(fail)
> -
>      def exec_command_and_wait_for_pattern(self, command, success_message):
>          command += '\n'
>          self.vm.console_socket.sendall(command.encode())
> -        self.wait_for_console_pattern(success_message)
> +        wait_for_console_pattern(self, success_message)
>  
>      def extract_from_deb(self, deb, path):
>          """
> @@ -89,7 +68,7 @@ class BootLinuxConsole(Test):
>                           '-append', kernel_command_line)
>          self.vm.launch()
>          console_pattern = 'Kernel command line: %s' % kernel_command_line
> -        self.wait_for_console_pattern(console_pattern)
> +        wait_for_console_pattern(self, console_pattern)
>  
>      def test_mips_malta(self):
>          """
> @@ -112,7 +91,7 @@ class BootLinuxConsole(Test):
>                           '-append', kernel_command_line)
>          self.vm.launch()
>          console_pattern = 'Kernel command line: %s' % kernel_command_line
> -        self.wait_for_console_pattern(console_pattern)
> +        wait_for_console_pattern(self, console_pattern)
>  
>      def test_mips64el_malta(self):
>          """
> @@ -145,7 +124,7 @@ class BootLinuxConsole(Test):
>                           '-append', kernel_command_line)
>          self.vm.launch()
>          console_pattern = 'Kernel command line: %s' % kernel_command_line
> -        self.wait_for_console_pattern(console_pattern)
> +        wait_for_console_pattern(self, console_pattern)
>  
>      def test_mips_malta_cpio(self):
>          """
> @@ -181,7 +160,7 @@ class BootLinuxConsole(Test):
>                           '-append', kernel_command_line,
>                           '-no-reboot')
>          self.vm.launch()
> -        self.wait_for_console_pattern('Boot successful.')
> +        wait_for_console_pattern(self, 'Boot successful.')
>  
>          self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo',
>                                                 'BogoMIPS')
> @@ -208,7 +187,7 @@ class BootLinuxConsole(Test):
>                           '-append', kernel_command_line)
>          self.vm.launch()
>          console_pattern = 'Kernel command line: %s' % kernel_command_line
> -        self.wait_for_console_pattern(console_pattern)
> +        wait_for_console_pattern(self, console_pattern)
>  
>      def test_mips_malta32el_nanomips_4k(self):
>          """
> @@ -266,7 +245,7 @@ class BootLinuxConsole(Test):
>                           '-append', kernel_command_line)
>          self.vm.launch()
>          console_pattern = 'Kernel command line: %s' % kernel_command_line
> -        self.wait_for_console_pattern(console_pattern)
> +        wait_for_console_pattern(self, console_pattern)
>  
>      def test_arm_virt(self):
>          """
> @@ -287,7 +266,7 @@ class BootLinuxConsole(Test):
>                           '-append', kernel_command_line)
>          self.vm.launch()
>          console_pattern = 'Kernel command line: %s' % kernel_command_line
> -        self.wait_for_console_pattern(console_pattern)
> +        wait_for_console_pattern(self, console_pattern)
>  
>      def test_arm_emcraft_sf2(self):
>          """
> @@ -314,7 +293,7 @@ class BootLinuxConsole(Test):
>                           '-drive', 'file=' + spi_path + ',if=mtd,format=raw',
>                           '-no-reboot')
>          self.vm.launch()
> -        self.wait_for_console_pattern('init started: BusyBox')
> +        wait_for_console_pattern(self, 'init started: BusyBox')
>  
>      def test_s390x_s390_ccw_virtio(self):
>          """
> @@ -335,7 +314,7 @@ class BootLinuxConsole(Test):
>                           '-append', kernel_command_line)
>          self.vm.launch()
>          console_pattern = 'Kernel command line: %s' % kernel_command_line
> -        self.wait_for_console_pattern(console_pattern)
> +        wait_for_console_pattern(self, console_pattern)
>  
>      def test_alpha_clipper(self):
>          """
> @@ -357,7 +336,7 @@ class BootLinuxConsole(Test):
>                           '-append', kernel_command_line)
>          self.vm.launch()
>          console_pattern = 'Kernel command line: %s' % kernel_command_line
> -        self.wait_for_console_pattern(console_pattern)
> +        wait_for_console_pattern(self, console_pattern)
>  
>      def test_ppc64_pseries(self):
>          """
> @@ -377,4 +356,4 @@ class BootLinuxConsole(Test):
>                           '-append', kernel_command_line)
>          self.vm.launch()
>          console_pattern = 'Kernel command line: %s' % kernel_command_line
> -        self.wait_for_console_pattern(console_pattern)
> +        wait_for_console_pattern(self, console_pattern)
> diff --git a/tests/acceptance/linux_ssh_mips_malta.py b/tests/acceptance/linux_ssh_mips_malta.py
> index 25a1df5098..ffbb06f846 100644
> --- a/tests/acceptance/linux_ssh_mips_malta.py
> +++ b/tests/acceptance/linux_ssh_mips_malta.py
> @@ -13,6 +13,7 @@ import time
>  
>  from avocado import skipUnless
>  from avocado_qemu import Test
> +from avocado_qemu import wait_for_console_pattern
>  from avocado.utils import process
>  from avocado.utils import archive
>  from avocado.utils import ssh
> @@ -40,19 +41,6 @@ class LinuxSSH(Test):
>      def setUp(self):
>          super(LinuxSSH, self).setUp()
>  
> -    def wait_for_console_pattern(self, success_message,
> -                                 failure_message='Oops'):
> -        console = self.vm.console_socket.makefile()
> -        console_logger = logging.getLogger('console')
> -        while True:
> -            msg = console.readline()
> -            console_logger.debug(msg.strip())
> -            if success_message in msg:
> -                break
> -            if failure_message in msg:
> -                fail = 'Failure message found in console: %s' % failure_message
> -                self.fail(fail)
> -
>      def get_portfwd(self):
>          res = self.vm.command('human-monitor-command',
>                                command_line='info usernet')
> @@ -109,7 +97,7 @@ class LinuxSSH(Test):
>  
>          self.log.info('VM launched, waiting for sshd')
>          console_pattern = 'Starting OpenBSD Secure Shell server: sshd'
> -        self.wait_for_console_pattern(console_pattern)
> +        wait_for_console_pattern(self, console_pattern, 'Oops')
>          self.log.info('sshd ready')
>  
>          self.ssh_connect('root', 'root')
> @@ -117,7 +105,7 @@ class LinuxSSH(Test):
>      def shutdown_via_ssh(self):
>          self.ssh_command('poweroff')
>          self.ssh_disconnect_vm()
> -        self.wait_for_console_pattern('Power down')
> +        wait_for_console_pattern(self, 'Power down', 'Oops')
>  
>      def ssh_command_output_contains(self, cmd, exp):
>          stdout, _ = self.ssh_command(cmd)

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 3/9] tests/acceptance: Send <carriage return> on serial lines
  2019-10-17 16:52 ` [PATCH v3 3/9] tests/acceptance: Send <carriage return> on serial lines Philippe Mathieu-Daudé
@ 2019-10-20 10:09   ` David Gibson
  2019-10-20 14:11     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 15+ messages in thread
From: David Gibson @ 2019-10-20 10:09 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo, qemu-devel,
	Kamil Rytarowski, qemu-ppc, Artyom Tarasenko, Cleber Rosa,
	Hervé Poussineau, Alex Bennée, Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 1470 bytes --]

On Thu, Oct 17, 2019 at 06:52:33PM +0200, Philippe Mathieu-Daudé wrote:
> Some firmwares don't parse the <Newline> control character and
> expect a <carriage return>.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/acceptance/boot_linux_console.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
> index 9ff2213874..bf9861296a 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -30,7 +30,7 @@ class BootLinuxConsole(Test):
>      KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
>  
>      def exec_command_and_wait_for_pattern(self, command, success_message):
> -        command += '\n'
> +        command += '\r\n'

I'm actually wondering if '\r' alone is really what we should be using
here.  Isn't that usually the character that actually pressing the
Enter key generates (on an old school tty)?  IIRC it's the thing on
the other side of the console that echoes back a \r and \n in order to
reposition the cursor on the next line.

>          self.vm.console_socket.sendall(command.encode())
>          wait_for_console_pattern(self, success_message)
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 4/9] tests/acceptance: Refactor exec_command_and_wait_for_pattern()
  2019-10-17 16:52 ` [PATCH v3 4/9] tests/acceptance: Refactor exec_command_and_wait_for_pattern() Philippe Mathieu-Daudé
@ 2019-10-20 10:10   ` David Gibson
  2019-10-23 15:54     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 15+ messages in thread
From: David Gibson @ 2019-10-20 10:10 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo,
	Philippe Mathieu-Daudé,
	qemu-devel, Kamil Rytarowski, qemu-ppc, Artyom Tarasenko,
	Cleber Rosa, Hervé Poussineau, Alex Bennée,
	Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 3975 bytes --]

On Thu, Oct 17, 2019 at 06:52:34PM +0200, Philippe Mathieu-Daudé wrote:
> From: Philippe Mathieu-Daudé <philmd@redhat.com>
> 
> The same utility method is already present in two different test
> files,

This patch only appears to remove it from one, though.

> so let's consolidate it into a single utility function.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  tests/acceptance/avocado_qemu/__init__.py | 19 +++++++++++++++++++
>  tests/acceptance/boot_linux_console.py    | 12 ++++--------
>  2 files changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
> index 39f72945cd..4d7d6b640a 100644
> --- a/tests/acceptance/avocado_qemu/__init__.py
> +++ b/tests/acceptance/avocado_qemu/__init__.py
> @@ -80,6 +80,25 @@ def wait_for_console_pattern(test, success_message,
>              test.fail(fail)
>  
>  
> +def exec_command_and_wait_for_pattern(test, command,
> +                                      success_message, failure_message):
> +    """
> +    Send a command to a console (appending CRLF characters), then wait
> +    for success_message to appear on the console, while logging the.
> +    content. Mark the test as failed if failure_message is found instead.
> +
> +    :param test: an Avocado test containing a VM that will have its console
> +                 read and probed for a success or failure message
> +    :type test: :class:`avocado_qemu.Test`
> +    :param command: the command to send
> +    :param success_message: if this message appears, test succeeds
> +    :param failure_message: if this message appears, test fails
> +    """
> +    command += '\r\n'
> +    self.vm.console_socket.sendall(command.encode())
> +    wait_for_console_pattern(self, success_message)
> +
> +
>  class Test(avocado.Test):
>      def setUp(self):
>          self._vms = {}
> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
> index bf9861296a..cc4d9be625 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -14,6 +14,7 @@ import gzip
>  import shutil
>  
>  from avocado_qemu import Test
> +from avocado_qemu import exec_command_and_wait_for_pattern
>  from avocado_qemu import wait_for_console_pattern
>  from avocado.utils import process
>  from avocado.utils import archive
> @@ -29,11 +30,6 @@ class BootLinuxConsole(Test):
>  
>      KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
>  
> -    def exec_command_and_wait_for_pattern(self, command, success_message):
> -        command += '\r\n'
> -        self.vm.console_socket.sendall(command.encode())
> -        wait_for_console_pattern(self, success_message)
> -
>      def extract_from_deb(self, deb, path):
>          """
>          Extracts a file from a deb package into the test workdir
> @@ -162,11 +158,11 @@ class BootLinuxConsole(Test):
>          self.vm.launch()
>          wait_for_console_pattern(self, 'Boot successful.')
>  
> -        self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo',
> +        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
>                                                 'BogoMIPS')
> -        self.exec_command_and_wait_for_pattern('uname -a',
> +        exec_command_and_wait_for_pattern(self, 'uname -a',
>                                                 'Debian')
> -        self.exec_command_and_wait_for_pattern('reboot',
> +        exec_command_and_wait_for_pattern(self, 'reboot',
>                                                 'reboot: Restarting system')
>  
>      def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash):

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 3/9] tests/acceptance: Send <carriage return> on serial lines
  2019-10-20 10:09   ` David Gibson
@ 2019-10-20 14:11     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-20 14:11 UTC (permalink / raw)
  To: David Gibson
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo, qemu-devel,
	Marc-André Lureau, Kamil Rytarowski, Paolo Bonzini,
	qemu-ppc, Artyom Tarasenko, Cleber Rosa, Hervé Poussineau,
	Alex Bennée, Samuel Thibault, Aurelien Jarno

Cc'ing Paolo/Samuel/Marc-André

On 10/20/19 12:09 PM, David Gibson wrote:
> On Thu, Oct 17, 2019 at 06:52:33PM +0200, Philippe Mathieu-Daudé wrote:
>> Some firmwares don't parse the <Newline> control character and
>> expect a <carriage return>.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>   tests/acceptance/boot_linux_console.py | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
>> index 9ff2213874..bf9861296a 100644
>> --- a/tests/acceptance/boot_linux_console.py
>> +++ b/tests/acceptance/boot_linux_console.py
>> @@ -30,7 +30,7 @@ class BootLinuxConsole(Test):
>>       KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
>>   
>>       def exec_command_and_wait_for_pattern(self, command, success_message):
>> -        command += '\n'
>> +        command += '\r\n'
> 
> I'm actually wondering if '\r' alone is really what we should be using
> here.  Isn't that usually the character that actually pressing the
> Enter key generates (on an old school tty)?  IIRC it's the thing on
> the other side of the console that echoes back a \r and \n in order to
> reposition the cursor on the next line.

Our current tests mostly target Linux/*BSD.
When I started testing U-boot/VxWorks images, I noticed the tests were 
stuck, why testing manually it was working, then this patch solved my issue.
I haven't checked the source but think the readline() implementation of 
these do strchr('\r') instead of strchr('\n') to match a newline?

So input sending Cartridge Return makes more sense here...

I tested with:

-- >8 --
      def exec_command_and_wait_for_pattern(self, command, success_message):
-        command += '\n'
+        command += '\r'
          self.vm.console_socket.sendall(command.encode())
          self.wait_for_console_pattern(success_message)
---

And everything works fine, so we don't need to send the New Line char :)

Thanks for helping me figure this out!
I'll wait if there are other comments then respin.

Regards,

Phil.

>>           self.vm.console_socket.sendall(command.encode())
>>           wait_for_console_pattern(self, success_message)
>>   
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 4/9] tests/acceptance: Refactor exec_command_and_wait_for_pattern()
  2019-10-20 10:10   ` David Gibson
@ 2019-10-23 15:54     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-23 15:54 UTC (permalink / raw)
  To: David Gibson, Philippe Mathieu-Daudé
  Cc: Fam Zheng, Eduardo Habkost, Aleksandar Rikalo, qemu-devel,
	Kamil Rytarowski, qemu-ppc, Artyom Tarasenko, Cleber Rosa,
	Hervé Poussineau, Alex Bennée, Aurelien Jarno

On 10/20/19 12:10 PM, David Gibson wrote:
> On Thu, Oct 17, 2019 at 06:52:34PM +0200, Philippe Mathieu-Daudé wrote:
>> From: Philippe Mathieu-Daudé <philmd@redhat.com>
>>
>> The same utility method is already present in two different test
>> files,
> 
> This patch only appears to remove it from one, though.
> 
>> so let's consolidate it into a single utility function.

Indeed, I reordered while rebasing and didn't notice the change,
thanks.

>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>   tests/acceptance/avocado_qemu/__init__.py | 19 +++++++++++++++++++
>>   tests/acceptance/boot_linux_console.py    | 12 ++++--------
>>   2 files changed, 23 insertions(+), 8 deletions(-)
>>
>> diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
>> index 39f72945cd..4d7d6b640a 100644
>> --- a/tests/acceptance/avocado_qemu/__init__.py
>> +++ b/tests/acceptance/avocado_qemu/__init__.py
>> @@ -80,6 +80,25 @@ def wait_for_console_pattern(test, success_message,
>>               test.fail(fail)
>>   
>>   
>> +def exec_command_and_wait_for_pattern(test, command,
>> +                                      success_message, failure_message):
>> +    """
>> +    Send a command to a console (appending CRLF characters), then wait
>> +    for success_message to appear on the console, while logging the.
>> +    content. Mark the test as failed if failure_message is found instead.
>> +
>> +    :param test: an Avocado test containing a VM that will have its console
>> +                 read and probed for a success or failure message
>> +    :type test: :class:`avocado_qemu.Test`
>> +    :param command: the command to send
>> +    :param success_message: if this message appears, test succeeds
>> +    :param failure_message: if this message appears, test fails
>> +    """
>> +    command += '\r\n'
>> +    self.vm.console_socket.sendall(command.encode())
>> +    wait_for_console_pattern(self, success_message)
>> +
>> +
>>   class Test(avocado.Test):
>>       def setUp(self):
>>           self._vms = {}
>> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
>> index bf9861296a..cc4d9be625 100644
>> --- a/tests/acceptance/boot_linux_console.py
>> +++ b/tests/acceptance/boot_linux_console.py
>> @@ -14,6 +14,7 @@ import gzip
>>   import shutil
>>   
>>   from avocado_qemu import Test
>> +from avocado_qemu import exec_command_and_wait_for_pattern
>>   from avocado_qemu import wait_for_console_pattern
>>   from avocado.utils import process
>>   from avocado.utils import archive
>> @@ -29,11 +30,6 @@ class BootLinuxConsole(Test):
>>   
>>       KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
>>   
>> -    def exec_command_and_wait_for_pattern(self, command, success_message):
>> -        command += '\r\n'
>> -        self.vm.console_socket.sendall(command.encode())
>> -        wait_for_console_pattern(self, success_message)
>> -
>>       def extract_from_deb(self, deb, path):
>>           """
>>           Extracts a file from a deb package into the test workdir
>> @@ -162,11 +158,11 @@ class BootLinuxConsole(Test):
>>           self.vm.launch()
>>           wait_for_console_pattern(self, 'Boot successful.')
>>   
>> -        self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo',
>> +        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
>>                                                  'BogoMIPS')
>> -        self.exec_command_and_wait_for_pattern('uname -a',
>> +        exec_command_and_wait_for_pattern(self, 'uname -a',
>>                                                  'Debian')
>> -        self.exec_command_and_wait_for_pattern('reboot',
>> +        exec_command_and_wait_for_pattern(self, 'reboot',
>>                                                  'reboot: Restarting system')
>>   
>>       def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash):
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-10-23 16:24 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-17 16:52 [PATCH v3 0/9] tests/acceptance: Add tests for the PReP/40p machine Philippe Mathieu-Daudé
2019-10-17 16:52 ` [PATCH v3 1/9] Acceptance tests: refactor wait_for_console_pattern Philippe Mathieu-Daudé
2019-10-20  6:36   ` David Gibson
2019-10-17 16:52 ` [RFC PATCH v3 2/9] tests/acceptance: Fix wait_for_console_pattern() hangs Philippe Mathieu-Daudé
2019-10-17 16:52 ` [PATCH v3 3/9] tests/acceptance: Send <carriage return> on serial lines Philippe Mathieu-Daudé
2019-10-20 10:09   ` David Gibson
2019-10-20 14:11     ` Philippe Mathieu-Daudé
2019-10-17 16:52 ` [PATCH v3 4/9] tests/acceptance: Refactor exec_command_and_wait_for_pattern() Philippe Mathieu-Daudé
2019-10-20 10:10   ` David Gibson
2019-10-23 15:54     ` Philippe Mathieu-Daudé
2019-10-17 16:52 ` [PATCH v3 5/9] tests/acceptance: Add test that runs NetBSD 4.0 installer on PRep/40p Philippe Mathieu-Daudé
2019-10-17 16:52 ` [PATCH v3 6/9] tests/acceptance: Test Open Firmware on the PReP/40p Philippe Mathieu-Daudé
2019-10-17 16:52 ` [PATCH v3 7/9] tests/acceptance: Test OpenBIOS " Philippe Mathieu-Daudé
2019-10-17 16:52 ` [PATCH v3 8/9] tests/acceptance: Test Sandalfoot initrd " Philippe Mathieu-Daudé
2019-10-17 16:52 ` [PATCH v3 9/9] .travis.yml: Let the avocado job run the 40p tests Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.