boot_linux_console.py (56889B)
1# Functional test that boots a Linux kernel and checks the console 2# 3# Copyright (c) 2018 Red Hat, Inc. 4# 5# Author: 6# Cleber Rosa <crosa@redhat.com> 7# 8# This work is licensed under the terms of the GNU GPL, version 2 or 9# later. See the COPYING file in the top-level directory. 10 11import os 12import lzma 13import gzip 14import shutil 15 16from avocado import skip 17from avocado import skipUnless 18from avocado_qemu import Test 19from avocado_qemu import exec_command 20from avocado_qemu import exec_command_and_wait_for_pattern 21from avocado_qemu import interrupt_interactive_console_until_pattern 22from avocado_qemu import wait_for_console_pattern 23from avocado.utils import process 24from avocado.utils import archive 25from avocado.utils.path import find_command, CmdNotFoundError 26 27P7ZIP_AVAILABLE = True 28try: 29 find_command('7z') 30except CmdNotFoundError: 31 P7ZIP_AVAILABLE = False 32 33""" 34Round up to next power of 2 35""" 36def pow2ceil(x): 37 return 1 if x == 0 else 2**(x - 1).bit_length() 38 39""" 40Expand file size to next power of 2 41""" 42def image_pow2ceil_expand(path): 43 size = os.path.getsize(path) 44 size_aligned = pow2ceil(size) 45 if size != size_aligned: 46 with open(path, 'ab+') as fd: 47 fd.truncate(size_aligned) 48 49class LinuxKernelTest(Test): 50 KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' 51 52 def wait_for_console_pattern(self, success_message, vm=None): 53 wait_for_console_pattern(self, success_message, 54 failure_message='Kernel panic - not syncing', 55 vm=vm) 56 57 def extract_from_deb(self, deb, path): 58 """ 59 Extracts a file from a deb package into the test workdir 60 61 :param deb: path to the deb archive 62 :param path: path within the deb archive of the file to be extracted 63 :returns: path of the extracted file 64 """ 65 cwd = os.getcwd() 66 os.chdir(self.workdir) 67 file_path = process.run("ar t %s" % deb).stdout_text.split()[2] 68 process.run("ar x %s %s" % (deb, file_path)) 69 archive.extract(file_path, self.workdir) 70 os.chdir(cwd) 71 # Return complete path to extracted file. Because callers to 72 # extract_from_deb() specify 'path' with a leading slash, it is 73 # necessary to use os.path.relpath() as otherwise os.path.join() 74 # interprets it as an absolute path and drops the self.workdir part. 75 return os.path.normpath(os.path.join(self.workdir, 76 os.path.relpath(path, '/'))) 77 78 def extract_from_rpm(self, rpm, path): 79 """ 80 Extracts a file from an RPM package into the test workdir. 81 82 :param rpm: path to the rpm archive 83 :param path: path within the rpm archive of the file to be extracted 84 needs to be a relative path (starting with './') because 85 cpio(1), which is used to extract the file, expects that. 86 :returns: path of the extracted file 87 """ 88 cwd = os.getcwd() 89 os.chdir(self.workdir) 90 process.run("rpm2cpio %s | cpio -id %s" % (rpm, path), shell=True) 91 os.chdir(cwd) 92 return os.path.normpath(os.path.join(self.workdir, path)) 93 94class BootLinuxConsole(LinuxKernelTest): 95 """ 96 Boots a Linux kernel and checks that the console is operational and the 97 kernel command line is properly passed from QEMU to the kernel 98 """ 99 timeout = 90 100 101 def test_x86_64_pc(self): 102 """ 103 :avocado: tags=arch:x86_64 104 :avocado: tags=machine:pc 105 """ 106 kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora' 107 '/linux/releases/29/Everything/x86_64/os/images/pxeboot' 108 '/vmlinuz') 109 kernel_hash = '23bebd2680757891cf7adedb033532163a792495' 110 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) 111 112 self.vm.set_console() 113 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' 114 self.vm.add_args('-kernel', kernel_path, 115 '-append', kernel_command_line) 116 self.vm.launch() 117 console_pattern = 'Kernel command line: %s' % kernel_command_line 118 self.wait_for_console_pattern(console_pattern) 119 120 def test_mips_malta(self): 121 """ 122 :avocado: tags=arch:mips 123 :avocado: tags=machine:malta 124 :avocado: tags=endian:big 125 """ 126 deb_url = ('http://snapshot.debian.org/archive/debian/' 127 '20130217T032700Z/pool/main/l/linux-2.6/' 128 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb') 129 deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04' 130 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) 131 kernel_path = self.extract_from_deb(deb_path, 132 '/boot/vmlinux-2.6.32-5-4kc-malta') 133 134 self.vm.set_console() 135 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' 136 self.vm.add_args('-kernel', kernel_path, 137 '-append', kernel_command_line) 138 self.vm.launch() 139 console_pattern = 'Kernel command line: %s' % kernel_command_line 140 self.wait_for_console_pattern(console_pattern) 141 142 def test_mips64el_malta(self): 143 """ 144 This test requires the ar tool to extract "data.tar.gz" from 145 the Debian package. 146 147 The kernel can be rebuilt using this Debian kernel source [1] and 148 following the instructions on [2]. 149 150 [1] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/ 151 #linux-source-2.6.32_2.6.32-48 152 [2] https://kernel-team.pages.debian.net/kernel-handbook/ 153 ch-common-tasks.html#s-common-official 154 155 :avocado: tags=arch:mips64el 156 :avocado: tags=machine:malta 157 """ 158 deb_url = ('http://snapshot.debian.org/archive/debian/' 159 '20130217T032700Z/pool/main/l/linux-2.6/' 160 'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb') 161 deb_hash = '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5' 162 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) 163 kernel_path = self.extract_from_deb(deb_path, 164 '/boot/vmlinux-2.6.32-5-5kc-malta') 165 166 self.vm.set_console() 167 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' 168 self.vm.add_args('-kernel', kernel_path, 169 '-append', kernel_command_line) 170 self.vm.launch() 171 console_pattern = 'Kernel command line: %s' % kernel_command_line 172 self.wait_for_console_pattern(console_pattern) 173 174 def test_mips64el_fuloong2e(self): 175 """ 176 :avocado: tags=arch:mips64el 177 :avocado: tags=machine:fuloong2e 178 :avocado: tags=endian:little 179 """ 180 deb_url = ('http://archive.debian.org/debian/pool/main/l/linux/' 181 'linux-image-3.16.0-6-loongson-2e_3.16.56-1+deb8u1_mipsel.deb') 182 deb_hash = 'd04d446045deecf7b755ef576551de0c4184dd44' 183 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) 184 kernel_path = self.extract_from_deb(deb_path, 185 '/boot/vmlinux-3.16.0-6-loongson-2e') 186 187 self.vm.set_console() 188 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' 189 self.vm.add_args('-kernel', kernel_path, 190 '-append', kernel_command_line) 191 self.vm.launch() 192 console_pattern = 'Kernel command line: %s' % kernel_command_line 193 self.wait_for_console_pattern(console_pattern) 194 195 def test_mips_malta_cpio(self): 196 """ 197 :avocado: tags=arch:mips 198 :avocado: tags=machine:malta 199 :avocado: tags=endian:big 200 """ 201 deb_url = ('http://snapshot.debian.org/archive/debian/' 202 '20160601T041800Z/pool/main/l/linux/' 203 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb') 204 deb_hash = 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8' 205 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) 206 kernel_path = self.extract_from_deb(deb_path, 207 '/boot/vmlinux-4.5.0-2-4kc-malta') 208 initrd_url = ('https://github.com/groeck/linux-build-test/raw/' 209 '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/' 210 'mips/rootfs.cpio.gz') 211 initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99' 212 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) 213 initrd_path = self.workdir + "rootfs.cpio" 214 archive.gzip_uncompress(initrd_path_gz, initrd_path) 215 216 self.vm.set_console() 217 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE 218 + 'console=ttyS0 console=tty ' 219 + 'rdinit=/sbin/init noreboot') 220 self.vm.add_args('-kernel', kernel_path, 221 '-initrd', initrd_path, 222 '-append', kernel_command_line, 223 '-no-reboot') 224 self.vm.launch() 225 self.wait_for_console_pattern('Boot successful.') 226 227 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 228 'BogoMIPS') 229 exec_command_and_wait_for_pattern(self, 'uname -a', 230 'Debian') 231 exec_command_and_wait_for_pattern(self, 'reboot', 232 'reboot: Restarting system') 233 # Wait for VM to shut down gracefully 234 self.vm.wait() 235 236 @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code') 237 def test_mips64el_malta_5KEc_cpio(self): 238 """ 239 :avocado: tags=arch:mips64el 240 :avocado: tags=machine:malta 241 :avocado: tags=endian:little 242 :avocado: tags=cpu:5KEc 243 """ 244 kernel_url = ('https://github.com/philmd/qemu-testing-blob/' 245 'raw/9ad2df38/mips/malta/mips64el/' 246 'vmlinux-3.19.3.mtoman.20150408') 247 kernel_hash = '00d1d268fb9f7d8beda1de6bebcc46e884d71754' 248 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) 249 initrd_url = ('https://github.com/groeck/linux-build-test/' 250 'raw/8584a59e/rootfs/' 251 'mipsel64/rootfs.mipsel64r1.cpio.gz') 252 initrd_hash = '1dbb8a396e916847325284dbe2151167' 253 initrd_path_gz = self.fetch_asset(initrd_url, algorithm='md5', 254 asset_hash=initrd_hash) 255 initrd_path = self.workdir + "rootfs.cpio" 256 archive.gzip_uncompress(initrd_path_gz, initrd_path) 257 258 self.vm.set_console() 259 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE 260 + 'console=ttyS0 console=tty ' 261 + 'rdinit=/sbin/init noreboot') 262 self.vm.add_args('-kernel', kernel_path, 263 '-initrd', initrd_path, 264 '-append', kernel_command_line, 265 '-no-reboot') 266 self.vm.launch() 267 wait_for_console_pattern(self, 'Boot successful.') 268 269 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 270 'MIPS 5KE') 271 exec_command_and_wait_for_pattern(self, 'uname -a', 272 '3.19.3.mtoman.20150408') 273 exec_command_and_wait_for_pattern(self, 'reboot', 274 'reboot: Restarting system') 275 # Wait for VM to shut down gracefully 276 self.vm.wait() 277 278 def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash): 279 kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash) 280 kernel_path = self.workdir + "kernel" 281 with lzma.open(kernel_path_xz, 'rb') as f_in: 282 with open(kernel_path, 'wb') as f_out: 283 shutil.copyfileobj(f_in, f_out) 284 285 self.vm.set_console() 286 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE 287 + 'mem=256m@@0x0 ' 288 + 'console=ttyS0') 289 self.vm.add_args('-no-reboot', 290 '-kernel', kernel_path, 291 '-append', kernel_command_line) 292 self.vm.launch() 293 console_pattern = 'Kernel command line: %s' % kernel_command_line 294 self.wait_for_console_pattern(console_pattern) 295 296 def test_mips_malta32el_nanomips_4k(self): 297 """ 298 :avocado: tags=arch:mipsel 299 :avocado: tags=machine:malta 300 :avocado: tags=endian:little 301 :avocado: tags=cpu:I7200 302 """ 303 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/' 304 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/' 305 'generic_nano32r6el_page4k.xz') 306 kernel_hash = '477456aafd2a0f1ddc9482727f20fe9575565dd6' 307 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash) 308 309 def test_mips_malta32el_nanomips_16k_up(self): 310 """ 311 :avocado: tags=arch:mipsel 312 :avocado: tags=machine:malta 313 :avocado: tags=endian:little 314 :avocado: tags=cpu:I7200 315 """ 316 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/' 317 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/' 318 'generic_nano32r6el_page16k_up.xz') 319 kernel_hash = 'e882868f944c71c816e832e2303b7874d044a7bc' 320 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash) 321 322 def test_mips_malta32el_nanomips_64k_dbg(self): 323 """ 324 :avocado: tags=arch:mipsel 325 :avocado: tags=machine:malta 326 :avocado: tags=endian:little 327 :avocado: tags=cpu:I7200 328 """ 329 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/' 330 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/' 331 'generic_nano32r6el_page64k_dbg.xz') 332 kernel_hash = '18d1c68f2e23429e266ca39ba5349ccd0aeb7180' 333 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash) 334 335 def test_aarch64_virt(self): 336 """ 337 :avocado: tags=arch:aarch64 338 :avocado: tags=machine:virt 339 :avocado: tags=accel:tcg 340 :avocado: tags=cpu:cortex-a53 341 """ 342 kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora' 343 '/linux/releases/29/Everything/aarch64/os/images/pxeboot' 344 '/vmlinuz') 345 kernel_hash = '8c73e469fc6ea06a58dc83a628fc695b693b8493' 346 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) 347 348 self.vm.set_console() 349 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 350 'console=ttyAMA0') 351 self.require_accelerator("tcg") 352 self.vm.add_args('-cpu', 'cortex-a53', 353 '-accel', 'tcg', 354 '-kernel', kernel_path, 355 '-append', kernel_command_line) 356 self.vm.launch() 357 console_pattern = 'Kernel command line: %s' % kernel_command_line 358 self.wait_for_console_pattern(console_pattern) 359 360 def test_aarch64_xlnx_versal_virt(self): 361 """ 362 :avocado: tags=arch:aarch64 363 :avocado: tags=machine:xlnx-versal-virt 364 :avocado: tags=device:pl011 365 :avocado: tags=device:arm_gicv3 366 :avocado: tags=accel:tcg 367 """ 368 images_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/' 369 'bionic-updates/main/installer-arm64/' 370 '20101020ubuntu543.15/images/') 371 kernel_url = images_url + 'netboot/ubuntu-installer/arm64/linux' 372 kernel_hash = '5bfc54cf7ed8157d93f6e5b0241e727b6dc22c50' 373 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) 374 375 initrd_url = images_url + 'netboot/ubuntu-installer/arm64/initrd.gz' 376 initrd_hash = 'd385d3e88d53e2004c5d43cbe668b458a094f772' 377 initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash) 378 379 self.vm.set_console() 380 self.vm.add_args('-m', '2G', 381 '-accel', 'tcg', 382 '-kernel', kernel_path, 383 '-initrd', initrd_path) 384 self.vm.launch() 385 self.wait_for_console_pattern('Checked W+X mappings: passed') 386 387 def test_arm_virt(self): 388 """ 389 :avocado: tags=arch:arm 390 :avocado: tags=machine:virt 391 :avocado: tags=accel:tcg 392 """ 393 kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora' 394 '/linux/releases/29/Everything/armhfp/os/images/pxeboot' 395 '/vmlinuz') 396 kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4' 397 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) 398 399 self.vm.set_console() 400 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 401 'console=ttyAMA0') 402 self.vm.add_args('-kernel', kernel_path, 403 '-append', kernel_command_line) 404 self.vm.launch() 405 console_pattern = 'Kernel command line: %s' % kernel_command_line 406 self.wait_for_console_pattern(console_pattern) 407 408 def test_arm_emcraft_sf2(self): 409 """ 410 :avocado: tags=arch:arm 411 :avocado: tags=machine:emcraft-sf2 412 :avocado: tags=endian:little 413 :avocado: tags=u-boot 414 :avocado: tags=accel:tcg 415 """ 416 uboot_url = ('https://raw.githubusercontent.com/' 417 'Subbaraya-Sundeep/qemu-test-binaries/' 418 'fe371d32e50ca682391e1e70ab98c2942aeffb01/u-boot') 419 uboot_hash = 'cbb8cbab970f594bf6523b9855be209c08374ae2' 420 uboot_path = self.fetch_asset(uboot_url, asset_hash=uboot_hash) 421 spi_url = ('https://raw.githubusercontent.com/' 422 'Subbaraya-Sundeep/qemu-test-binaries/' 423 'fe371d32e50ca682391e1e70ab98c2942aeffb01/spi.bin') 424 spi_hash = '65523a1835949b6f4553be96dec1b6a38fb05501' 425 spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash) 426 427 self.vm.set_console() 428 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE 429 self.vm.add_args('-kernel', uboot_path, 430 '-append', kernel_command_line, 431 '-drive', 'file=' + spi_path + ',if=mtd,format=raw', 432 '-no-reboot') 433 self.vm.launch() 434 self.wait_for_console_pattern('Enter \'help\' for a list') 435 436 exec_command_and_wait_for_pattern(self, 'ifconfig eth0 10.0.2.15', 437 'eth0: link becomes ready') 438 exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2', 439 '3 packets transmitted, 3 packets received, 0% packet loss') 440 441 def do_test_arm_raspi2(self, uart_id): 442 """ 443 :avocado: tags=accel:tcg 444 445 The kernel can be rebuilt using the kernel source referenced 446 and following the instructions on the on: 447 https://www.raspberrypi.org/documentation/linux/kernel/building.md 448 """ 449 serial_kernel_cmdline = { 450 0: 'earlycon=pl011,0x3f201000 console=ttyAMA0', 451 } 452 deb_url = ('http://archive.raspberrypi.org/debian/' 453 'pool/main/r/raspberrypi-firmware/' 454 'raspberrypi-kernel_1.20190215-1_armhf.deb') 455 deb_hash = 'cd284220b32128c5084037553db3c482426f3972' 456 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) 457 kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img') 458 dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb') 459 460 self.vm.set_console() 461 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 462 serial_kernel_cmdline[uart_id] + 463 ' root=/dev/mmcblk0p2 rootwait ' + 464 'dwc_otg.fiq_fsm_enable=0') 465 self.vm.add_args('-kernel', kernel_path, 466 '-dtb', dtb_path, 467 '-append', kernel_command_line, 468 '-device', 'usb-kbd') 469 self.vm.launch() 470 console_pattern = 'Kernel command line: %s' % kernel_command_line 471 self.wait_for_console_pattern(console_pattern) 472 console_pattern = 'Product: QEMU USB Keyboard' 473 self.wait_for_console_pattern(console_pattern) 474 475 def test_arm_raspi2_uart0(self): 476 """ 477 :avocado: tags=arch:arm 478 :avocado: tags=machine:raspi2b 479 :avocado: tags=device:pl011 480 :avocado: tags=accel:tcg 481 """ 482 self.do_test_arm_raspi2(0) 483 484 def test_arm_raspi2_initrd(self): 485 """ 486 :avocado: tags=arch:arm 487 :avocado: tags=machine:raspi2b 488 """ 489 deb_url = ('http://archive.raspberrypi.org/debian/' 490 'pool/main/r/raspberrypi-firmware/' 491 'raspberrypi-kernel_1.20190215-1_armhf.deb') 492 deb_hash = 'cd284220b32128c5084037553db3c482426f3972' 493 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) 494 kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img') 495 dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb') 496 497 initrd_url = ('https://github.com/groeck/linux-build-test/raw/' 498 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' 499 'arm/rootfs-armv7a.cpio.gz') 500 initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c' 501 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) 502 initrd_path = os.path.join(self.workdir, 'rootfs.cpio') 503 archive.gzip_uncompress(initrd_path_gz, initrd_path) 504 505 self.vm.set_console() 506 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 507 'earlycon=pl011,0x3f201000 console=ttyAMA0 ' 508 'panic=-1 noreboot ' + 509 'dwc_otg.fiq_fsm_enable=0') 510 self.vm.add_args('-kernel', kernel_path, 511 '-dtb', dtb_path, 512 '-initrd', initrd_path, 513 '-append', kernel_command_line, 514 '-no-reboot') 515 self.vm.launch() 516 self.wait_for_console_pattern('Boot successful.') 517 518 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 519 'BCM2835') 520 exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', 521 '/soc/cprman@7e101000') 522 exec_command(self, 'halt') 523 # Wait for VM to shut down gracefully 524 self.vm.wait() 525 526 def test_arm_exynos4210_initrd(self): 527 """ 528 :avocado: tags=arch:arm 529 :avocado: tags=machine:smdkc210 530 :avocado: tags=accel:tcg 531 """ 532 deb_url = ('https://snapshot.debian.org/archive/debian/' 533 '20190928T224601Z/pool/main/l/linux/' 534 'linux-image-4.19.0-6-armmp_4.19.67-2+deb10u1_armhf.deb') 535 deb_hash = 'fa9df4a0d38936cb50084838f2cb933f570d7d82' 536 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) 537 kernel_path = self.extract_from_deb(deb_path, 538 '/boot/vmlinuz-4.19.0-6-armmp') 539 dtb_path = '/usr/lib/linux-image-4.19.0-6-armmp/exynos4210-smdkv310.dtb' 540 dtb_path = self.extract_from_deb(deb_path, dtb_path) 541 542 initrd_url = ('https://github.com/groeck/linux-build-test/raw/' 543 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' 544 'arm/rootfs-armv5.cpio.gz') 545 initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b' 546 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) 547 initrd_path = os.path.join(self.workdir, 'rootfs.cpio') 548 archive.gzip_uncompress(initrd_path_gz, initrd_path) 549 550 self.vm.set_console() 551 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 552 'earlycon=exynos4210,0x13800000 earlyprintk ' + 553 'console=ttySAC0,115200n8 ' + 554 'random.trust_cpu=off cryptomgr.notests ' + 555 'cpuidle.off=1 panic=-1 noreboot') 556 557 self.vm.add_args('-kernel', kernel_path, 558 '-dtb', dtb_path, 559 '-initrd', initrd_path, 560 '-append', kernel_command_line, 561 '-no-reboot') 562 self.vm.launch() 563 564 self.wait_for_console_pattern('Boot successful.') 565 # TODO user command, for now the uart is stuck 566 567 def test_arm_cubieboard_initrd(self): 568 """ 569 :avocado: tags=arch:arm 570 :avocado: tags=machine:cubieboard 571 :avocado: tags=accel:tcg 572 """ 573 deb_url = ('https://apt.armbian.com/pool/main/l/' 574 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') 575 deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' 576 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) 577 kernel_path = self.extract_from_deb(deb_path, 578 '/boot/vmlinuz-5.10.16-sunxi') 579 dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb' 580 dtb_path = self.extract_from_deb(deb_path, dtb_path) 581 initrd_url = ('https://github.com/groeck/linux-build-test/raw/' 582 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' 583 'arm/rootfs-armv5.cpio.gz') 584 initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b' 585 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) 586 initrd_path = os.path.join(self.workdir, 'rootfs.cpio') 587 archive.gzip_uncompress(initrd_path_gz, initrd_path) 588 589 self.vm.set_console() 590 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 591 'console=ttyS0,115200 ' 592 'usbcore.nousb ' 593 'panic=-1 noreboot') 594 self.vm.add_args('-kernel', kernel_path, 595 '-dtb', dtb_path, 596 '-initrd', initrd_path, 597 '-append', kernel_command_line, 598 '-no-reboot') 599 self.vm.launch() 600 self.wait_for_console_pattern('Boot successful.') 601 602 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 603 'Allwinner sun4i/sun5i') 604 exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', 605 'system-control@1c00000') 606 # cubieboard's reboot is not functioning; omit reboot test. 607 608 def test_arm_cubieboard_sata(self): 609 """ 610 :avocado: tags=arch:arm 611 :avocado: tags=machine:cubieboard 612 :avocado: tags=accel:tcg 613 """ 614 deb_url = ('https://apt.armbian.com/pool/main/l/' 615 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') 616 deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' 617 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) 618 kernel_path = self.extract_from_deb(deb_path, 619 '/boot/vmlinuz-5.10.16-sunxi') 620 dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb' 621 dtb_path = self.extract_from_deb(deb_path, dtb_path) 622 rootfs_url = ('https://github.com/groeck/linux-build-test/raw/' 623 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' 624 'arm/rootfs-armv5.ext2.gz') 625 rootfs_hash = '093e89d2b4d982234bf528bc9fb2f2f17a9d1f93' 626 rootfs_path_gz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash) 627 rootfs_path = os.path.join(self.workdir, 'rootfs.cpio') 628 archive.gzip_uncompress(rootfs_path_gz, rootfs_path) 629 630 self.vm.set_console() 631 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 632 'console=ttyS0,115200 ' 633 'usbcore.nousb ' 634 'root=/dev/sda ro ' 635 'panic=-1 noreboot') 636 self.vm.add_args('-kernel', kernel_path, 637 '-dtb', dtb_path, 638 '-drive', 'if=none,format=raw,id=disk0,file=' 639 + rootfs_path, 640 '-device', 'ide-hd,bus=ide.0,drive=disk0', 641 '-append', kernel_command_line, 642 '-no-reboot') 643 self.vm.launch() 644 self.wait_for_console_pattern('Boot successful.') 645 646 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 647 'Allwinner sun4i/sun5i') 648 exec_command_and_wait_for_pattern(self, 'cat /proc/partitions', 649 'sda') 650 # cubieboard's reboot is not functioning; omit reboot test. 651 652 @skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout') 653 def test_arm_quanta_gsj(self): 654 """ 655 :avocado: tags=arch:arm 656 :avocado: tags=machine:quanta-gsj 657 :avocado: tags=accel:tcg 658 """ 659 # 25 MiB compressed, 32 MiB uncompressed. 660 image_url = ( 661 'https://github.com/hskinnemoen/openbmc/releases/download/' 662 '20200711-gsj-qemu-0/obmc-phosphor-image-gsj.static.mtd.gz') 663 image_hash = '14895e634923345cb5c8776037ff7876df96f6b1' 664 image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash) 665 image_name = 'obmc.mtd' 666 image_path = os.path.join(self.workdir, image_name) 667 archive.gzip_uncompress(image_path_gz, image_path) 668 669 self.vm.set_console() 670 drive_args = 'file=' + image_path + ',if=mtd,bus=0,unit=0' 671 self.vm.add_args('-drive', drive_args) 672 self.vm.launch() 673 674 # Disable drivers and services that stall for a long time during boot, 675 # to avoid running past the 90-second timeout. These may be removed 676 # as the corresponding device support is added. 677 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + ( 678 'console=${console} ' 679 'mem=${mem} ' 680 'initcall_blacklist=npcm_i2c_bus_driver_init ' 681 'systemd.mask=systemd-random-seed.service ' 682 'systemd.mask=dropbearkey.service ' 683 ) 684 685 self.wait_for_console_pattern('> BootBlock by Nuvoton') 686 self.wait_for_console_pattern('>Device: Poleg BMC NPCM730') 687 self.wait_for_console_pattern('>Skip DDR init.') 688 self.wait_for_console_pattern('U-Boot ') 689 interrupt_interactive_console_until_pattern( 690 self, 'Hit any key to stop autoboot:', 'U-Boot>') 691 exec_command_and_wait_for_pattern( 692 self, "setenv bootargs ${bootargs} " + kernel_command_line, 693 'U-Boot>') 694 exec_command_and_wait_for_pattern( 695 self, 'run romboot', 'Booting Kernel from flash') 696 self.wait_for_console_pattern('Booting Linux on physical CPU 0x0') 697 self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0') 698 self.wait_for_console_pattern('OpenBMC Project Reference Distro') 699 self.wait_for_console_pattern('gsj login:') 700 701 def test_arm_quanta_gsj_initrd(self): 702 """ 703 :avocado: tags=arch:arm 704 :avocado: tags=machine:quanta-gsj 705 :avocado: tags=accel:tcg 706 """ 707 initrd_url = ( 708 'https://github.com/hskinnemoen/openbmc/releases/download/' 709 '20200711-gsj-qemu-0/obmc-phosphor-initramfs-gsj.cpio.xz') 710 initrd_hash = '98fefe5d7e56727b1eb17d5c00311b1b5c945300' 711 initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash) 712 kernel_url = ( 713 'https://github.com/hskinnemoen/openbmc/releases/download/' 714 '20200711-gsj-qemu-0/uImage-gsj.bin') 715 kernel_hash = 'fa67b2f141d56d39b3c54305c0e8a899c99eb2c7' 716 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) 717 dtb_url = ( 718 'https://github.com/hskinnemoen/openbmc/releases/download/' 719 '20200711-gsj-qemu-0/nuvoton-npcm730-gsj.dtb') 720 dtb_hash = '18315f7006d7b688d8312d5c727eecd819aa36a4' 721 dtb_path = self.fetch_asset(dtb_url, asset_hash=dtb_hash) 722 723 self.vm.set_console() 724 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 725 'console=ttyS0,115200n8 ' 726 'earlycon=uart8250,mmio32,0xf0001000') 727 self.vm.add_args('-kernel', kernel_path, 728 '-initrd', initrd_path, 729 '-dtb', dtb_path, 730 '-append', kernel_command_line) 731 self.vm.launch() 732 733 self.wait_for_console_pattern('Booting Linux on physical CPU 0x0') 734 self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0') 735 self.wait_for_console_pattern( 736 'Give root password for system maintenance') 737 738 def test_arm_orangepi(self): 739 """ 740 :avocado: tags=arch:arm 741 :avocado: tags=machine:orangepi-pc 742 :avocado: tags=accel:tcg 743 """ 744 deb_url = ('https://apt.armbian.com/pool/main/l/' 745 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') 746 deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' 747 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) 748 kernel_path = self.extract_from_deb(deb_path, 749 '/boot/vmlinuz-5.10.16-sunxi') 750 dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb' 751 dtb_path = self.extract_from_deb(deb_path, dtb_path) 752 753 self.vm.set_console() 754 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 755 'console=ttyS0,115200n8 ' 756 'earlycon=uart,mmio32,0x1c28000') 757 self.vm.add_args('-kernel', kernel_path, 758 '-dtb', dtb_path, 759 '-append', kernel_command_line) 760 self.vm.launch() 761 console_pattern = 'Kernel command line: %s' % kernel_command_line 762 self.wait_for_console_pattern(console_pattern) 763 764 def test_arm_orangepi_initrd(self): 765 """ 766 :avocado: tags=arch:arm 767 :avocado: tags=accel:tcg 768 :avocado: tags=machine:orangepi-pc 769 """ 770 deb_url = ('https://apt.armbian.com/pool/main/l/' 771 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') 772 deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' 773 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) 774 kernel_path = self.extract_from_deb(deb_path, 775 '/boot/vmlinuz-5.10.16-sunxi') 776 dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb' 777 dtb_path = self.extract_from_deb(deb_path, dtb_path) 778 initrd_url = ('https://github.com/groeck/linux-build-test/raw/' 779 '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' 780 'arm/rootfs-armv7a.cpio.gz') 781 initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c' 782 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) 783 initrd_path = os.path.join(self.workdir, 'rootfs.cpio') 784 archive.gzip_uncompress(initrd_path_gz, initrd_path) 785 786 self.vm.set_console() 787 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 788 'console=ttyS0,115200 ' 789 'panic=-1 noreboot') 790 self.vm.add_args('-kernel', kernel_path, 791 '-dtb', dtb_path, 792 '-initrd', initrd_path, 793 '-append', kernel_command_line, 794 '-no-reboot') 795 self.vm.launch() 796 self.wait_for_console_pattern('Boot successful.') 797 798 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 799 'Allwinner sun8i Family') 800 exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', 801 'system-control@1c00000') 802 exec_command_and_wait_for_pattern(self, 'reboot', 803 'reboot: Restarting system') 804 # Wait for VM to shut down gracefully 805 self.vm.wait() 806 807 def test_arm_orangepi_sd(self): 808 """ 809 :avocado: tags=arch:arm 810 :avocado: tags=accel:tcg 811 :avocado: tags=machine:orangepi-pc 812 :avocado: tags=device:sd 813 """ 814 deb_url = ('https://apt.armbian.com/pool/main/l/' 815 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') 816 deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' 817 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) 818 kernel_path = self.extract_from_deb(deb_path, 819 '/boot/vmlinuz-5.10.16-sunxi') 820 dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb' 821 dtb_path = self.extract_from_deb(deb_path, dtb_path) 822 rootfs_url = ('http://storage.kernelci.org/images/rootfs/buildroot/' 823 'kci-2019.02/armel/base/rootfs.ext2.xz') 824 rootfs_hash = '692510cb625efda31640d1de0a8d60e26040f061' 825 rootfs_path_xz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash) 826 rootfs_path = os.path.join(self.workdir, 'rootfs.cpio') 827 archive.lzma_uncompress(rootfs_path_xz, rootfs_path) 828 image_pow2ceil_expand(rootfs_path) 829 830 self.vm.set_console() 831 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 832 'console=ttyS0,115200 ' 833 'root=/dev/mmcblk0 rootwait rw ' 834 'panic=-1 noreboot') 835 self.vm.add_args('-kernel', kernel_path, 836 '-dtb', dtb_path, 837 '-drive', 'file=' + rootfs_path + ',if=sd,format=raw', 838 '-append', kernel_command_line, 839 '-no-reboot') 840 self.vm.launch() 841 shell_ready = "/bin/sh: can't access tty; job control turned off" 842 self.wait_for_console_pattern(shell_ready) 843 844 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 845 'Allwinner sun8i Family') 846 exec_command_and_wait_for_pattern(self, 'cat /proc/partitions', 847 'mmcblk0') 848 exec_command_and_wait_for_pattern(self, 'ifconfig eth0 up', 849 'eth0: Link is Up') 850 exec_command_and_wait_for_pattern(self, 'udhcpc eth0', 851 'udhcpc: lease of 10.0.2.15 obtained') 852 exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2', 853 '3 packets transmitted, 3 packets received, 0% packet loss') 854 exec_command_and_wait_for_pattern(self, 'reboot', 855 'reboot: Restarting system') 856 # Wait for VM to shut down gracefully 857 self.vm.wait() 858 859 @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') 860 def test_arm_orangepi_bionic_20_08(self): 861 """ 862 :avocado: tags=arch:arm 863 :avocado: tags=machine:orangepi-pc 864 :avocado: tags=device:sd 865 """ 866 867 # This test download a 275 MiB compressed image and expand it 868 # to 1036 MiB, but the underlying filesystem is 1552 MiB... 869 # As we expand it to 2 GiB we are safe. 870 871 image_url = ('https://archive.armbian.com/orangepipc/archive/' 872 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz') 873 image_hash = ('b4d6775f5673486329e45a0586bf06b6' 874 'dbe792199fd182ac6b9c7bb6c7d3e6dd') 875 image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash, 876 algorithm='sha256') 877 image_path = archive.extract(image_path_xz, self.workdir) 878 image_pow2ceil_expand(image_path) 879 880 self.vm.set_console() 881 self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw', 882 '-nic', 'user', 883 '-no-reboot') 884 self.vm.launch() 885 886 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 887 'console=ttyS0,115200 ' 888 'loglevel=7 ' 889 'nosmp ' 890 'systemd.default_timeout_start_sec=9000 ' 891 'systemd.mask=armbian-zram-config.service ' 892 'systemd.mask=armbian-ramlog.service') 893 894 self.wait_for_console_pattern('U-Boot SPL') 895 self.wait_for_console_pattern('Autoboot in ') 896 exec_command_and_wait_for_pattern(self, ' ', '=>') 897 exec_command_and_wait_for_pattern(self, "setenv extraargs '" + 898 kernel_command_line + "'", '=>') 899 exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...'); 900 901 self.wait_for_console_pattern('systemd[1]: Set hostname ' + 902 'to <orangepipc>') 903 self.wait_for_console_pattern('Starting Load Kernel Modules...') 904 905 @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') 906 def test_arm_orangepi_uboot_netbsd9(self): 907 """ 908 :avocado: tags=arch:arm 909 :avocado: tags=machine:orangepi-pc 910 :avocado: tags=device:sd 911 :avocado: tags=os:netbsd 912 """ 913 # This test download a 304MB compressed image and expand it to 2GB 914 deb_url = ('http://snapshot.debian.org/archive/debian/' 915 '20200108T145233Z/pool/main/u/u-boot/' 916 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb') 917 deb_hash = 'f67f404a80753ca3d1258f13e38f2b060e13db99' 918 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) 919 # We use the common OrangePi PC 'plus' build of U-Boot for our secondary 920 # program loader (SPL). We will then set the path to the more specific 921 # OrangePi "PC" device tree blob with 'setenv fdtfile' in U-Boot prompt, 922 # before to boot NetBSD. 923 uboot_path = '/usr/lib/u-boot/orangepi_plus/u-boot-sunxi-with-spl.bin' 924 uboot_path = self.extract_from_deb(deb_path, uboot_path) 925 image_url = ('https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/' 926 'evbarm-earmv7hf/binary/gzimg/armv7.img.gz') 927 image_hash = '2babb29d36d8360adcb39c09e31060945259917a' 928 image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash) 929 image_path = os.path.join(self.workdir, 'armv7.img') 930 archive.gzip_uncompress(image_path_gz, image_path) 931 image_pow2ceil_expand(image_path) 932 image_drive_args = 'if=sd,format=raw,snapshot=on,file=' + image_path 933 934 # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 conv=notrunc 935 with open(uboot_path, 'rb') as f_in: 936 with open(image_path, 'r+b') as f_out: 937 f_out.seek(8 * 1024) 938 shutil.copyfileobj(f_in, f_out) 939 940 self.vm.set_console() 941 self.vm.add_args('-nic', 'user', 942 '-drive', image_drive_args, 943 '-global', 'allwinner-rtc.base-year=2000', 944 '-no-reboot') 945 self.vm.launch() 946 wait_for_console_pattern(self, 'U-Boot 2020.01+dfsg-1') 947 interrupt_interactive_console_until_pattern(self, 948 'Hit any key to stop autoboot:', 949 'switch to partitions #0, OK') 950 951 exec_command_and_wait_for_pattern(self, '', '=>') 952 cmd = 'setenv bootargs root=ld0a' 953 exec_command_and_wait_for_pattern(self, cmd, '=>') 954 cmd = 'setenv kernel netbsd-GENERIC.ub' 955 exec_command_and_wait_for_pattern(self, cmd, '=>') 956 cmd = 'setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb' 957 exec_command_and_wait_for_pattern(self, cmd, '=>') 958 cmd = ("setenv bootcmd 'fatload mmc 0:1 ${kernel_addr_r} ${kernel}; " 959 "fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; " 960 "fdt addr ${fdt_addr_r}; " 961 "bootm ${kernel_addr_r} - ${fdt_addr_r}'") 962 exec_command_and_wait_for_pattern(self, cmd, '=>') 963 964 exec_command_and_wait_for_pattern(self, 'boot', 965 'Booting kernel from Legacy Image') 966 wait_for_console_pattern(self, 'Starting kernel ...') 967 wait_for_console_pattern(self, 'NetBSD 9.0 (GENERIC)') 968 # Wait for user-space 969 wait_for_console_pattern(self, 'Starting root file system check') 970 971 def test_aarch64_raspi3_atf(self): 972 """ 973 :avocado: tags=arch:aarch64 974 :avocado: tags=machine:raspi3b 975 :avocado: tags=cpu:cortex-a53 976 :avocado: tags=device:pl011 977 :avocado: tags=atf 978 """ 979 zip_url = ('https://github.com/pbatard/RPi3/releases/download/' 980 'v1.15/RPi3_UEFI_Firmware_v1.15.zip') 981 zip_hash = '74b3bd0de92683cadb14e008a7575e1d0c3cafb9' 982 zip_path = self.fetch_asset(zip_url, asset_hash=zip_hash) 983 984 archive.extract(zip_path, self.workdir) 985 efi_fd = os.path.join(self.workdir, 'RPI_EFI.fd') 986 987 self.vm.set_console(console_index=1) 988 self.vm.add_args('-nodefaults', 989 '-device', 'loader,file=%s,force-raw=true' % efi_fd) 990 self.vm.launch() 991 self.wait_for_console_pattern('version UEFI Firmware v1.15') 992 993 def test_s390x_s390_ccw_virtio(self): 994 """ 995 :avocado: tags=arch:s390x 996 :avocado: tags=machine:s390-ccw-virtio 997 """ 998 kernel_url = ('https://archives.fedoraproject.org/pub/archive' 999 '/fedora-secondary/releases/29/Everything/s390x/os/images' 1000 '/kernel.img') 1001 kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313' 1002 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) 1003 1004 self.vm.set_console() 1005 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0' 1006 self.vm.add_args('-nodefaults', 1007 '-kernel', kernel_path, 1008 '-append', kernel_command_line) 1009 self.vm.launch() 1010 console_pattern = 'Kernel command line: %s' % kernel_command_line 1011 self.wait_for_console_pattern(console_pattern) 1012 1013 def test_alpha_clipper(self): 1014 """ 1015 :avocado: tags=arch:alpha 1016 :avocado: tags=machine:clipper 1017 """ 1018 kernel_url = ('http://archive.debian.org/debian/dists/lenny/main/' 1019 'installer-alpha/20090123lenny10/images/cdrom/vmlinuz') 1020 kernel_hash = '3a943149335529e2ed3e74d0d787b85fb5671ba3' 1021 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) 1022 1023 uncompressed_kernel = archive.uncompress(kernel_path, self.workdir) 1024 1025 self.vm.set_console() 1026 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' 1027 self.vm.add_args('-nodefaults', 1028 '-kernel', uncompressed_kernel, 1029 '-append', kernel_command_line) 1030 self.vm.launch() 1031 console_pattern = 'Kernel command line: %s' % kernel_command_line 1032 self.wait_for_console_pattern(console_pattern) 1033 1034 def test_m68k_q800(self): 1035 """ 1036 :avocado: tags=arch:m68k 1037 :avocado: tags=machine:q800 1038 """ 1039 deb_url = ('https://snapshot.debian.org/archive/debian-ports' 1040 '/20191021T083923Z/pool-m68k/main' 1041 '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb') 1042 deb_hash = '044954bb9be4160a3ce81f8bc1b5e856b75cccd1' 1043 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) 1044 kernel_path = self.extract_from_deb(deb_path, 1045 '/boot/vmlinux-5.3.0-1-m68k') 1046 1047 self.vm.set_console() 1048 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 1049 'console=ttyS0 vga=off') 1050 self.vm.add_args('-kernel', kernel_path, 1051 '-append', kernel_command_line) 1052 self.vm.launch() 1053 console_pattern = 'Kernel command line: %s' % kernel_command_line 1054 self.wait_for_console_pattern(console_pattern) 1055 console_pattern = 'No filesystem could mount root' 1056 self.wait_for_console_pattern(console_pattern) 1057 1058 def do_test_advcal_2018(self, day, tar_hash, kernel_name, console=0): 1059 tar_url = ('https://www.qemu-advent-calendar.org' 1060 '/2018/download/day' + day + '.tar.xz') 1061 file_path = self.fetch_asset(tar_url, asset_hash=tar_hash) 1062 archive.extract(file_path, self.workdir) 1063 self.vm.set_console(console_index=console) 1064 self.vm.add_args('-kernel', 1065 self.workdir + '/day' + day + '/' + kernel_name) 1066 self.vm.launch() 1067 self.wait_for_console_pattern('QEMU advent calendar') 1068 1069 def test_arm_vexpressa9(self): 1070 """ 1071 :avocado: tags=arch:arm 1072 :avocado: tags=machine:vexpress-a9 1073 """ 1074 tar_hash = '32b7677ce8b6f1471fb0059865f451169934245b' 1075 self.vm.add_args('-dtb', self.workdir + '/day16/vexpress-v2p-ca9.dtb') 1076 self.do_test_advcal_2018('16', tar_hash, 'winter.zImage') 1077 1078 def test_arm_ast2400_palmetto_openbmc_v2_9_0(self): 1079 """ 1080 :avocado: tags=arch:arm 1081 :avocado: tags=machine:palmetto-bmc 1082 """ 1083 1084 image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/' 1085 'obmc-phosphor-image-palmetto.static.mtd') 1086 image_hash = ('3e13bbbc28e424865dc42f35ad672b10f2e82cdb11846bb28fa625b48beafd0d') 1087 image_path = self.fetch_asset(image_url, asset_hash=image_hash, 1088 algorithm='sha256') 1089 1090 self.do_test_arm_aspeed(image_path) 1091 1092 def test_arm_ast2500_romulus_openbmc_v2_9_0(self): 1093 """ 1094 :avocado: tags=arch:arm 1095 :avocado: tags=machine:romulus-bmc 1096 """ 1097 1098 image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/' 1099 'obmc-phosphor-image-romulus.static.mtd') 1100 image_hash = ('820341076803f1955bc31e647a512c79f9add4f5233d0697678bab4604c7bb25') 1101 image_path = self.fetch_asset(image_url, asset_hash=image_hash, 1102 algorithm='sha256') 1103 1104 self.do_test_arm_aspeed(image_path) 1105 1106 def do_test_arm_aspeed(self, image): 1107 self.vm.set_console() 1108 self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', 1109 '-net', 'nic') 1110 self.vm.launch() 1111 1112 self.wait_for_console_pattern("U-Boot 2016.07") 1113 self.wait_for_console_pattern("## Loading kernel from FIT Image at 20080000") 1114 self.wait_for_console_pattern("Starting kernel ...") 1115 self.wait_for_console_pattern("Booting Linux on physical CPU 0x0") 1116 self.wait_for_console_pattern( 1117 "aspeed-smc 1e620000.spi: read control register: 203b0641") 1118 self.wait_for_console_pattern("ftgmac100 1e660000.ethernet eth0: irq ") 1119 self.wait_for_console_pattern("systemd[1]: Set hostname to") 1120 1121 def test_arm_ast2600_debian(self): 1122 """ 1123 :avocado: tags=arch:arm 1124 :avocado: tags=machine:tacoma-bmc 1125 """ 1126 deb_url = ('http://snapshot.debian.org/archive/debian/' 1127 '20210302T203551Z/' 1128 'pool/main/l/linux/' 1129 'linux-image-5.10.0-3-armmp_5.10.13-1_armhf.deb') 1130 deb_hash = 'db40d32fe39255d05482bea48d72467b67d6225bb2a2a4d6f618cb8976f1e09e' 1131 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash, 1132 algorithm='sha256') 1133 kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-5.10.0-3-armmp') 1134 dtb_path = self.extract_from_deb(deb_path, 1135 '/usr/lib/linux-image-5.10.0-3-armmp/aspeed-bmc-opp-tacoma.dtb') 1136 1137 self.vm.set_console() 1138 self.vm.add_args('-kernel', kernel_path, 1139 '-dtb', dtb_path, 1140 '-net', 'nic') 1141 self.vm.launch() 1142 self.wait_for_console_pattern("Booting Linux on physical CPU 0xf00") 1143 self.wait_for_console_pattern("SMP: Total of 2 processors activated") 1144 self.wait_for_console_pattern("No filesystem could mount root") 1145 1146 def test_m68k_mcf5208evb(self): 1147 """ 1148 :avocado: tags=arch:m68k 1149 :avocado: tags=machine:mcf5208evb 1150 """ 1151 tar_hash = 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c' 1152 self.do_test_advcal_2018('07', tar_hash, 'sanity-clause.elf') 1153 1154 def test_or1k_sim(self): 1155 """ 1156 :avocado: tags=arch:or1k 1157 :avocado: tags=machine:or1k-sim 1158 """ 1159 tar_hash = '20334cdaf386108c530ff0badaecc955693027dd' 1160 self.do_test_advcal_2018('20', tar_hash, 'vmlinux') 1161 1162 def test_nios2_10m50(self): 1163 """ 1164 :avocado: tags=arch:nios2 1165 :avocado: tags=machine:10m50-ghrd 1166 """ 1167 tar_hash = 'e4251141726c412ac0407c5a6bceefbbff018918' 1168 self.do_test_advcal_2018('14', tar_hash, 'vmlinux.elf') 1169 1170 def test_ppc64_e500(self): 1171 """ 1172 :avocado: tags=arch:ppc64 1173 :avocado: tags=machine:ppce500 1174 :avocado: tags=cpu:e5500 1175 """ 1176 tar_hash = '6951d86d644b302898da2fd701739c9406527fe1' 1177 self.do_test_advcal_2018('19', tar_hash, 'uImage') 1178 1179 def do_test_ppc64_powernv(self, proc): 1180 images_url = ('https://github.com/open-power/op-build/releases/download/v2.7/') 1181 1182 kernel_url = images_url + 'zImage.epapr' 1183 kernel_hash = '0ab237df661727e5392cee97460e8674057a883c5f74381a128fa772588d45cd' 1184 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash, 1185 algorithm='sha256') 1186 self.vm.set_console() 1187 self.vm.add_args('-kernel', kernel_path, 1188 '-append', 'console=tty0 console=hvc0', 1189 '-device', 'pcie-pci-bridge,id=bridge1,bus=pcie.1,addr=0x0', 1190 '-device', 'nvme,bus=pcie.2,addr=0x0,serial=1234', 1191 '-device', 'e1000e,bus=bridge1,addr=0x3', 1192 '-device', 'nec-usb-xhci,bus=bridge1,addr=0x2') 1193 self.vm.launch() 1194 1195 self.wait_for_console_pattern("CPU: " + proc + " generation processor") 1196 self.wait_for_console_pattern("zImage starting: loaded") 1197 self.wait_for_console_pattern("Run /init as init process") 1198 self.wait_for_console_pattern("Creating 1 MTD partitions") 1199 1200 def test_ppc_powernv8(self): 1201 """ 1202 :avocado: tags=arch:ppc64 1203 :avocado: tags=machine:powernv8 1204 """ 1205 self.do_test_ppc64_powernv('P8') 1206 1207 def test_ppc_powernv9(self): 1208 """ 1209 :avocado: tags=arch:ppc64 1210 :avocado: tags=machine:powernv9 1211 """ 1212 self.do_test_ppc64_powernv('P9') 1213 1214 def test_ppc_g3beige(self): 1215 """ 1216 :avocado: tags=arch:ppc 1217 :avocado: tags=machine:g3beige 1218 """ 1219 tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc' 1220 self.vm.add_args('-M', 'graphics=off') 1221 self.do_test_advcal_2018('15', tar_hash, 'invaders.elf') 1222 1223 def test_ppc_mac99(self): 1224 """ 1225 :avocado: tags=arch:ppc 1226 :avocado: tags=machine:mac99 1227 """ 1228 tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc' 1229 self.vm.add_args('-M', 'graphics=off') 1230 self.do_test_advcal_2018('15', tar_hash, 'invaders.elf') 1231 1232 def test_sh4_r2d(self): 1233 """ 1234 :avocado: tags=arch:sh4 1235 :avocado: tags=machine:r2d 1236 """ 1237 tar_hash = 'fe06a4fd8ccbf2e27928d64472939d47829d4c7e' 1238 self.vm.add_args('-append', 'console=ttySC1') 1239 self.do_test_advcal_2018('09', tar_hash, 'zImage', console=1) 1240 1241 def test_sparc_ss20(self): 1242 """ 1243 :avocado: tags=arch:sparc 1244 :avocado: tags=machine:SS-20 1245 """ 1246 tar_hash = 'b18550d5d61c7615d989a06edace051017726a9f' 1247 self.do_test_advcal_2018('11', tar_hash, 'zImage.elf') 1248 1249 def test_xtensa_lx60(self): 1250 """ 1251 :avocado: tags=arch:xtensa 1252 :avocado: tags=machine:lx60 1253 :avocado: tags=cpu:dc233c 1254 """ 1255 tar_hash = '49e88d9933742f0164b60839886c9739cb7a0d34' 1256 self.do_test_advcal_2018('02', tar_hash, 'santas-sleigh-ride.elf')