1 # Linux initrd acceptance test.
3 # Copyright (c) 2018 Red Hat, Inc.
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.
12 from avocado
.utils
.process
import run
14 from avocado_qemu
import Test
17 class LinuxInitrd(Test
):
19 Checks QEMU evaluates correctly the initrd file passed as -initrd option.
27 def test_with_2gib_file_should_exit_error_msg(self
):
29 Pretends to boot QEMU with an initrd file with size of 2GiB
30 and expect it exits with error message.
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
:
42 cmd
= "%s -kernel %s -initrd %s" % (self
.qemu_bin
, kernel_path
,
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.*' % (
48 self
.assertRegex(res
.stderr_text
, expected_msg
)