aboutsummaryrefslogtreecommitdiff
path: root/tests/acceptance/boot_linux_console.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/acceptance/boot_linux_console.py')
-rw-r--r--tests/acceptance/boot_linux_console.py167
1 files changed, 131 insertions, 36 deletions
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index df27813c78..4e9ac0ecc3 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -9,12 +9,14 @@
# later. See the COPYING file in the top-level directory.
import os
-import logging
import lzma
import gzip
import shutil
+from avocado import skipUnless
from avocado_qemu import Test
+from avocado_qemu import exec_command_and_wait_for_pattern
+from avocado_qemu import wait_for_console_pattern
from avocado.utils import process
from avocado.utils import archive
@@ -29,31 +31,9 @@ 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)
+ def wait_for_console_pattern(self, success_message):
+ wait_for_console_pattern(self, success_message,
+ failure_message='Kernel panic - not syncing')
def extract_from_deb(self, deb, path):
"""
@@ -166,10 +146,7 @@ class BootLinuxConsole(Test):
initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99'
initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
initrd_path = self.workdir + "rootfs.cpio"
-
- with gzip.open(initrd_path_gz, 'rb') as f_in:
- with open(initrd_path, 'wb') as f_out:
- shutil.copyfileobj(f_in, f_out)
+ archive.gzip_uncompress(initrd_path_gz, initrd_path)
self.vm.set_machine('malta')
self.vm.set_console()
@@ -183,12 +160,53 @@ class BootLinuxConsole(Test):
self.vm.launch()
self.wait_for_console_pattern('Boot successful.')
- self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo',
- 'BogoMIPS')
- self.exec_command_and_wait_for_pattern('uname -a',
- 'Debian')
- self.exec_command_and_wait_for_pattern('reboot',
- 'reboot: Restarting system')
+ exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
+ 'BogoMIPS')
+ exec_command_and_wait_for_pattern(self, 'uname -a',
+ 'Debian')
+ exec_command_and_wait_for_pattern(self, 'reboot',
+ 'reboot: Restarting system')
+
+ @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+ def test_mips64el_malta_5KEc_cpio(self):
+ """
+ :avocado: tags=arch:mips64el
+ :avocado: tags=machine:malta
+ :avocado: tags=endian:little
+ """
+ kernel_url = ('https://github.com/philmd/qemu-testing-blob/'
+ 'raw/9ad2df38/mips/malta/mips64el/'
+ 'vmlinux-3.19.3.mtoman.20150408')
+ kernel_hash = '00d1d268fb9f7d8beda1de6bebcc46e884d71754'
+ kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+ initrd_url = ('https://github.com/groeck/linux-build-test/'
+ 'raw/8584a59e/rootfs/'
+ 'mipsel64/rootfs.mipsel64r1.cpio.gz')
+ initrd_hash = '1dbb8a396e916847325284dbe2151167'
+ initrd_path_gz = self.fetch_asset(initrd_url, algorithm='md5',
+ asset_hash=initrd_hash)
+ initrd_path = self.workdir + "rootfs.cpio"
+ archive.gzip_uncompress(initrd_path_gz, initrd_path)
+
+ self.vm.set_machine('malta')
+ self.vm.set_console()
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
+ + 'console=ttyS0 console=tty '
+ + 'rdinit=/sbin/init noreboot')
+ self.vm.add_args('-cpu', '5KEc',
+ '-kernel', kernel_path,
+ '-initrd', initrd_path,
+ '-append', kernel_command_line,
+ '-no-reboot')
+ self.vm.launch()
+ wait_for_console_pattern(self, 'Boot successful.')
+
+ exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
+ 'MIPS 5KE')
+ exec_command_and_wait_for_pattern(self, 'uname -a',
+ '3.19.3.mtoman.20150408')
+ exec_command_and_wait_for_pattern(self, 'reboot',
+ 'reboot: Restarting system')
def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash):
kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
@@ -316,6 +334,83 @@ class BootLinuxConsole(Test):
self.vm.launch()
self.wait_for_console_pattern('init started: BusyBox')
+ def do_test_arm_raspi2(self, uart_id):
+ """
+ The kernel can be rebuilt using the kernel source referenced
+ and following the instructions on the on:
+ https://www.raspberrypi.org/documentation/linux/kernel/building.md
+ """
+ serial_kernel_cmdline = {
+ 0: 'earlycon=pl011,0x3f201000 console=ttyAMA0',
+ }
+ deb_url = ('http://archive.raspberrypi.org/debian/'
+ 'pool/main/r/raspberrypi-firmware/'
+ 'raspberrypi-kernel_1.20190215-1_armhf.deb')
+ deb_hash = 'cd284220b32128c5084037553db3c482426f3972'
+ deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+ kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
+ dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
+
+ self.vm.set_machine('raspi2')
+ self.vm.set_console()
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
+ serial_kernel_cmdline[uart_id])
+ self.vm.add_args('-kernel', kernel_path,
+ '-dtb', dtb_path,
+ '-append', kernel_command_line)
+ self.vm.launch()
+ console_pattern = 'Kernel command line: %s' % kernel_command_line
+ self.wait_for_console_pattern(console_pattern)
+
+ def test_arm_raspi2_uart0(self):
+ """
+ :avocado: tags=arch:arm
+ :avocado: tags=machine:raspi2
+ :avocado: tags=device:pl011
+ """
+ self.do_test_arm_raspi2(0)
+
+ def test_arm_exynos4210_initrd(self):
+ """
+ :avocado: tags=arch:arm
+ :avocado: tags=machine:smdkc210
+ """
+ deb_url = ('https://snapshot.debian.org/archive/debian/'
+ '20190928T224601Z/pool/main/l/linux/'
+ 'linux-image-4.19.0-6-armmp_4.19.67-2+deb10u1_armhf.deb')
+ deb_hash = 'fa9df4a0d38936cb50084838f2cb933f570d7d82'
+ deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+ kernel_path = self.extract_from_deb(deb_path,
+ '/boot/vmlinuz-4.19.0-6-armmp')
+ dtb_path = '/usr/lib/linux-image-4.19.0-6-armmp/exynos4210-smdkv310.dtb'
+ dtb_path = self.extract_from_deb(deb_path, dtb_path)
+
+ initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
+ '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
+ 'arm/rootfs-armv5.cpio.gz')
+ initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
+ initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
+ initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
+ archive.gzip_uncompress(initrd_path_gz, initrd_path)
+
+ self.vm.set_machine('smdkc210')
+ self.vm.set_console()
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
+ 'earlycon=exynos4210,0x13800000 earlyprintk ' +
+ 'console=ttySAC0,115200n8 ' +
+ 'random.trust_cpu=off cryptomgr.notests ' +
+ 'cpuidle.off=1 panic=-1 noreboot')
+
+ self.vm.add_args('-kernel', kernel_path,
+ '-dtb', dtb_path,
+ '-initrd', initrd_path,
+ '-append', kernel_command_line,
+ '-no-reboot')
+ self.vm.launch()
+
+ self.wait_for_console_pattern('Boot successful.')
+ # TODO user command, for now the uart is stuck
+
def test_s390x_s390_ccw_virtio(self):
"""
:avocado: tags=arch:s390x