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