xref: /openbmc/qemu/tests/avocado/boot_linux.py (revision a158c63b)
1# Functional test that boots a complete Linux system via a cloud image
2#
3# Copyright (c) 2018-2020 Red Hat, Inc.
4#
5# Author:
6#  Cleber Rosa <crosa@redhat.com>
7#
8# This work is licensed under the terms of the GNU GPL, version 2 or
9# later.  See the COPYING file in the top-level directory.
10
11import os
12
13from avocado_qemu import LinuxTest, BUILD_DIR
14
15from avocado import skipUnless
16
17
18class BootLinuxX8664(LinuxTest):
19    """
20    :avocado: tags=arch:x86_64
21    """
22    timeout = 480
23
24    def test_pc_i440fx_tcg(self):
25        """
26        :avocado: tags=machine:pc
27        :avocado: tags=accel:tcg
28        """
29        self.require_accelerator("tcg")
30        self.vm.add_args("-accel", "tcg")
31        self.launch_and_wait(set_up_ssh_connection=False)
32
33    def test_pc_i440fx_kvm(self):
34        """
35        :avocado: tags=machine:pc
36        :avocado: tags=accel:kvm
37        """
38        self.require_accelerator("kvm")
39        self.vm.add_args("-accel", "kvm")
40        self.launch_and_wait(set_up_ssh_connection=False)
41
42    def test_pc_q35_tcg(self):
43        """
44        :avocado: tags=machine:q35
45        :avocado: tags=accel:tcg
46        """
47        self.require_accelerator("tcg")
48        self.vm.add_args("-accel", "tcg")
49        self.launch_and_wait(set_up_ssh_connection=False)
50
51    def test_pc_q35_kvm(self):
52        """
53        :avocado: tags=machine:q35
54        :avocado: tags=accel:kvm
55        """
56        self.require_accelerator("kvm")
57        self.vm.add_args("-accel", "kvm")
58        self.launch_and_wait(set_up_ssh_connection=False)
59
60
61# For Aarch64 we only boot KVM tests in CI as booting the current
62# Fedora OS in TCG tests is very heavyweight. There are lighter weight
63# distros which we use in the machine_aarch64_virt.py tests.
64class BootLinuxAarch64(LinuxTest):
65    """
66    :avocado: tags=arch:aarch64
67    :avocado: tags=machine:virt
68    """
69    timeout = 720
70
71    def test_virt_kvm(self):
72        """
73        :avocado: tags=accel:kvm
74        :avocado: tags=cpu:host
75        """
76        self.require_accelerator("kvm")
77        self.vm.add_args("-accel", "kvm")
78        self.vm.add_args("-machine", "virt,gic-version=host")
79        self.vm.add_args('-bios',
80                         os.path.join(BUILD_DIR, 'pc-bios',
81                                      'edk2-aarch64-code.fd'))
82        self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
83        self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom')
84        self.launch_and_wait(set_up_ssh_connection=False)
85
86
87# See the tux_baseline.py tests for almost the same coverage in a lot
88# less time.
89class BootLinuxPPC64(LinuxTest):
90    """
91    :avocado: tags=arch:ppc64
92    """
93
94    timeout = 360
95
96    @skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited')
97    def test_pseries_tcg(self):
98        """
99        :avocado: tags=machine:pseries
100        :avocado: tags=accel:tcg
101        """
102        self.require_accelerator("tcg")
103        self.vm.add_args("-accel", "tcg")
104        self.launch_and_wait(set_up_ssh_connection=False)
105
106    def test_pseries_kvm(self):
107        """
108        :avocado: tags=machine:pseries
109        :avocado: tags=accel:kvm
110        """
111        self.require_accelerator("kvm")
112        self.vm.add_args("-accel", "kvm")
113        self.vm.add_args("-machine", "cap-ccf-assist=off")
114        self.launch_and_wait(set_up_ssh_connection=False)
115
116class BootLinuxS390X(LinuxTest):
117    """
118    :avocado: tags=arch:s390x
119    """
120
121    timeout = 240
122
123    @skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited')
124    def test_s390_ccw_virtio_tcg(self):
125        """
126        :avocado: tags=machine:s390-ccw-virtio
127        :avocado: tags=accel:tcg
128        """
129        self.require_accelerator("tcg")
130        self.vm.add_args("-accel", "tcg")
131        self.launch_and_wait(set_up_ssh_connection=False)
132