Cleber Rosa | c1cc73f | 2018-05-30 14:41:56 -0400 | [diff] [blame] | 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 | |
Philippe Mathieu-Daudé | f879204 | 2019-03-12 13:18:17 -0400 | [diff] [blame] | 11 | import os |
Philippe Mathieu-Daudé | f375ad6 | 2019-05-21 01:19:08 +0200 | [diff] [blame] | 12 | import lzma |
Philippe Mathieu-Daudé | 8936867 | 2019-05-21 01:19:09 +0200 | [diff] [blame] | 13 | import gzip |
Philippe Mathieu-Daudé | f375ad6 | 2019-05-21 01:19:08 +0200 | [diff] [blame] | 14 | import shutil |
Cleber Rosa | c1cc73f | 2018-05-30 14:41:56 -0400 | [diff] [blame] | 15 | |
Philippe Mathieu-Daudé | efdb45b | 2019-10-28 19:04:04 -0400 | [diff] [blame] | 16 | from avocado import skipUnless |
Cleber Rosa | c1cc73f | 2018-05-30 14:41:56 -0400 | [diff] [blame] | 17 | from avocado_qemu import Test |
Philippe Mathieu-Daudé | 2b17d81 | 2019-10-28 19:04:04 -0400 | [diff] [blame] | 18 | from avocado_qemu import exec_command_and_wait_for_pattern |
Philippe Mathieu-Daudé | 921589f | 2020-03-11 23:18:53 +0100 | [diff] [blame] | 19 | from avocado_qemu import interrupt_interactive_console_until_pattern |
Cleber Rosa | 77bcd24 | 2019-10-28 19:04:04 -0400 | [diff] [blame] | 20 | from avocado_qemu import wait_for_console_pattern |
Philippe Mathieu-Daudé | f879204 | 2019-03-12 13:18:17 -0400 | [diff] [blame] | 21 | from avocado.utils import process |
| 22 | from avocado.utils import archive |
Philippe Mathieu-Daudé | 784b879 | 2020-03-11 23:18:52 +0100 | [diff] [blame] | 23 | from avocado.utils.path import find_command, CmdNotFoundError |
Cleber Rosa | c1cc73f | 2018-05-30 14:41:56 -0400 | [diff] [blame] | 24 | |
Philippe Mathieu-Daudé | 784b879 | 2020-03-11 23:18:52 +0100 | [diff] [blame] | 25 | P7ZIP_AVAILABLE = True |
| 26 | try: |
| 27 | find_command('7z') |
| 28 | except CmdNotFoundError: |
| 29 | P7ZIP_AVAILABLE = False |
Cleber Rosa | c1cc73f | 2018-05-30 14:41:56 -0400 | [diff] [blame] | 30 | |
| 31 | class BootLinuxConsole(Test): |
| 32 | """ |
Cleber Rosa | 78664ed | 2019-03-12 13:18:11 -0400 | [diff] [blame] | 33 | Boots a Linux kernel and checks that the console is operational and the |
| 34 | kernel command line is properly passed from QEMU to the kernel |
Cleber Rosa | c1cc73f | 2018-05-30 14:41:56 -0400 | [diff] [blame] | 35 | """ |
| 36 | |
Cleber Rosa | 61f7450 | 2019-03-12 13:18:14 -0400 | [diff] [blame] | 37 | timeout = 90 |
Cleber Rosa | c1cc73f | 2018-05-30 14:41:56 -0400 | [diff] [blame] | 38 | |
Cleber Rosa | b50fcd3 | 2019-03-12 13:18:13 -0400 | [diff] [blame] | 39 | KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' |
| 40 | |
Cleber Rosa | 77bcd24 | 2019-10-28 19:04:04 -0400 | [diff] [blame] | 41 | def wait_for_console_pattern(self, success_message): |
| 42 | wait_for_console_pattern(self, success_message, |
| 43 | failure_message='Kernel panic - not syncing') |
Philippe Mathieu-Daudé | 8936867 | 2019-05-21 01:19:09 +0200 | [diff] [blame] | 44 | |
Philippe Mathieu-Daudé | f879204 | 2019-03-12 13:18:17 -0400 | [diff] [blame] | 45 | def extract_from_deb(self, deb, path): |
| 46 | """ |
| 47 | Extracts a file from a deb package into the test workdir |
| 48 | |
| 49 | :param deb: path to the deb archive |
Liam Merwick | 4526038 | 2020-01-27 16:36:31 +0000 | [diff] [blame] | 50 | :param path: path within the deb archive of the file to be extracted |
Philippe Mathieu-Daudé | f879204 | 2019-03-12 13:18:17 -0400 | [diff] [blame] | 51 | :returns: path of the extracted file |
| 52 | """ |
| 53 | cwd = os.getcwd() |
| 54 | os.chdir(self.workdir) |
Philippe Mathieu-Daudé | 6c1c4c3 | 2019-03-13 00:45:40 +0100 | [diff] [blame] | 55 | file_path = process.run("ar t %s" % deb).stdout_text.split()[2] |
| 56 | process.run("ar x %s %s" % (deb, file_path)) |
| 57 | archive.extract(file_path, self.workdir) |
Philippe Mathieu-Daudé | f879204 | 2019-03-12 13:18:17 -0400 | [diff] [blame] | 58 | os.chdir(cwd) |
Liam Merwick | 921a9f6 | 2020-02-05 14:56:05 +0000 | [diff] [blame] | 59 | # Return complete path to extracted file. Because callers to |
| 60 | # extract_from_deb() specify 'path' with a leading slash, it is |
| 61 | # necessary to use os.path.relpath() as otherwise os.path.join() |
| 62 | # interprets it as an absolute path and drops the self.workdir part. |
| 63 | return os.path.normpath(os.path.join(self.workdir, |
| 64 | os.path.relpath(path, '/'))) |
Philippe Mathieu-Daudé | f879204 | 2019-03-12 13:18:17 -0400 | [diff] [blame] | 65 | |
Liam Merwick | 76a901d | 2020-02-05 14:56:03 +0000 | [diff] [blame] | 66 | def extract_from_rpm(self, rpm, path): |
| 67 | """ |
| 68 | Extracts a file from an RPM package into the test workdir. |
| 69 | |
| 70 | :param rpm: path to the rpm archive |
| 71 | :param path: path within the rpm archive of the file to be extracted |
| 72 | needs to be a relative path (starting with './') because |
| 73 | cpio(1), which is used to extract the file, expects that. |
| 74 | :returns: path of the extracted file |
| 75 | """ |
| 76 | cwd = os.getcwd() |
| 77 | os.chdir(self.workdir) |
| 78 | process.run("rpm2cpio %s | cpio -id %s" % (rpm, path), shell=True) |
| 79 | os.chdir(cwd) |
| 80 | return os.path.normpath(os.path.join(self.workdir, path)) |
| 81 | |
Cleber Rosa | 78664ed | 2019-03-12 13:18:11 -0400 | [diff] [blame] | 82 | def test_x86_64_pc(self): |
| 83 | """ |
| 84 | :avocado: tags=arch:x86_64 |
| 85 | :avocado: tags=machine:pc |
| 86 | """ |
Cleber Rosa | 93bbbdf | 2019-09-03 20:52:18 -0400 | [diff] [blame] | 87 | kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora' |
| 88 | '/linux/releases/29/Everything/x86_64/os/images/pxeboot' |
| 89 | '/vmlinuz') |
Cleber Rosa | 7d7985b | 2019-03-12 13:18:12 -0400 | [diff] [blame] | 90 | kernel_hash = '23bebd2680757891cf7adedb033532163a792495' |
Cleber Rosa | c1cc73f | 2018-05-30 14:41:56 -0400 | [diff] [blame] | 91 | kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) |
| 92 | |
Cleber Rosa | c1cc73f | 2018-05-30 14:41:56 -0400 | [diff] [blame] | 93 | self.vm.set_console() |
Cleber Rosa | b50fcd3 | 2019-03-12 13:18:13 -0400 | [diff] [blame] | 94 | kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' |
Cleber Rosa | c1cc73f | 2018-05-30 14:41:56 -0400 | [diff] [blame] | 95 | self.vm.add_args('-kernel', kernel_path, |
| 96 | '-append', kernel_command_line) |
| 97 | self.vm.launch() |
Cleber Rosa | 0d1d74e | 2019-03-12 13:18:15 -0400 | [diff] [blame] | 98 | console_pattern = 'Kernel command line: %s' % kernel_command_line |
| 99 | self.wait_for_console_pattern(console_pattern) |
Philippe Mathieu-Daudé | f879204 | 2019-03-12 13:18:17 -0400 | [diff] [blame] | 100 | |
| 101 | def test_mips_malta(self): |
| 102 | """ |
| 103 | :avocado: tags=arch:mips |
| 104 | :avocado: tags=machine:malta |
| 105 | :avocado: tags=endian:big |
| 106 | """ |
| 107 | deb_url = ('http://snapshot.debian.org/archive/debian/' |
| 108 | '20130217T032700Z/pool/main/l/linux-2.6/' |
| 109 | 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb') |
| 110 | deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04' |
| 111 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
| 112 | kernel_path = self.extract_from_deb(deb_path, |
| 113 | '/boot/vmlinux-2.6.32-5-4kc-malta') |
| 114 | |
Philippe Mathieu-Daudé | f879204 | 2019-03-12 13:18:17 -0400 | [diff] [blame] | 115 | self.vm.set_console() |
| 116 | kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' |
| 117 | self.vm.add_args('-kernel', kernel_path, |
| 118 | '-append', kernel_command_line) |
| 119 | self.vm.launch() |
| 120 | console_pattern = 'Kernel command line: %s' % kernel_command_line |
| 121 | self.wait_for_console_pattern(console_pattern) |
Cleber Rosa | 02c2852 | 2019-03-12 13:18:18 -0400 | [diff] [blame] | 122 | |
| 123 | def test_mips64el_malta(self): |
| 124 | """ |
| 125 | This test requires the ar tool to extract "data.tar.gz" from |
| 126 | the Debian package. |
| 127 | |
| 128 | The kernel can be rebuilt using this Debian kernel source [1] and |
| 129 | following the instructions on [2]. |
| 130 | |
| 131 | [1] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/ |
| 132 | #linux-source-2.6.32_2.6.32-48 |
| 133 | [2] https://kernel-team.pages.debian.net/kernel-handbook/ |
| 134 | ch-common-tasks.html#s-common-official |
| 135 | |
| 136 | :avocado: tags=arch:mips64el |
| 137 | :avocado: tags=machine:malta |
| 138 | """ |
| 139 | deb_url = ('http://snapshot.debian.org/archive/debian/' |
| 140 | '20130217T032700Z/pool/main/l/linux-2.6/' |
| 141 | 'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb') |
| 142 | deb_hash = '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5' |
| 143 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
| 144 | kernel_path = self.extract_from_deb(deb_path, |
| 145 | '/boot/vmlinux-2.6.32-5-5kc-malta') |
| 146 | |
Cleber Rosa | 02c2852 | 2019-03-12 13:18:18 -0400 | [diff] [blame] | 147 | self.vm.set_console() |
| 148 | kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' |
| 149 | self.vm.add_args('-kernel', kernel_path, |
| 150 | '-append', kernel_command_line) |
| 151 | self.vm.launch() |
| 152 | console_pattern = 'Kernel command line: %s' % kernel_command_line |
| 153 | self.wait_for_console_pattern(console_pattern) |
Cleber Rosa | d4e1216 | 2019-03-12 13:18:21 -0400 | [diff] [blame] | 154 | |
Philippe Mathieu-Daudé | 8936867 | 2019-05-21 01:19:09 +0200 | [diff] [blame] | 155 | def test_mips_malta_cpio(self): |
| 156 | """ |
| 157 | :avocado: tags=arch:mips |
| 158 | :avocado: tags=machine:malta |
| 159 | :avocado: tags=endian:big |
| 160 | """ |
| 161 | deb_url = ('http://snapshot.debian.org/archive/debian/' |
| 162 | '20160601T041800Z/pool/main/l/linux/' |
| 163 | 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb') |
| 164 | deb_hash = 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8' |
| 165 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
| 166 | kernel_path = self.extract_from_deb(deb_path, |
| 167 | '/boot/vmlinux-4.5.0-2-4kc-malta') |
| 168 | initrd_url = ('https://github.com/groeck/linux-build-test/raw/' |
| 169 | '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/' |
| 170 | 'mips/rootfs.cpio.gz') |
| 171 | initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99' |
| 172 | initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) |
| 173 | initrd_path = self.workdir + "rootfs.cpio" |
Philippe Mathieu-Daudé | f2cd6cf | 2019-10-28 19:04:04 -0400 | [diff] [blame] | 174 | archive.gzip_uncompress(initrd_path_gz, initrd_path) |
Philippe Mathieu-Daudé | 8936867 | 2019-05-21 01:19:09 +0200 | [diff] [blame] | 175 | |
Philippe Mathieu-Daudé | 8936867 | 2019-05-21 01:19:09 +0200 | [diff] [blame] | 176 | self.vm.set_console() |
| 177 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE |
| 178 | + 'console=ttyS0 console=tty ' |
| 179 | + 'rdinit=/sbin/init noreboot') |
| 180 | self.vm.add_args('-kernel', kernel_path, |
| 181 | '-initrd', initrd_path, |
| 182 | '-append', kernel_command_line, |
| 183 | '-no-reboot') |
| 184 | self.vm.launch() |
| 185 | self.wait_for_console_pattern('Boot successful.') |
| 186 | |
Philippe Mathieu-Daudé | 2b17d81 | 2019-10-28 19:04:04 -0400 | [diff] [blame] | 187 | exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', |
| 188 | 'BogoMIPS') |
| 189 | exec_command_and_wait_for_pattern(self, 'uname -a', |
| 190 | 'Debian') |
| 191 | exec_command_and_wait_for_pattern(self, 'reboot', |
| 192 | 'reboot: Restarting system') |
Philippe Mathieu-Daudé | 8936867 | 2019-05-21 01:19:09 +0200 | [diff] [blame] | 193 | |
Philippe Mathieu-Daudé | efdb45b | 2019-10-28 19:04:04 -0400 | [diff] [blame] | 194 | @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code') |
| 195 | def test_mips64el_malta_5KEc_cpio(self): |
| 196 | """ |
| 197 | :avocado: tags=arch:mips64el |
| 198 | :avocado: tags=machine:malta |
| 199 | :avocado: tags=endian:little |
| 200 | """ |
| 201 | kernel_url = ('https://github.com/philmd/qemu-testing-blob/' |
| 202 | 'raw/9ad2df38/mips/malta/mips64el/' |
| 203 | 'vmlinux-3.19.3.mtoman.20150408') |
| 204 | kernel_hash = '00d1d268fb9f7d8beda1de6bebcc46e884d71754' |
| 205 | kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) |
| 206 | initrd_url = ('https://github.com/groeck/linux-build-test/' |
| 207 | 'raw/8584a59e/rootfs/' |
| 208 | 'mipsel64/rootfs.mipsel64r1.cpio.gz') |
| 209 | initrd_hash = '1dbb8a396e916847325284dbe2151167' |
| 210 | initrd_path_gz = self.fetch_asset(initrd_url, algorithm='md5', |
| 211 | asset_hash=initrd_hash) |
| 212 | initrd_path = self.workdir + "rootfs.cpio" |
| 213 | archive.gzip_uncompress(initrd_path_gz, initrd_path) |
| 214 | |
Philippe Mathieu-Daudé | efdb45b | 2019-10-28 19:04:04 -0400 | [diff] [blame] | 215 | self.vm.set_console() |
| 216 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE |
| 217 | + 'console=ttyS0 console=tty ' |
| 218 | + 'rdinit=/sbin/init noreboot') |
| 219 | self.vm.add_args('-cpu', '5KEc', |
| 220 | '-kernel', kernel_path, |
| 221 | '-initrd', initrd_path, |
| 222 | '-append', kernel_command_line, |
| 223 | '-no-reboot') |
| 224 | self.vm.launch() |
| 225 | wait_for_console_pattern(self, 'Boot successful.') |
| 226 | |
| 227 | exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', |
| 228 | 'MIPS 5KE') |
| 229 | exec_command_and_wait_for_pattern(self, 'uname -a', |
| 230 | '3.19.3.mtoman.20150408') |
| 231 | exec_command_and_wait_for_pattern(self, 'reboot', |
| 232 | 'reboot: Restarting system') |
Philippe Mathieu-Daudé | f375ad6 | 2019-05-21 01:19:08 +0200 | [diff] [blame] | 233 | |
| 234 | def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash): |
| 235 | kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash) |
| 236 | kernel_path = self.workdir + "kernel" |
| 237 | with lzma.open(kernel_path_xz, 'rb') as f_in: |
| 238 | with open(kernel_path, 'wb') as f_out: |
| 239 | shutil.copyfileobj(f_in, f_out) |
| 240 | |
Cleber Rosa | d4e1216 | 2019-03-12 13:18:21 -0400 | [diff] [blame] | 241 | self.vm.set_console() |
| 242 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE |
| 243 | + 'mem=256m@@0x0 ' |
| 244 | + 'console=ttyS0') |
| 245 | self.vm.add_args('-no-reboot', |
| 246 | '-cpu', 'I7200', |
| 247 | '-kernel', kernel_path, |
| 248 | '-append', kernel_command_line) |
| 249 | self.vm.launch() |
| 250 | console_pattern = 'Kernel command line: %s' % kernel_command_line |
Cleber Rosa | 1a30892 | 2019-03-12 13:18:22 -0400 | [diff] [blame] | 251 | self.wait_for_console_pattern(console_pattern) |
| 252 | |
| 253 | def test_mips_malta32el_nanomips_4k(self): |
| 254 | """ |
| 255 | :avocado: tags=arch:mipsel |
| 256 | :avocado: tags=machine:malta |
| 257 | :avocado: tags=endian:little |
| 258 | """ |
| 259 | kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/' |
| 260 | 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/' |
| 261 | 'generic_nano32r6el_page4k.xz') |
| 262 | kernel_hash = '477456aafd2a0f1ddc9482727f20fe9575565dd6' |
| 263 | self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash) |
| 264 | |
| 265 | def test_mips_malta32el_nanomips_16k_up(self): |
| 266 | """ |
| 267 | :avocado: tags=arch:mipsel |
| 268 | :avocado: tags=machine:malta |
| 269 | :avocado: tags=endian:little |
| 270 | """ |
Cleber Rosa | 7918249 | 2019-03-12 13:18:23 -0400 | [diff] [blame] | 271 | kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/' |
Philippe Mathieu-Daudé | 77ead6b | 2019-05-21 00:06:35 +0200 | [diff] [blame] | 272 | 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/' |
| 273 | 'generic_nano32r6el_page16k_up.xz') |
| 274 | kernel_hash = 'e882868f944c71c816e832e2303b7874d044a7bc' |
| 275 | self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash) |
| 276 | |
| 277 | def test_mips_malta32el_nanomips_64k_dbg(self): |
| 278 | """ |
| 279 | :avocado: tags=arch:mipsel |
| 280 | :avocado: tags=machine:malta |
| 281 | :avocado: tags=endian:little |
| 282 | """ |
| 283 | kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/' |
| 284 | 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/' |
| 285 | 'generic_nano32r6el_page64k_dbg.xz') |
| 286 | kernel_hash = '18d1c68f2e23429e266ca39ba5349ccd0aeb7180' |
| 287 | self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash) |
| 288 | |
| 289 | def test_aarch64_virt(self): |
| 290 | """ |
| 291 | :avocado: tags=arch:aarch64 |
| 292 | :avocado: tags=machine:virt |
| 293 | """ |
Cleber Rosa | 93bbbdf | 2019-09-03 20:52:18 -0400 | [diff] [blame] | 294 | kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora' |
| 295 | '/linux/releases/29/Everything/aarch64/os/images/pxeboot' |
| 296 | '/vmlinuz') |
Cleber Rosa | c1cc73f | 2018-05-30 14:41:56 -0400 | [diff] [blame] | 297 | kernel_hash = '8c73e469fc6ea06a58dc83a628fc695b693b8493' |
| 298 | kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) |
| 299 | |
Cleber Rosa | c1cc73f | 2018-05-30 14:41:56 -0400 | [diff] [blame] | 300 | self.vm.set_console() |
| 301 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
| 302 | 'console=ttyAMA0') |
| 303 | self.vm.add_args('-cpu', 'cortex-a53', |
| 304 | '-kernel', kernel_path, |
| 305 | '-append', kernel_command_line) |
| 306 | self.vm.launch() |
| 307 | console_pattern = 'Kernel command line: %s' % kernel_command_line |
| 308 | self.wait_for_console_pattern(console_pattern) |
| 309 | |
| 310 | def test_arm_virt(self): |
| 311 | """ |
| 312 | :avocado: tags=arch:arm |
| 313 | :avocado: tags=machine:virt |
| 314 | """ |
Cleber Rosa | 93bbbdf | 2019-09-03 20:52:18 -0400 | [diff] [blame] | 315 | kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora' |
| 316 | '/linux/releases/29/Everything/armhfp/os/images/pxeboot' |
| 317 | '/vmlinuz') |
Cleber Rosa | c1cc73f | 2018-05-30 14:41:56 -0400 | [diff] [blame] | 318 | kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4' |
| 319 | kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) |
| 320 | |
Cleber Rosa | c1cc73f | 2018-05-30 14:41:56 -0400 | [diff] [blame] | 321 | self.vm.set_console() |
| 322 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
| 323 | 'console=ttyAMA0') |
| 324 | self.vm.add_args('-kernel', kernel_path, |
| 325 | '-append', kernel_command_line) |
| 326 | self.vm.launch() |
| 327 | console_pattern = 'Kernel command line: %s' % kernel_command_line |
| 328 | self.wait_for_console_pattern(console_pattern) |
Cleber Rosa | 7918249 | 2019-03-12 13:18:23 -0400 | [diff] [blame] | 329 | |
Philippe Mathieu-Daudé | 77ead6b | 2019-05-21 00:06:35 +0200 | [diff] [blame] | 330 | def test_arm_emcraft_sf2(self): |
| 331 | """ |
| 332 | :avocado: tags=arch:arm |
Cleber Rosa | ba21bde | 2019-11-04 10:13:18 -0500 | [diff] [blame] | 333 | :avocado: tags=machine:emcraft-sf2 |
Philippe Mathieu-Daudé | 77ead6b | 2019-05-21 00:06:35 +0200 | [diff] [blame] | 334 | :avocado: tags=endian:little |
Philippe Mathieu-Daudé | b6f0a43 | 2020-01-21 00:51:59 +0100 | [diff] [blame] | 335 | :avocado: tags=u-boot |
Philippe Mathieu-Daudé | 77ead6b | 2019-05-21 00:06:35 +0200 | [diff] [blame] | 336 | """ |
| 337 | uboot_url = ('https://raw.githubusercontent.com/' |
| 338 | 'Subbaraya-Sundeep/qemu-test-binaries/' |
Subbaraya Sundeep | 70d7857 | 2020-04-16 20:24:51 +0530 | [diff] [blame] | 339 | 'fe371d32e50ca682391e1e70ab98c2942aeffb01/u-boot') |
| 340 | uboot_hash = 'cbb8cbab970f594bf6523b9855be209c08374ae2' |
Philippe Mathieu-Daudé | 77ead6b | 2019-05-21 00:06:35 +0200 | [diff] [blame] | 341 | uboot_path = self.fetch_asset(uboot_url, asset_hash=uboot_hash) |
| 342 | spi_url = ('https://raw.githubusercontent.com/' |
| 343 | 'Subbaraya-Sundeep/qemu-test-binaries/' |
Subbaraya Sundeep | 70d7857 | 2020-04-16 20:24:51 +0530 | [diff] [blame] | 344 | 'fe371d32e50ca682391e1e70ab98c2942aeffb01/spi.bin') |
| 345 | spi_hash = '65523a1835949b6f4553be96dec1b6a38fb05501' |
Philippe Mathieu-Daudé | 77ead6b | 2019-05-21 00:06:35 +0200 | [diff] [blame] | 346 | spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash) |
| 347 | |
Philippe Mathieu-Daudé | 77ead6b | 2019-05-21 00:06:35 +0200 | [diff] [blame] | 348 | self.vm.set_console() |
| 349 | kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE |
| 350 | self.vm.add_args('-kernel', uboot_path, |
| 351 | '-append', kernel_command_line, |
| 352 | '-drive', 'file=' + spi_path + ',if=mtd,format=raw', |
| 353 | '-no-reboot') |
| 354 | self.vm.launch() |
Subbaraya Sundeep | 70d7857 | 2020-04-16 20:24:51 +0530 | [diff] [blame] | 355 | self.wait_for_console_pattern('Enter \'help\' for a list') |
| 356 | |
| 357 | exec_command_and_wait_for_pattern(self, 'ifconfig eth0 10.0.2.15', |
| 358 | 'eth0: link becomes ready') |
| 359 | exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2', |
| 360 | '3 packets transmitted, 3 packets received, 0% packet loss') |
Philippe Mathieu-Daudé | 77ead6b | 2019-05-21 00:06:35 +0200 | [diff] [blame] | 361 | |
Philippe Mathieu-Daudé | 92d9361 | 2019-10-28 19:04:04 -0400 | [diff] [blame] | 362 | def do_test_arm_raspi2(self, uart_id): |
| 363 | """ |
| 364 | The kernel can be rebuilt using the kernel source referenced |
| 365 | and following the instructions on the on: |
| 366 | https://www.raspberrypi.org/documentation/linux/kernel/building.md |
| 367 | """ |
| 368 | serial_kernel_cmdline = { |
| 369 | 0: 'earlycon=pl011,0x3f201000 console=ttyAMA0', |
| 370 | } |
| 371 | deb_url = ('http://archive.raspberrypi.org/debian/' |
| 372 | 'pool/main/r/raspberrypi-firmware/' |
| 373 | 'raspberrypi-kernel_1.20190215-1_armhf.deb') |
| 374 | deb_hash = 'cd284220b32128c5084037553db3c482426f3972' |
| 375 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
| 376 | kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img') |
| 377 | dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb') |
| 378 | |
Philippe Mathieu-Daudé | 92d9361 | 2019-10-28 19:04:04 -0400 | [diff] [blame] | 379 | self.vm.set_console() |
| 380 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
| 381 | serial_kernel_cmdline[uart_id]) |
| 382 | self.vm.add_args('-kernel', kernel_path, |
| 383 | '-dtb', dtb_path, |
| 384 | '-append', kernel_command_line) |
| 385 | self.vm.launch() |
| 386 | console_pattern = 'Kernel command line: %s' % kernel_command_line |
| 387 | self.wait_for_console_pattern(console_pattern) |
| 388 | |
| 389 | def test_arm_raspi2_uart0(self): |
| 390 | """ |
| 391 | :avocado: tags=arch:arm |
| 392 | :avocado: tags=machine:raspi2 |
| 393 | :avocado: tags=device:pl011 |
| 394 | """ |
| 395 | self.do_test_arm_raspi2(0) |
| 396 | |
Philippe Mathieu-Daudé | 017aa60 | 2019-10-28 19:04:04 -0400 | [diff] [blame] | 397 | def test_arm_exynos4210_initrd(self): |
| 398 | """ |
| 399 | :avocado: tags=arch:arm |
| 400 | :avocado: tags=machine:smdkc210 |
| 401 | """ |
| 402 | deb_url = ('https://snapshot.debian.org/archive/debian/' |
| 403 | '20190928T224601Z/pool/main/l/linux/' |
| 404 | 'linux-image-4.19.0-6-armmp_4.19.67-2+deb10u1_armhf.deb') |
| 405 | deb_hash = 'fa9df4a0d38936cb50084838f2cb933f570d7d82' |
| 406 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
| 407 | kernel_path = self.extract_from_deb(deb_path, |
| 408 | '/boot/vmlinuz-4.19.0-6-armmp') |
| 409 | dtb_path = '/usr/lib/linux-image-4.19.0-6-armmp/exynos4210-smdkv310.dtb' |
| 410 | dtb_path = self.extract_from_deb(deb_path, dtb_path) |
| 411 | |
| 412 | initrd_url = ('https://github.com/groeck/linux-build-test/raw/' |
| 413 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' |
| 414 | 'arm/rootfs-armv5.cpio.gz') |
| 415 | initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b' |
| 416 | initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) |
| 417 | initrd_path = os.path.join(self.workdir, 'rootfs.cpio') |
| 418 | archive.gzip_uncompress(initrd_path_gz, initrd_path) |
| 419 | |
Philippe Mathieu-Daudé | 017aa60 | 2019-10-28 19:04:04 -0400 | [diff] [blame] | 420 | self.vm.set_console() |
| 421 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
| 422 | 'earlycon=exynos4210,0x13800000 earlyprintk ' + |
| 423 | 'console=ttySAC0,115200n8 ' + |
| 424 | 'random.trust_cpu=off cryptomgr.notests ' + |
| 425 | 'cpuidle.off=1 panic=-1 noreboot') |
| 426 | |
| 427 | self.vm.add_args('-kernel', kernel_path, |
| 428 | '-dtb', dtb_path, |
| 429 | '-initrd', initrd_path, |
| 430 | '-append', kernel_command_line, |
| 431 | '-no-reboot') |
| 432 | self.vm.launch() |
| 433 | |
| 434 | self.wait_for_console_pattern('Boot successful.') |
| 435 | # TODO user command, for now the uart is stuck |
| 436 | |
Philippe Mathieu-Daudé | c5ce315 | 2020-01-17 14:09:29 +0000 | [diff] [blame] | 437 | def test_arm_cubieboard_initrd(self): |
| 438 | """ |
| 439 | :avocado: tags=arch:arm |
| 440 | :avocado: tags=machine:cubieboard |
| 441 | """ |
| 442 | deb_url = ('https://apt.armbian.com/pool/main/l/' |
| 443 | 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') |
| 444 | deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' |
| 445 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
| 446 | kernel_path = self.extract_from_deb(deb_path, |
| 447 | '/boot/vmlinuz-4.20.7-sunxi') |
| 448 | dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb' |
| 449 | dtb_path = self.extract_from_deb(deb_path, dtb_path) |
| 450 | initrd_url = ('https://github.com/groeck/linux-build-test/raw/' |
| 451 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' |
| 452 | 'arm/rootfs-armv5.cpio.gz') |
| 453 | initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b' |
| 454 | initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) |
| 455 | initrd_path = os.path.join(self.workdir, 'rootfs.cpio') |
| 456 | archive.gzip_uncompress(initrd_path_gz, initrd_path) |
| 457 | |
| 458 | self.vm.set_console() |
| 459 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
| 460 | 'console=ttyS0,115200 ' |
| 461 | 'usbcore.nousb ' |
| 462 | 'panic=-1 noreboot') |
| 463 | self.vm.add_args('-kernel', kernel_path, |
| 464 | '-dtb', dtb_path, |
| 465 | '-initrd', initrd_path, |
| 466 | '-append', kernel_command_line, |
| 467 | '-no-reboot') |
| 468 | self.vm.launch() |
| 469 | self.wait_for_console_pattern('Boot successful.') |
| 470 | |
| 471 | exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', |
| 472 | 'Allwinner sun4i/sun5i') |
| 473 | exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', |
| 474 | 'system-control@1c00000') |
| 475 | exec_command_and_wait_for_pattern(self, 'reboot', |
| 476 | 'reboot: Restarting system') |
| 477 | |
Philippe Mathieu-Daudé | e33ee30 | 2020-01-17 14:09:30 +0000 | [diff] [blame] | 478 | def test_arm_cubieboard_sata(self): |
| 479 | """ |
| 480 | :avocado: tags=arch:arm |
| 481 | :avocado: tags=machine:cubieboard |
| 482 | """ |
| 483 | deb_url = ('https://apt.armbian.com/pool/main/l/' |
| 484 | 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') |
| 485 | deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' |
| 486 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
| 487 | kernel_path = self.extract_from_deb(deb_path, |
| 488 | '/boot/vmlinuz-4.20.7-sunxi') |
| 489 | dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb' |
| 490 | dtb_path = self.extract_from_deb(deb_path, dtb_path) |
| 491 | rootfs_url = ('https://github.com/groeck/linux-build-test/raw/' |
| 492 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' |
| 493 | 'arm/rootfs-armv5.ext2.gz') |
| 494 | rootfs_hash = '093e89d2b4d982234bf528bc9fb2f2f17a9d1f93' |
| 495 | rootfs_path_gz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash) |
| 496 | rootfs_path = os.path.join(self.workdir, 'rootfs.cpio') |
| 497 | archive.gzip_uncompress(rootfs_path_gz, rootfs_path) |
| 498 | |
| 499 | self.vm.set_console() |
| 500 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
| 501 | 'console=ttyS0,115200 ' |
| 502 | 'usbcore.nousb ' |
| 503 | 'root=/dev/sda ro ' |
| 504 | 'panic=-1 noreboot') |
| 505 | self.vm.add_args('-kernel', kernel_path, |
| 506 | '-dtb', dtb_path, |
| 507 | '-drive', 'if=none,format=raw,id=disk0,file=' |
| 508 | + rootfs_path, |
| 509 | '-device', 'ide-hd,bus=ide.0,drive=disk0', |
| 510 | '-append', kernel_command_line, |
| 511 | '-no-reboot') |
| 512 | self.vm.launch() |
| 513 | self.wait_for_console_pattern('Boot successful.') |
| 514 | |
| 515 | exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', |
| 516 | 'Allwinner sun4i/sun5i') |
| 517 | exec_command_and_wait_for_pattern(self, 'cat /proc/partitions', |
| 518 | 'sda') |
| 519 | exec_command_and_wait_for_pattern(self, 'reboot', |
| 520 | 'reboot: Restarting system') |
| 521 | |
Philippe Mathieu-Daudé | 5abe9f0 | 2020-03-11 23:18:49 +0100 | [diff] [blame] | 522 | def test_arm_orangepi(self): |
| 523 | """ |
| 524 | :avocado: tags=arch:arm |
| 525 | :avocado: tags=machine:orangepi-pc |
| 526 | """ |
| 527 | deb_url = ('https://apt.armbian.com/pool/main/l/' |
| 528 | 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') |
| 529 | deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' |
| 530 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
| 531 | kernel_path = self.extract_from_deb(deb_path, |
| 532 | '/boot/vmlinuz-4.20.7-sunxi') |
| 533 | dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb' |
| 534 | dtb_path = self.extract_from_deb(deb_path, dtb_path) |
| 535 | |
| 536 | self.vm.set_console() |
| 537 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
| 538 | 'console=ttyS0,115200n8 ' |
| 539 | 'earlycon=uart,mmio32,0x1c28000') |
| 540 | self.vm.add_args('-kernel', kernel_path, |
| 541 | '-dtb', dtb_path, |
| 542 | '-append', kernel_command_line) |
| 543 | self.vm.launch() |
| 544 | console_pattern = 'Kernel command line: %s' % kernel_command_line |
| 545 | self.wait_for_console_pattern(console_pattern) |
| 546 | |
Philippe Mathieu-Daudé | c40b1de | 2020-03-11 23:18:50 +0100 | [diff] [blame] | 547 | def test_arm_orangepi_initrd(self): |
| 548 | """ |
| 549 | :avocado: tags=arch:arm |
| 550 | :avocado: tags=machine:orangepi-pc |
| 551 | """ |
| 552 | deb_url = ('https://apt.armbian.com/pool/main/l/' |
| 553 | 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') |
| 554 | deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' |
| 555 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
| 556 | kernel_path = self.extract_from_deb(deb_path, |
| 557 | '/boot/vmlinuz-4.20.7-sunxi') |
| 558 | dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb' |
| 559 | dtb_path = self.extract_from_deb(deb_path, dtb_path) |
| 560 | initrd_url = ('https://github.com/groeck/linux-build-test/raw/' |
| 561 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' |
| 562 | 'arm/rootfs-armv7a.cpio.gz') |
| 563 | initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c' |
| 564 | initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) |
| 565 | initrd_path = os.path.join(self.workdir, 'rootfs.cpio') |
| 566 | archive.gzip_uncompress(initrd_path_gz, initrd_path) |
| 567 | |
| 568 | self.vm.set_console() |
| 569 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
| 570 | 'console=ttyS0,115200 ' |
| 571 | 'panic=-1 noreboot') |
| 572 | self.vm.add_args('-kernel', kernel_path, |
| 573 | '-dtb', dtb_path, |
| 574 | '-initrd', initrd_path, |
| 575 | '-append', kernel_command_line, |
| 576 | '-no-reboot') |
| 577 | self.vm.launch() |
| 578 | self.wait_for_console_pattern('Boot successful.') |
| 579 | |
| 580 | exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', |
| 581 | 'Allwinner sun8i Family') |
| 582 | exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', |
| 583 | 'system-control@1c00000') |
| 584 | exec_command_and_wait_for_pattern(self, 'reboot', |
| 585 | 'reboot: Restarting system') |
| 586 | |
Philippe Mathieu-Daudé | de2749b | 2020-03-11 23:18:51 +0100 | [diff] [blame] | 587 | def test_arm_orangepi_sd(self): |
| 588 | """ |
| 589 | :avocado: tags=arch:arm |
| 590 | :avocado: tags=machine:orangepi-pc |
| 591 | """ |
| 592 | deb_url = ('https://apt.armbian.com/pool/main/l/' |
| 593 | 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') |
| 594 | deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' |
| 595 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
| 596 | kernel_path = self.extract_from_deb(deb_path, |
| 597 | '/boot/vmlinuz-4.20.7-sunxi') |
| 598 | dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb' |
| 599 | dtb_path = self.extract_from_deb(deb_path, dtb_path) |
| 600 | rootfs_url = ('http://storage.kernelci.org/images/rootfs/buildroot/' |
| 601 | 'kci-2019.02/armel/base/rootfs.ext2.xz') |
| 602 | rootfs_hash = '692510cb625efda31640d1de0a8d60e26040f061' |
| 603 | rootfs_path_xz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash) |
| 604 | rootfs_path = os.path.join(self.workdir, 'rootfs.cpio') |
| 605 | archive.lzma_uncompress(rootfs_path_xz, rootfs_path) |
| 606 | |
| 607 | self.vm.set_console() |
| 608 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
| 609 | 'console=ttyS0,115200 ' |
| 610 | 'root=/dev/mmcblk0 rootwait rw ' |
| 611 | 'panic=-1 noreboot') |
| 612 | self.vm.add_args('-kernel', kernel_path, |
| 613 | '-dtb', dtb_path, |
| 614 | '-drive', 'file=' + rootfs_path + ',if=sd,format=raw', |
| 615 | '-append', kernel_command_line, |
| 616 | '-no-reboot') |
| 617 | self.vm.launch() |
| 618 | shell_ready = "/bin/sh: can't access tty; job control turned off" |
| 619 | self.wait_for_console_pattern(shell_ready) |
| 620 | |
| 621 | exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', |
| 622 | 'Allwinner sun8i Family') |
| 623 | exec_command_and_wait_for_pattern(self, 'cat /proc/partitions', |
| 624 | 'mmcblk0') |
| 625 | exec_command_and_wait_for_pattern(self, 'ifconfig eth0 up', |
| 626 | 'eth0: Link is Up') |
| 627 | exec_command_and_wait_for_pattern(self, 'udhcpc eth0', |
| 628 | 'udhcpc: lease of 10.0.2.15 obtained') |
| 629 | exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2', |
| 630 | '3 packets transmitted, 3 packets received, 0% packet loss') |
| 631 | exec_command_and_wait_for_pattern(self, 'reboot', |
| 632 | 'reboot: Restarting system') |
| 633 | |
Philippe Mathieu-Daudé | 784b879 | 2020-03-11 23:18:52 +0100 | [diff] [blame] | 634 | @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') |
| 635 | @skipUnless(P7ZIP_AVAILABLE, '7z not installed') |
| 636 | def test_arm_orangepi_bionic(self): |
| 637 | """ |
| 638 | :avocado: tags=arch:arm |
| 639 | :avocado: tags=machine:orangepi-pc |
| 640 | """ |
| 641 | |
| 642 | # This test download a 196MB compressed image and expand it to 932MB... |
| 643 | image_url = ('https://dl.armbian.com/orangepipc/archive/' |
| 644 | 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z') |
| 645 | image_hash = '196a8ffb72b0123d92cea4a070894813d305c71e' |
| 646 | image_path_7z = self.fetch_asset(image_url, asset_hash=image_hash) |
| 647 | image_name = 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img' |
| 648 | image_path = os.path.join(self.workdir, image_name) |
| 649 | process.run("7z e -o%s %s" % (self.workdir, image_path_7z)) |
| 650 | |
| 651 | self.vm.set_console() |
| 652 | self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw', |
| 653 | '-nic', 'user', |
| 654 | '-no-reboot') |
| 655 | self.vm.launch() |
| 656 | |
| 657 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
| 658 | 'console=ttyS0,115200 ' |
| 659 | 'loglevel=7 ' |
| 660 | 'nosmp ' |
| 661 | 'systemd.default_timeout_start_sec=9000 ' |
| 662 | 'systemd.mask=armbian-zram-config.service ' |
| 663 | 'systemd.mask=armbian-ramlog.service') |
| 664 | |
| 665 | self.wait_for_console_pattern('U-Boot SPL') |
| 666 | self.wait_for_console_pattern('Autoboot in ') |
| 667 | exec_command_and_wait_for_pattern(self, ' ', '=>') |
| 668 | exec_command_and_wait_for_pattern(self, "setenv extraargs '" + |
| 669 | kernel_command_line + "'", '=>') |
| 670 | exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...'); |
| 671 | |
| 672 | self.wait_for_console_pattern('systemd[1]: Set hostname ' + |
| 673 | 'to <orangepipc>') |
| 674 | self.wait_for_console_pattern('Starting Load Kernel Modules...') |
| 675 | |
Philippe Mathieu-Daudé | 921589f | 2020-03-11 23:18:53 +0100 | [diff] [blame] | 676 | @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') |
| 677 | def test_arm_orangepi_uboot_netbsd9(self): |
| 678 | """ |
| 679 | :avocado: tags=arch:arm |
| 680 | :avocado: tags=machine:orangepi-pc |
| 681 | """ |
| 682 | # This test download a 304MB compressed image and expand it to 1.3GB... |
| 683 | deb_url = ('http://snapshot.debian.org/archive/debian/' |
| 684 | '20200108T145233Z/pool/main/u/u-boot/' |
| 685 | 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb') |
| 686 | deb_hash = 'f67f404a80753ca3d1258f13e38f2b060e13db99' |
| 687 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
| 688 | # We use the common OrangePi PC 'plus' build of U-Boot for our secondary |
| 689 | # program loader (SPL). We will then set the path to the more specific |
| 690 | # OrangePi "PC" device tree blob with 'setenv fdtfile' in U-Boot prompt, |
| 691 | # before to boot NetBSD. |
| 692 | uboot_path = '/usr/lib/u-boot/orangepi_plus/u-boot-sunxi-with-spl.bin' |
| 693 | uboot_path = self.extract_from_deb(deb_path, uboot_path) |
| 694 | image_url = ('https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/' |
| 695 | 'evbarm-earmv7hf/binary/gzimg/armv7.img.gz') |
| 696 | image_hash = '2babb29d36d8360adcb39c09e31060945259917a' |
| 697 | image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash) |
| 698 | image_path = os.path.join(self.workdir, 'armv7.img') |
| 699 | image_drive_args = 'if=sd,format=raw,snapshot=on,file=' + image_path |
| 700 | archive.gzip_uncompress(image_path_gz, image_path) |
| 701 | |
| 702 | # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 conv=notrunc |
| 703 | with open(uboot_path, 'rb') as f_in: |
| 704 | with open(image_path, 'r+b') as f_out: |
| 705 | f_out.seek(8 * 1024) |
| 706 | shutil.copyfileobj(f_in, f_out) |
| 707 | |
| 708 | # Extend image, to avoid that NetBSD thinks the partition |
| 709 | # inside the image is larger than device size itself |
| 710 | f_out.seek(0, 2) |
| 711 | f_out.seek(64 * 1024 * 1024, 1) |
| 712 | f_out.write(bytearray([0x00])) |
| 713 | |
| 714 | self.vm.set_console() |
| 715 | self.vm.add_args('-nic', 'user', |
| 716 | '-drive', image_drive_args, |
| 717 | '-global', 'allwinner-rtc.base-year=2000', |
| 718 | '-no-reboot') |
| 719 | self.vm.launch() |
| 720 | wait_for_console_pattern(self, 'U-Boot 2020.01+dfsg-1') |
| 721 | interrupt_interactive_console_until_pattern(self, |
| 722 | 'Hit any key to stop autoboot:', |
| 723 | 'switch to partitions #0, OK') |
| 724 | |
| 725 | exec_command_and_wait_for_pattern(self, '', '=>') |
| 726 | cmd = 'setenv bootargs root=ld0a' |
| 727 | exec_command_and_wait_for_pattern(self, cmd, '=>') |
| 728 | cmd = 'setenv kernel netbsd-GENERIC.ub' |
| 729 | exec_command_and_wait_for_pattern(self, cmd, '=>') |
| 730 | cmd = 'setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb' |
| 731 | exec_command_and_wait_for_pattern(self, cmd, '=>') |
| 732 | cmd = ("setenv bootcmd 'fatload mmc 0:1 ${kernel_addr_r} ${kernel}; " |
| 733 | "fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; " |
| 734 | "fdt addr ${fdt_addr_r}; " |
| 735 | "bootm ${kernel_addr_r} - ${fdt_addr_r}'") |
| 736 | exec_command_and_wait_for_pattern(self, cmd, '=>') |
| 737 | |
| 738 | exec_command_and_wait_for_pattern(self, 'boot', |
| 739 | 'Booting kernel from Legacy Image') |
| 740 | wait_for_console_pattern(self, 'Starting kernel ...') |
| 741 | wait_for_console_pattern(self, 'NetBSD 9.0 (GENERIC)') |
| 742 | # Wait for user-space |
| 743 | wait_for_console_pattern(self, 'Starting root file system check') |
| 744 | |
Cleber Rosa | 7918249 | 2019-03-12 13:18:23 -0400 | [diff] [blame] | 745 | def test_s390x_s390_ccw_virtio(self): |
| 746 | """ |
| 747 | :avocado: tags=arch:s390x |
Cleber Rosa | ba21bde | 2019-11-04 10:13:18 -0500 | [diff] [blame] | 748 | :avocado: tags=machine:s390-ccw-virtio |
Cleber Rosa | 7918249 | 2019-03-12 13:18:23 -0400 | [diff] [blame] | 749 | """ |
Cleber Rosa | 93bbbdf | 2019-09-03 20:52:18 -0400 | [diff] [blame] | 750 | kernel_url = ('https://archives.fedoraproject.org/pub/archive' |
| 751 | '/fedora-secondary/releases/29/Everything/s390x/os/images' |
| 752 | '/kernel.img') |
Cleber Rosa | 7918249 | 2019-03-12 13:18:23 -0400 | [diff] [blame] | 753 | kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313' |
| 754 | kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) |
| 755 | |
Cleber Rosa | 7918249 | 2019-03-12 13:18:23 -0400 | [diff] [blame] | 756 | self.vm.set_console() |
| 757 | kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0' |
| 758 | self.vm.add_args('-nodefaults', |
| 759 | '-kernel', kernel_path, |
| 760 | '-append', kernel_command_line) |
| 761 | self.vm.launch() |
| 762 | console_pattern = 'Kernel command line: %s' % kernel_command_line |
| 763 | self.wait_for_console_pattern(console_pattern) |
Cleber Rosa | b36b593 | 2019-03-12 13:18:24 -0400 | [diff] [blame] | 764 | |
| 765 | def test_alpha_clipper(self): |
| 766 | """ |
| 767 | :avocado: tags=arch:alpha |
| 768 | :avocado: tags=machine:clipper |
| 769 | """ |
| 770 | kernel_url = ('http://archive.debian.org/debian/dists/lenny/main/' |
| 771 | 'installer-alpha/current/images/cdrom/vmlinuz') |
| 772 | kernel_hash = '3a943149335529e2ed3e74d0d787b85fb5671ba3' |
| 773 | kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) |
| 774 | |
| 775 | uncompressed_kernel = archive.uncompress(kernel_path, self.workdir) |
| 776 | |
Cleber Rosa | b36b593 | 2019-03-12 13:18:24 -0400 | [diff] [blame] | 777 | self.vm.set_console() |
| 778 | kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' |
Philippe Mathieu-Daudé | 1d77f1b | 2020-01-29 22:23:42 +0100 | [diff] [blame] | 779 | self.vm.add_args('-nodefaults', |
Cleber Rosa | b36b593 | 2019-03-12 13:18:24 -0400 | [diff] [blame] | 780 | '-kernel', uncompressed_kernel, |
| 781 | '-append', kernel_command_line) |
| 782 | self.vm.launch() |
| 783 | console_pattern = 'Kernel command line: %s' % kernel_command_line |
| 784 | self.wait_for_console_pattern(console_pattern) |
Cleber Rosa | 83fa3bc | 2019-06-07 11:22:19 -0400 | [diff] [blame] | 785 | |
| 786 | def test_ppc64_pseries(self): |
| 787 | """ |
| 788 | :avocado: tags=arch:ppc64 |
| 789 | :avocado: tags=machine:pseries |
| 790 | """ |
Cleber Rosa | 93bbbdf | 2019-09-03 20:52:18 -0400 | [diff] [blame] | 791 | kernel_url = ('https://archives.fedoraproject.org/pub/archive' |
| 792 | '/fedora-secondary/releases/29/Everything/ppc64le/os' |
| 793 | '/ppc/ppc64/vmlinuz') |
Cleber Rosa | 83fa3bc | 2019-06-07 11:22:19 -0400 | [diff] [blame] | 794 | kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77' |
| 795 | kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) |
| 796 | |
Cleber Rosa | 83fa3bc | 2019-06-07 11:22:19 -0400 | [diff] [blame] | 797 | self.vm.set_console() |
| 798 | kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0' |
| 799 | self.vm.add_args('-kernel', kernel_path, |
| 800 | '-append', kernel_command_line) |
| 801 | self.vm.launch() |
| 802 | console_pattern = 'Kernel command line: %s' % kernel_command_line |
| 803 | self.wait_for_console_pattern(console_pattern) |
Philippe Mathieu-Daudé | f7d8552 | 2019-10-26 18:45:46 +0200 | [diff] [blame] | 804 | |
| 805 | def test_m68k_q800(self): |
| 806 | """ |
| 807 | :avocado: tags=arch:m68k |
| 808 | :avocado: tags=machine:q800 |
| 809 | """ |
Philippe Mathieu-Daudé | f44b554 | 2019-11-26 23:38:09 +0100 | [diff] [blame] | 810 | deb_url = ('https://snapshot.debian.org/archive/debian-ports' |
| 811 | '/20191021T083923Z/pool-m68k/main' |
Cleber Rosa | 2ecde8b | 2019-10-29 19:23:20 -0400 | [diff] [blame] | 812 | '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb') |
| 813 | deb_hash = '044954bb9be4160a3ce81f8bc1b5e856b75cccd1' |
Philippe Mathieu-Daudé | b67d22a | 2019-11-26 23:38:10 +0100 | [diff] [blame] | 814 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
Philippe Mathieu-Daudé | f7d8552 | 2019-10-26 18:45:46 +0200 | [diff] [blame] | 815 | kernel_path = self.extract_from_deb(deb_path, |
Cleber Rosa | 2ecde8b | 2019-10-29 19:23:20 -0400 | [diff] [blame] | 816 | '/boot/vmlinux-5.3.0-1-m68k') |
Philippe Mathieu-Daudé | f7d8552 | 2019-10-26 18:45:46 +0200 | [diff] [blame] | 817 | |
Philippe Mathieu-Daudé | f7d8552 | 2019-10-26 18:45:46 +0200 | [diff] [blame] | 818 | self.vm.set_console() |
| 819 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
| 820 | 'console=ttyS0 vga=off') |
| 821 | self.vm.add_args('-kernel', kernel_path, |
| 822 | '-append', kernel_command_line) |
| 823 | self.vm.launch() |
| 824 | console_pattern = 'Kernel command line: %s' % kernel_command_line |
| 825 | self.wait_for_console_pattern(console_pattern) |
| 826 | console_pattern = 'No filesystem could mount root' |
| 827 | self.wait_for_console_pattern(console_pattern) |
Thomas Huth | b0065e1 | 2020-01-24 18:03:25 +0100 | [diff] [blame] | 828 | |
| 829 | def do_test_advcal_2018(self, day, tar_hash, kernel_name): |
| 830 | tar_url = ('https://www.qemu-advent-calendar.org' |
| 831 | '/2018/download/day' + day + '.tar.xz') |
| 832 | file_path = self.fetch_asset(tar_url, asset_hash=tar_hash) |
| 833 | archive.extract(file_path, self.workdir) |
| 834 | self.vm.set_console() |
| 835 | self.vm.add_args('-kernel', |
| 836 | self.workdir + '/day' + day + '/' + kernel_name) |
| 837 | self.vm.launch() |
| 838 | self.wait_for_console_pattern('QEMU advent calendar') |
| 839 | |
| 840 | def test_arm_vexpressa9(self): |
| 841 | """ |
| 842 | :avocado: tags=arch:arm |
| 843 | :avocado: tags=machine:vexpress-a9 |
| 844 | """ |
| 845 | tar_hash = '32b7677ce8b6f1471fb0059865f451169934245b' |
| 846 | self.vm.add_args('-dtb', self.workdir + '/day16/vexpress-v2p-ca9.dtb') |
| 847 | self.do_test_advcal_2018('16', tar_hash, 'winter.zImage') |
| 848 | |
| 849 | def test_m68k_mcf5208evb(self): |
| 850 | """ |
| 851 | :avocado: tags=arch:m68k |
| 852 | :avocado: tags=machine:mcf5208evb |
| 853 | """ |
| 854 | tar_hash = 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c' |
| 855 | self.do_test_advcal_2018('07', tar_hash, 'sanity-clause.elf') |
| 856 | |
| 857 | def test_microblaze_s3adsp1800(self): |
| 858 | """ |
| 859 | :avocado: tags=arch:microblaze |
| 860 | :avocado: tags=machine:petalogix-s3adsp1800 |
| 861 | """ |
| 862 | tar_hash = '08bf3e3bfb6b6c7ce1e54ab65d54e189f2caf13f' |
| 863 | self.do_test_advcal_2018('17', tar_hash, 'ballerina.bin') |
| 864 | |
| 865 | def test_or1k_sim(self): |
| 866 | """ |
| 867 | :avocado: tags=arch:or1k |
| 868 | :avocado: tags=machine:or1k-sim |
| 869 | """ |
| 870 | tar_hash = '20334cdaf386108c530ff0badaecc955693027dd' |
| 871 | self.do_test_advcal_2018('20', tar_hash, 'vmlinux') |
| 872 | |
| 873 | def test_nios2_10m50(self): |
| 874 | """ |
| 875 | :avocado: tags=arch:nios2 |
| 876 | :avocado: tags=machine:10m50-ghrd |
| 877 | """ |
| 878 | tar_hash = 'e4251141726c412ac0407c5a6bceefbbff018918' |
| 879 | self.do_test_advcal_2018('14', tar_hash, 'vmlinux.elf') |
| 880 | |
| 881 | def test_ppc64_e500(self): |
| 882 | """ |
| 883 | :avocado: tags=arch:ppc64 |
| 884 | :avocado: tags=machine:ppce500 |
| 885 | """ |
| 886 | tar_hash = '6951d86d644b302898da2fd701739c9406527fe1' |
| 887 | self.vm.add_args('-cpu', 'e5500') |
| 888 | self.do_test_advcal_2018('19', tar_hash, 'uImage') |
| 889 | |
| 890 | def test_ppc_g3beige(self): |
| 891 | """ |
| 892 | :avocado: tags=arch:ppc |
| 893 | :avocado: tags=machine:g3beige |
| 894 | """ |
| 895 | tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc' |
| 896 | self.vm.add_args('-M', 'graphics=off') |
| 897 | self.do_test_advcal_2018('15', tar_hash, 'invaders.elf') |
| 898 | |
| 899 | def test_ppc_mac99(self): |
| 900 | """ |
| 901 | :avocado: tags=arch:ppc |
| 902 | :avocado: tags=machine:mac99 |
| 903 | """ |
| 904 | tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc' |
| 905 | self.vm.add_args('-M', 'graphics=off') |
| 906 | self.do_test_advcal_2018('15', tar_hash, 'invaders.elf') |
| 907 | |
| 908 | def test_sparc_ss20(self): |
| 909 | """ |
| 910 | :avocado: tags=arch:sparc |
| 911 | :avocado: tags=machine:SS-20 |
| 912 | """ |
| 913 | tar_hash = 'b18550d5d61c7615d989a06edace051017726a9f' |
| 914 | self.do_test_advcal_2018('11', tar_hash, 'zImage.elf') |
| 915 | |
| 916 | def test_xtensa_lx60(self): |
| 917 | """ |
| 918 | :avocado: tags=arch:xtensa |
| 919 | :avocado: tags=machine:lx60 |
| 920 | """ |
| 921 | tar_hash = '49e88d9933742f0164b60839886c9739cb7a0d34' |
| 922 | self.vm.add_args('-cpu', 'dc233c') |
| 923 | self.do_test_advcal_2018('02', tar_hash, 'santas-sleigh-ride.elf') |