tests/acceptance: Add tests for the PReP/40p machine
v3 cover tests/acceptance: Add tests for the PReP/40p machine
From: PhilMD <[email protected]>
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
Signature · 1 line
2.21.0
PATCH v3 1/9 Acceptance tests: refactor wait_for_console_pattern
From: Cleber Rosa <[email protected]>
The same utility method is already present in two different test files, so let's consolidate it into a single utility function.
Message-Id: <[email protected]>
--- 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(-)
tests/acceptance/avocado_qemu/__init__.py +26 -0
@@ -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 = {}
tests/acceptance/boot_linux_console.py +13 -34
130 lines not on this page · raw message
tests/acceptance/linux_ssh_mips_malta.py +3 -15
@@ -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)
Signature · 1 line
2.21.0
Re: [PATCH v3 1/9] Acceptance tests: refactor wait_for_console_pattern
Quoted 10 lines · Philippe Mathieu-Daudé
From: Cleber Rosa <[email protected]>
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 <[email protected]>Message-Id: <[email protected]>
Reviewed-by Philippe Mathieu-Daudé <[email protected]>[PMD: rebased fixing conflicts in linux_ssh_mips_malta.py]Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 247 lines
--- 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(-)tests/acceptance/avocado_qemu/__init__.py +26
-0@@ -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 = {}tests/acceptance/boot_linux_console.py +13
-34@@ -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)tests/acceptance/linux_ssh_mips_malta.py +3
-15@@ -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)
Signature · 4 lines
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
RFC PATCH v3 2/9 tests/acceptance: Fix wait_for_console_pattern() hangs
In reply to Philippe Mathieu-DaudéFrom: Philippe Mathieu-Daudé <[email protected]>
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.
--- tests/acceptance/avocado_qemu/__init__.py | 1 + 1 file changed, 1 insertion(+)
tests/acceptance/avocado_qemu/__init__.py +1 -0
@@ -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)
Signature · 1 line
2.21.0
PATCH v3 3/9 tests/acceptance: Send <carriage return> on serial lines
In reply to Philippe Mathieu-DaudéSome firmwares don't parse the <Newline> control character and expect a <carriage return>.
--- tests/acceptance/boot_linux_console.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/acceptance/boot_linux_console.py +1 -1
@@ -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)
Signature · 1 line
2.21.0
Re: [PATCH v3 3/9] tests/acceptance: Send <carriage return> on serial lines
Quoted 13 lines · Philippe Mathieu-Daudé
Some firmwares don't parse the <Newline> control character and expect a <carriage return>.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/boot_linux_console.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/acceptance/boot_linux_console.py +0
-0
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 33
Quoted 5 lines
tests/acceptance/boot_linux_console.py +1
-1@@ -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.
Quoted 3 lines
tests/acceptance/boot_linux_console.py +0
-0self.vm.console_socket.sendall(command.encode()) wait_for_console_pattern(self, success_message)
Signature · 4 lines
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
Re: [PATCH v3 3/9] tests/acceptance: Send <carriage return> on serial lines
Cc'ing Paolo/Samuel/Marc-André
Quoted 16 lines · David Gibson
Quoted 15 lines · Philippe Mathieu-Daudé
Some firmwares don't parse the <Newline> control character and expect a <carriage return>.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/boot_linux_console.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/acceptance/boot_linux_console.py +0
-0@@ -30,7 +30,7 @@ class BootLinuxConsole(Test): KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
Quoted 9 lines
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 33
Quoted 3 lines
tests/acceptance/boot_linux_console.py +1
-1def 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.
Quoted 4 lines
Quoted 3 lines
tests/acceptance/boot_linux_console.py +0
-0self.vm.console_socket.sendall(command.encode()) wait_for_console_pattern(self, success_message)
PATCH v3 4/9 tests/acceptance: Refactor exec_command_and_wait_for_pattern()
In reply to Philippe Mathieu-DaudéFrom: Philippe Mathieu-Daudé <[email protected]>
The same utility method is already present in two different test files, so let's consolidate it into a single utility function.
--- tests/acceptance/avocado_qemu/__init__.py | 19 +++++++++++++++++++ tests/acceptance/boot_linux_console.py | 12 ++++-------- 2 files changed, 23 insertions(+), 8 deletions(-)
tests/acceptance/avocado_qemu/__init__.py +19 -0
@@ -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 = {}
tests/acceptance/boot_linux_console.py +4 -8
@@ -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):
Signature · 1 line
2.21.0
Re: [PATCH v3 4/9] tests/acceptance: Refactor exec_command_and_wait_for_pattern()
Quoted 4 lines · Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé <[email protected]>
The same utility method is already present in two different test files,
This patch only appears to remove it from one, though.
Quoted 77 lines
so let's consolidate it into a single utility function.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/avocado_qemu/__init__.py | 19 +++++++++++++++++++ tests/acceptance/boot_linux_console.py | 12 ++++-------- 2 files changed, 23 insertions(+), 8 deletions(-)tests/acceptance/avocado_qemu/__init__.py +19
-0@@ -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 = {}tests/acceptance/boot_linux_console.py +4
-8@@ -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):
Signature · 4 lines
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
Re: [PATCH v3 4/9] tests/acceptance: Refactor exec_command_and_wait_for_pattern()
Quoted 9 lines · David Gibson
Quoted 4 lines · Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé <[email protected]>
The same utility method is already present in two different test files,
This patch only appears to remove it from one, though.
Quoted 1 line
so let's consolidate it into a single utility function.
Indeed, I reordered while rebasing and didn't notice the change, thanks.
Quoted 77 lines
Quoted 76 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/avocado_qemu/__init__.py | 19 +++++++++++++++++++ tests/acceptance/boot_linux_console.py | 12 ++++-------- 2 files changed, 23 insertions(+), 8 deletions(-)tests/acceptance/avocado_qemu/__init__.py +19
-0@@ -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 = {}tests/acceptance/boot_linux_console.py +4
-8@@ -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):
PATCH v3 5/9 tests/acceptance: Add test that runs NetBSD 4.0 installer on PRep/40p
In reply to Philippe Mathieu-Daudé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
---
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
MAINTAINERS +1 -0
@@ -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 <[email protected]>
tests/acceptance/ppc_prep_40p.py new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v3 6/9 tests/acceptance: Test Open Firmware on the PReP/40p
In reply to Philippe Mathieu-DaudéUser case from:
https://tyom.blogspot.com/2019/04/aixprep-under-qemu-how-to.html
---
v3: use avocado_qemu.wait_for_console_pattern (Cleber)
--- tests/acceptance/ppc_prep_40p.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
tests/acceptance/ppc_prep_40p.py +21 -0
@@ -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)
Signature · 1 line
2.21.0
PATCH v3 7/9 tests/acceptance: Test OpenBIOS on the PReP/40p
In reply to Philippe Mathieu-DaudéUser case from:
https://mail.coreboot.org/pipermail/openbios/2018-May/010360.html
---
v3:
- use avocado_qemu.wait_for_console_pattern (Cleber)
- use MD5 hash
--- tests/acceptance/ppc_prep_40p.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
tests/acceptance/ppc_prep_40p.py +32 -0
@@ -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')
Signature · 1 line
2.21.0
PATCH v3 8/9 tests/acceptance: Test Sandalfoot initrd on the PReP/40p
In reply to Philippe Mathieu-DaudéUser case from:
https://mail.coreboot.org/pipermail/openbios/2018-May/010360.html
Sandalfoot info:
http://www.juneau-lug.org/sandalfoot.php
---
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(+)
tests/acceptance/ppc_prep_40p.py +30 -0
@@ -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)
Signature · 1 line
2.21.0
PATCH v3 9/9 .travis.yml: Let the avocado job run the 40p tests
In reply to Philippe Mathieu-Daudé--- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
.travis.yml +1 -1
@@ -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
Signature · 1 line
2.21.0