summaryrefslogtreecommitdiff
path: root/debian/tests/01_sanity_tests.py
blob: 63d98631344b205291ea478f120137ba69a1d067 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#
# UEFI Shim sanity checks for tests
#
# Copyright (C) 2019 Canonical, Ltd.
# Author: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import subprocess
import sys
import unittest

from uefi_tests_base import UEFITestsBase


class SanityTests(UEFITestsBase):
    '''
    Sanity checks for uefi tests
    '''

    def testArchitectureSuffixes(self):
        """Ensure sanity of our concept of architecture suffixes for UEFI"""

        machine = subprocess.check_output(['uname', '-m']).rstrip().decode('utf-8')
        if machine == 'x86_64':
            self.assertEqual('x64', self.arch_suffix)
            self.assertEqual('x86_64-efi', self.grub_arch)
            self.assertEqual('qemu-system-x86_64', self.qemu_arch)
        elif machine == 'aarch64':
            self.assertEqual('aa64', self.arch_suffix)
            self.assertEqual('arm64-efi', self.grub_arch)
            self.assertEqual('qemu-system-aarch64', self.qemu_arch)

    def testQemuAvailable(self):
        """Ensure QEMU is available for this architecture"""
        try:
            out = subprocess.run([self.qemu_arch, '-version'], stdout=None)
            out.check_returncode()
        except:
            raise UEFINotAvailable(feature="qemu", arch=self.arch_machine,
                                   details="%s failed to run" % self.qemu_arch)


unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=2))