s390x: upgrade status of KVM cores to "supported"
[qemu/ar7.git] / tests / acceptance / linux_initrd.py
blob737355c2ef028350fb7d7926c569446cb633b637
1 # Linux initrd acceptance test.
3 # Copyright (c) 2018 Red Hat, Inc.
5 # Author:
6 # Wainer dos Santos Moschetta <wainersm@redhat.com>
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.
11 import tempfile
12 from avocado.utils.process import run
14 from avocado_qemu import Test
17 class LinuxInitrd(Test):
18 """
19 Checks QEMU evaluates correctly the initrd file passed as -initrd option.
21 :avocado: enable
22 :avocado: tags=x86_64
23 """
25 timeout = 60
27 def test_with_2gib_file_should_exit_error_msg(self):
28 """
29 Pretends to boot QEMU with an initrd file with size of 2GiB
30 and expect it exits with error message.
31 """
32 kernel_url = ('https://mirrors.kernel.org/fedora/releases/28/'
33 'Everything/x86_64/os/images/pxeboot/vmlinuz')
34 kernel_hash = '238e083e114c48200f80d889f7e32eeb2793e02a'
35 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
36 max_size = 2 * (1024 ** 3) - 1
38 with tempfile.NamedTemporaryFile() as initrd:
39 initrd.seek(max_size)
40 initrd.write(b'\0')
41 initrd.flush()
42 cmd = "%s -kernel %s -initrd %s" % (self.qemu_bin, kernel_path,
43 initrd.name)
44 res = run(cmd, ignore_status=True)
45 self.assertEqual(res.exit_status, 1)
46 expected_msg = r'.*initrd is too large.*max: \d+, need %s.*' % (
47 max_size + 1)
48 self.assertRegex(res.stderr_text, expected_msg)