xref: /openbmc/qemu/tests/avocado/boot_linux.py (revision 6d17020a)
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 skipIf
16
17
18class BootLinuxX8664(LinuxTest):
19    """
20    :avocado: tags=arch:x86_64
21    """
22
23    def test_pc_i440fx_tcg(self):
24        """
25        :avocado: tags=machine:pc
26        :avocado: tags=accel:tcg
27        """
28        self.require_accelerator("tcg")
29        self.vm.add_args("-accel", "tcg")
30        self.launch_and_wait(set_up_ssh_connection=False)
31
32    def test_pc_i440fx_kvm(self):
33        """
34        :avocado: tags=machine:pc
35        :avocado: tags=accel:kvm
36        """
37        self.require_accelerator("kvm")
38        self.vm.add_args("-accel", "kvm")
39        self.launch_and_wait(set_up_ssh_connection=False)
40
41    def test_pc_q35_tcg(self):
42        """
43        :avocado: tags=machine:q35
44        :avocado: tags=accel:tcg
45        """
46        self.require_accelerator("tcg")
47        self.vm.add_args("-accel", "tcg")
48        self.launch_and_wait(set_up_ssh_connection=False)
49
50    def test_pc_q35_kvm(self):
51        """
52        :avocado: tags=machine:q35
53        :avocado: tags=accel:kvm
54        """
55        self.require_accelerator("kvm")
56        self.vm.add_args("-accel", "kvm")
57        self.launch_and_wait(set_up_ssh_connection=False)
58
59
60class BootLinuxAarch64(LinuxTest):
61    """
62    :avocado: tags=arch:aarch64
63    :avocado: tags=machine:virt
64    :avocado: tags=machine:gic-version=2
65    """
66
67    def add_common_args(self):
68        self.vm.add_args('-bios',
69                         os.path.join(BUILD_DIR, 'pc-bios',
70                                      'edk2-aarch64-code.fd'))
71        self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
72        self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom')
73
74    def test_virt_tcg_gicv2(self):
75        """
76        :avocado: tags=accel:tcg
77        :avocado: tags=cpu:max
78        :avocado: tags=device:gicv2
79        """
80        self.require_accelerator("tcg")
81        self.vm.add_args("-accel", "tcg")
82        self.vm.add_args("-cpu", "max,lpa2=off")
83        self.vm.add_args("-machine", "virt,gic-version=2")
84        self.add_common_args()
85        self.launch_and_wait(set_up_ssh_connection=False)
86
87    def test_virt_tcg_gicv3(self):
88        """
89        :avocado: tags=accel:tcg
90        :avocado: tags=cpu:max
91        :avocado: tags=device:gicv3
92        """
93        self.require_accelerator("tcg")
94        self.vm.add_args("-accel", "tcg")
95        self.vm.add_args("-cpu", "max,lpa2=off")
96        self.vm.add_args("-machine", "virt,gic-version=3")
97        self.add_common_args()
98        self.launch_and_wait(set_up_ssh_connection=False)
99
100    def test_virt_kvm(self):
101        """
102        :avocado: tags=accel:kvm
103        :avocado: tags=cpu:host
104        """
105        self.require_accelerator("kvm")
106        self.vm.add_args("-accel", "kvm")
107        self.vm.add_args("-machine", "virt,gic-version=host")
108        self.add_common_args()
109        self.launch_and_wait(set_up_ssh_connection=False)
110
111
112class BootLinuxPPC64(LinuxTest):
113    """
114    :avocado: tags=arch:ppc64
115    """
116
117    def test_pseries_tcg(self):
118        """
119        :avocado: tags=machine:pseries
120        :avocado: tags=accel:tcg
121        """
122        self.require_accelerator("tcg")
123        self.vm.add_args("-accel", "tcg")
124        self.launch_and_wait(set_up_ssh_connection=False)
125
126
127class BootLinuxS390X(LinuxTest):
128    """
129    :avocado: tags=arch:s390x
130    """
131
132    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
133    def test_s390_ccw_virtio_tcg(self):
134        """
135        :avocado: tags=machine:s390-ccw-virtio
136        :avocado: tags=accel:tcg
137        """
138        self.require_accelerator("tcg")
139        self.vm.add_args("-accel", "tcg")
140        self.launch_and_wait(set_up_ssh_connection=False)
141