summaryrefslogtreecommitdiff
diff options
authorPMR <pmr@pmr-lander>2020-01-30 08:38:17 +0000
committerPMR <pmr@pmr-lander>2020-01-30 08:38:17 +0000
commit83b3db8612c6c1e2da42d5106b44f03d6fa22ead (patch)
treefb3eb4ea7c441fe3566c9c95caef4d624af7a0ed
parent51cf09675bd1c5f1cab2869e08a9e8e57be36208 (diff)
parentef098d4eb81e3d62336f9c165e82ca0ca39e5fb6 (diff)
Merge #372737 from ~rodsmith/plainbox-provider-checkbox:add-firmware-reboot-test
Add a test to see if the firmware claims support for the EFI reboot-to-firmware-setup feature, which is present in most new UEFIs.
-rwxr-xr-xbin/boot_mode_test45
-rw-r--r--units/miscellanea/jobs.pxu12
-rw-r--r--units/miscellanea/test-plan.pxu1
3 files changed, 48 insertions, 10 deletions
diff --git a/bin/boot_mode_test b/bin/boot_mode_test
index 7c9358c..e51a099 100755
--- a/bin/boot_mode_test
+++ b/bin/boot_mode_test
@@ -26,19 +26,16 @@ import logging
from argparse import ArgumentParser
-def version_check(check):
- """Check the installed Ubuntu version to see if it is older than 16.04
- (Xenial) and run the requested check
+def do_tests(check):
+ """Dispatcher for the requested tests.
:returns:
- 0 if if the installed version is older than 16.04 regardless of return
- code from the requested check
-
- return code from requested check if the installed version is 16.04 or
- newer.
+ return code from requested check.
"""
if check == 'efi':
return efi_boot_check()
+ elif check == 'reboot_firmware':
+ return reboot_to_firmware_check()
else:
return secure_boot_check()
@@ -59,6 +56,33 @@ def efi_boot_check():
return 1
+def reboot_to_firmware_check():
+ """Test that the computer supports the reboot-to-firmware feature.
+
+ :returns:
+ 0 if the feature IS supported (pass)
+ 1 if the feature is NOT supported (fail)
+ """
+ osis_dir = "/sys/firmware/efi/efivars/"
+ osis_var = osis_dir + \
+ "OsIndicationsSupported-8be4df61-93ca-11d2-aa0d-00e098032b8c"
+ if os.path.isdir(osis_dir):
+ if os.path.isfile(osis_var):
+ fw_info = open(osis_var).read()
+ if ord(fw_info[4]) & 1:
+ logging.info("PASS: Reboot-to-firmware feature is present.")
+ return 0
+ else:
+ logging.error("FAIL: Reboot-to-firmware feature is missing.")
+ return 1
+ else:
+ logging.info("FAIL: OsIndicationsSupported variable not present.")
+ return 1
+ else:
+ logging.info("FAIL: System did NOT boot in EFI mode.")
+ return 1
+
+
def secure_boot_check():
"""Test that the computer booted with Secure Boot active.
@@ -97,13 +121,14 @@ def secure_boot_check():
def main():
parser = ArgumentParser()
parser.add_argument('check',
- choices=['efi', 'secureboot'],
+ choices=['efi', 'secureboot', 'reboot_firmware'],
help='The type of check to perform')
args = parser.parse_args()
FORMAT = '%(levelname)s: %(message)s'
logging.basicConfig(level=logging.INFO, format=FORMAT)
- return version_check(args.check)
+ return do_tests(args.check)
+
if __name__ == '__main__':
sys.exit(main())
diff --git a/units/miscellanea/jobs.pxu b/units/miscellanea/jobs.pxu
index 1f008cb..ebc7c4d 100644
--- a/units/miscellanea/jobs.pxu
+++ b/units/miscellanea/jobs.pxu
@@ -150,6 +150,18 @@ command: boot_mode_test secureboot
plugin: shell
category_id: com.canonical.plainbox::miscellanea
estimated_duration: 0.5
+id: miscellanea/reboot_firmware
+requires:
+ cpuinfo.platform in ("i386", "x86_64", "aarch64")
+depends: miscellanea/efi_boot_mode
+_summary: Test that system supports booting into firmware setup utility
+_description:
+ Test that the system supports rebooting into the firmware setup utility.
+command: boot_mode_test reboot_firmware
+
+plugin: shell
+category_id: com.canonical.plainbox::miscellanea
+estimated_duration: 0.5
unit: template
template-resource: model_assertion
template-unit: job
diff --git a/units/miscellanea/test-plan.pxu b/units/miscellanea/test-plan.pxu
index 94bb410..b202727 100644
--- a/units/miscellanea/test-plan.pxu
+++ b/units/miscellanea/test-plan.pxu
@@ -64,6 +64,7 @@ mandatory_include:
miscellanea/get_maas_version certification-status=blocker
miscellanea/efi_boot_mode certification-status=blocker
miscellanea/secure_boot_mode
+ miscellanea/reboot_firmware
miscellanea/efi_pxeboot
miscellanea/check_prerelease
miscellanea/kernel_taint_test