From 79b95f1092adc1d3f646d850793568a96aa1c7bc Mon Sep 17 00:00:00 2001 From: Bastien Roucariès Date: Mon, 15 Apr 2024 14:06:23 +0000 Subject: Add ubuntu test --- debian/tests/10_uefi_boot_tests.py | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 debian/tests/10_uefi_boot_tests.py (limited to 'debian/tests/10_uefi_boot_tests.py') diff --git a/debian/tests/10_uefi_boot_tests.py b/debian/tests/10_uefi_boot_tests.py new file mode 100755 index 00000000..e2d0d293 --- /dev/null +++ b/debian/tests/10_uefi_boot_tests.py @@ -0,0 +1,51 @@ +# +# UEFI boot testing +# +# Copyright (C) 2019 Canonical, Ltd. +# Author: Mathieu Trudel-Lapierre +# +# 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 . + +import subprocess +import sys +import unittest + +from uefi_tests_base import UEFITestsBase, UEFINotAvailable, UEFIVirtualMachine + + +class UEFIBootTests(UEFITestsBase): + """ + Validate UEFI signatures for common problems + """ + @classmethod + def setUpClass(klass): + UEFITestsBase.setUpClass() + klass.base_image = UEFIVirtualMachine(arch=klass.image_arch) + #klass.base_image.prepare() + + def testCanary(self): + """Validate that a control/canary (unchanged) image boots fine""" + canary = UEFIVirtualMachine(self.base_image) + canary.run() + self.assertBoots(canary) + + def testNewShim(self): + """Validate that a new SHIM binary on the image will boot""" + new_shim = UEFIVirtualMachine(self.base_image) + new_shim.update(src='/usr/lib/shim/shimx64.efi.signed', dst='/boot/efi/EFI/ubuntu/shimx64.efi') + new_shim.update(src='/usr/lib/shim/shimx64.efi.signed', dst='/boot/efi/EFI/BOOT/BOOTX64.efi') + new_shim.run() + self.assertBoots(new_shim) + + +unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=2)) -- cgit v1.2.3 From 586dedee7253ae66fe9551e2e89432743cf8c5f9 Mon Sep 17 00:00:00 2001 From: Bastien Roucariès Date: Mon, 15 Apr 2024 14:11:26 +0000 Subject: Port to debian --- debian/tests/10_uefi_boot_tests.py | 2 +- debian/tests/uefi_tests_base.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'debian/tests/10_uefi_boot_tests.py') diff --git a/debian/tests/10_uefi_boot_tests.py b/debian/tests/10_uefi_boot_tests.py index e2d0d293..7ef4df44 100755 --- a/debian/tests/10_uefi_boot_tests.py +++ b/debian/tests/10_uefi_boot_tests.py @@ -42,7 +42,7 @@ class UEFIBootTests(UEFITestsBase): def testNewShim(self): """Validate that a new SHIM binary on the image will boot""" new_shim = UEFIVirtualMachine(self.base_image) - new_shim.update(src='/usr/lib/shim/shimx64.efi.signed', dst='/boot/efi/EFI/ubuntu/shimx64.efi') + new_shim.update(src='/usr/lib/shim/shimx64.efi.signed', dst='/boot/efi/EFI/debian/shimx64.efi') new_shim.update(src='/usr/lib/shim/shimx64.efi.signed', dst='/boot/efi/EFI/BOOT/BOOTX64.efi') new_shim.run() self.assertBoots(new_shim) diff --git a/debian/tests/uefi_tests_base.py b/debian/tests/uefi_tests_base.py index cf9d40b1..f007d741 100644 --- a/debian/tests/uefi_tests_base.py +++ b/debian/tests/uefi_tests_base.py @@ -67,7 +67,7 @@ class UEFITestsBase(unittest.TestCase): # Base paths for the ESP. klass.uefi_base_dir = os.path.join('/', 'boot', 'efi', 'EFI') klass.uefi_boot_dir = os.path.join(klass.uefi_base_dir, 'BOOT') - klass.uefi_install_dir = os.path.join(klass.uefi_base_dir, 'ubuntu') + klass.uefi_install_dir = os.path.join(klass.uefi_base_dir, 'debian') # CAs for signature validation klass.canonical_ca = os.path.join('/usr/share/grub', 'canonical-uefi-ca.crt') @@ -151,7 +151,7 @@ DEFAULT_METADATA = 'instance-id: nocloud\nlocal-hostname: autopkgtest\n' DEFAULT_USERDATA = """#cloud-config locale: en_US.UTF-8 -password: ubuntu +password: debian chpasswd: { expire: False } ssh_pwauth: True manage_etc_hosts: True @@ -173,7 +173,7 @@ class UEFIVirtualMachine(UEFITestsBase): self.path = tempfile.mkstemp(dir=self.autopkgtest_dir.name)[1] if not base: subprocess.run(['wget', - 'http://cloud-images.ubuntu.com/%s/current/%s-server-cloudimg-%s.img' + 'http://cloud.debian.org/%s/lastest/debian-%s-genericcloud-%s.img' % (self.release, self.release, self.arch), '-O', '%s/base.img' % self.autopkgtest_dir.name]) else: -- cgit v1.2.3