Files
open-source-firmware-valida…/lib/secure-boot-lib.robot
Michał Żygowski 4f10afbdbc Odroid h4 ultra tests (#881)
* dasharo-compatibility/network-speed.robot: Move keywords to lib

The keywords are generic for network performance testing. They can
be reused by other tests, e.g. incoming ODROID netcard test.

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-compatibility/odroid-netcard.robot: Add netcard test

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-compatibility/memory-ibecc.robot: Add IBECC tests

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs: Add ODROID H4 Ultra

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-performance/fast-boot.robot: Make the test work with telnet

The test assumed that the device is already booted to an OS, which probably
is true for laptops. Add necessary Power On's and initial booting to OS
on the beginning of the test to handle a case where the serial connection
can be used to navigate and select OSes to boot.

Also do not log in to OS again after "Measure FW Boot Time On Linux",
because this keyword keeps the connection to the OS.

TEST=Run the test and PASS it on ODROID H4 Ultra

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* lib/sleep-lib.robot: Make sleep tests work with telnet

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* test_cases.json: Add new test cases

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs/odroid-h4: Do not verify FW version after flashing

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* compatibility/custom-network-boot-entries.robot: Ensure netboot is enabled

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs/odroid-h4: Add CPU temperature threshold

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs/odroid-h4: Update release date

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* variables.robot: Fix the configs for ODROID platforms

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-compatibility/miniPCIe-slot-verification.robot: Fix skip

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-compatibility/nvme-support.robot: Use configs to get disk name

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs: Drop unused CLEVO_DISK

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs/odroid-h4: Synchronize configs

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs/odroid-h4: Enable Windows tests

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* os-config/ansible/os-specific-tasks/201.yaml: Add docker installation

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* scripts/lib/robot.sh: Fix typo in directory name

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs/odroid-h4: Disable fan speed measurements

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* lib/usb-hid-msc-lib.robot: Fix condition for mounting USB

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* compatibility/device-detection.robot: Close connections at the end of teardown

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* compatibility/device-detection.robot: Add proper checks for suite skip

Judging by the content of test cases, the suite depends on the
SSH connection method and the DCU backed for option manipulation.
It is not suitable for runnign in other configuration, like
telnet connection method and option management via firmware setup.

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs/odroid-h4: Update release version

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* compatibility/efibootmgr.robot: Make test suitable for telnet platforms

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* keywords.robot: Wait for the power to stabilize before pressing power button

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* util/basic-platform-setup.robot: Mark suite as automated

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* test_cases.json: Sort new tests by ID

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* compatibility/audio-subsystem.robot: Use generic keyword for command

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* compatibility/cpu-fan-speed-measure.robot: Skip suite earlier to save time

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* lib/network.robot: Make intervals larger for Get Hostname Ip

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs/odroid-h4: Disable hybrid core support

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* lib/network.robot: Add variable for Get Ip interval

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* scripts/regression-rerun-failed.sh: Add script to rerun failed tests

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* compatibility/efibootmgr.robot: Ensure network boot is disabled initially

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs/odroid-h4: Fix CPU temperature threshold

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* lib/power-after-fail-lib.robot: Fix import failure

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* compatibility/reset-to-defaults.robot: Skip fan profile test if not supported

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* compatibility/platform-suspend-and-resume.robot: Check for skip in suite setup

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* compatibility/reset-to-defaults.robot: Skip sleep type test if not supported

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* Deploy UEFI Shell where necessary

Basic platform setup deploye UEFI SHell, however running a whole
suite like comaptibility, e.g. during regression, causes the FW
to eb flashed again and the UEFI Shell is lost right after basic
platform setup finishes its job.

Ensure the UEFI Shell is deployed wherever it is used.

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* lib/esp-scanning-lib.robot: Sync filesystem after cleaning ESP

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-compatibility/DTS: Skip flashing if FW variable not set

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-compatibility/dasharo-tools-suite.robot: Fix internal flashing

"Flash Via Internal Programmer" sends a file to DUT from host. However,
the test downloads th binary with wget prior to the keyword execution.
Skip the wrapper and call "Flash Via Internal Programmer With Args"
directly.

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-security/tpm: Fix TPM tests

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-security/verified-boot.robot: Sync filesystem before power cycling

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-compatibility/audio-subsystem.robot: Fix headphones Windows tests

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-compatibility/audio-subsystem.robot: Make audo devices platform-specific

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* lib/bios/menus.robot: Fix variable type

Fixes the error of variable value not a list or list-like.

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-security/verified-boot.robot: Drop VBO011.001 duplication

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* lib/sleep-lib.robot: Fix suspend test on Telnet

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs/odroid-h4: Remove obsolete override

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* scripts/regression.sh: Run stability suite too

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs/odroid-h4-ultra.robot: Sync DTS E2E variables

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs/odroid-h4: Sync DMI info

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-stability/tpm-detect.robot: Drop check for NVME in TPM detection

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-compatibility/power-after-fail.robot: Fix powering on based on var state

When power after fail test are executed, the state of power after fail variable
is changed. The Power On keyword does not take it int oaccount and uses only
the default state of the variable. This results in obsolete power button presses
which often lead to powering off the platform right after PSU is powered on.
Because of that the tests fail due to power LED not being lit up.

Define another variable that is updated runtime and represents current state of
the power after faile variable.

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* keywords: Fix usage in teardown

Fixes the problem: 'Set Tags' cannot be used in suite teardown.

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-compatibility: Fix list comparison in Ethernet tests

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs/odroid-h4-ultra.robot: Update Ethernet info

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* util/basic-platform-setup.robot: Add minimal-regression tag

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* lib/secure-boot-lib.robot: Fix launching UEFI Shell

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* lib/linux.robot: Add MKTME to dmesg error allowlist

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* variables.robot: Add ODROID H4 Ultra

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-compatibility: Move netcard test to ETHPERF

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-compatibility/network-speed.robot: merge netcard test with ETHPERF001

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* dasharo-compatibility/device-detection.robot: Fix duplicated close connection

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

* platform-configs: Drop unused ODROID_NETCARD_SUPPORT

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>

---------

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
2025-09-24 07:47:30 +02:00

279 lines
13 KiB
Plaintext

*** Settings ***
Documentation Collection of keywords related to UEFI Secure Boot
Resource ../keywords.robot
*** Variables ***
${GOOD_KEYS_URL}= https://cloud.3mdeb.com/index.php/s/SjM5dQGji4XDAni/download/good_keys.img
${GOOD_KEYS_NAME}= good_keys.img
${GOOD_KEYS_SHA256}= 13de737ba50c8d14a88aaf5314a938fb6826e18ba8f337470ee490b17dd6bea8
${NOT_SIGNED_URL}= https://cloud.3mdeb.com/index.php/s/zmJXxGG4piGB2Me/download/not_signed.img
${NOT_SIGNED_NAME}= not_signed.img
${NOT_SIGNED_SHA256}= 15dc0a250b73c3132b1d7c5f8e81f00cc34d899c3ddecbb838a8cd0b66c4f608
${BAD_KEYS_URL}= https://cloud.3mdeb.com/index.php/s/BJPbSqRH6NdbRym/download/bad_keys.img
${BAD_KEYS_NAME}= bad_keys.img
${BAD_KEYS_SHA256}= 6da92bd97d4b4ca645fa98dcdfdc0c6876959e5b815a36f1f7759bc5463e7b19
${BAD_FORMAT_URL}= https://cloud.3mdeb.com/index.php/s/AsBnATiHTZQ6jae/download/bad_format.img
${BAD_FORMAT_NAME}= bad_format.img
${BAD_FORMAT_SHA256}= 59d17bc120dfd0f2e6948a2bfdbdf5fb06eddcb44f9a053a8e7b8f677e21858c
*** Keywords ***
Get Secure Boot Menu Construction
[Documentation] Secure Boot menu is very different than all
... of the others so we need a special keyword for parsing it.
... Return only selectable entries. If some menu option is not
... selectable (grayed out) it will not be in the menu construction
... list.
[Arguments] ${checkpoint}=Esc=Exit ${lines_top}=1 ${lines_bot}=2
${out}= Read From Terminal Until ${checkpoint}
# At first, parse the menu as usual
${menu}= Parse Menu Snapshot Into Construction ${out} ${lines_top} ${lines_bot}
${enable_sb_can_be_selected}= Run Keyword And Return Status
... List Should Not Contain Value
... ${menu}
... To enable Secure Boot, set Secure Boot Mode to
# If we have a help message indicating keys are not provisioned,
# we drop this help message end Enable Secure Boot option (which is
# not selectable) from the menu construction.
IF ${enable_sb_can_be_selected} == ${FALSE}
Remove Values From List
... ${menu}
... To enable Secure Boot, set Secure Boot Mode to
... Custom and enroll the keys/PK first.
... Enable Secure Boot [ ]
... Enable Secure Boot [X]
END
RETURN ${menu}
Enter Secure Boot Menu
[Documentation] This keyword enters Secure Boot menu after the platform was powered on.
${setup_menu}= Enter Setup Menu Tianocore And Return Construction
${device_mgr_menu}= Enter Submenu From Snapshot And Return Construction
... ${setup_menu}
... Device Manager
Enter Submenu From Snapshot ${device_mgr_menu} Secure Boot Configuration
Enter Secure Boot Menu And Return Construction
[Documentation] This keyword enters Secure Boot menu after the platform was powered on. Returns Secure Boot menu construction.
Enter Secure Boot Menu
${sb_menu}= Get Secure Boot Menu Construction
RETURN ${sb_menu}
Enter Advanced Secure Boot Keys Management
[Documentation] Enables Secure Boot Custom Mode and enters Advanced Management menu.
[Arguments] ${sb_menu}
Set Option State ${sb_menu} Secure Boot Mode Custom Mode
# After selecting Custom Mode, the Advanced Menu is one below
Press Key N Times And Enter 1 ${ARROW_DOWN}
Enter Advanced Secure Boot Keys Management And Return Construction
[Documentation] Enables Secure Boot Custom Mode and enters Advanced Management menu.
[Arguments] ${sb_menu}
Enter Advanced Secure Boot Keys Management ${sb_menu}
${menu}= Get Submenu Construction opt_only=${TRUE}
RETURN ${menu}
Reset To Default Secure Boot Keys
[Documentation] This keyword assumes that we are in the Advanced Secure
... Boot menu already.
[Arguments] ${advanced_menu}
Enter Submenu From Snapshot ${advanced_menu} Reset to default Secure Boot Keys
Read From Terminal Until Are you sure?
Press Enter
# QEMU needs a lot of time, why?
Sleep 15s
Erase All Secure Boot Keys
[Documentation] This keyword assumes that we are in the Advanced Secure
... Boot menu already.
[Arguments] ${advanced_menu}
Enter Submenu From Snapshot ${advanced_menu} Erase all Secure Boot Keys
Read From Terminal Until Are you sure?
Press Enter
# QEMU needs a lot of time, why?
Sleep 15s
Return Secure Boot State
[Documentation] Returns the state of Secure Boot as reported in the Secure Boot Configuration menu
[Arguments] ${sb_menu}
${index}= Get Index Of Matching Option In Menu ${sb_menu} Secure Boot State
${sb_state}= Get From List ${sb_menu} ${index}
${sb_state}= Remove String ${sb_state} Secure Boot State
${sb_state}= Strip String ${sb_state}
RETURN ${sb_state}
Make Sure That Keys Are Provisioned
[Documentation] Expects to be executed when in Secure Boot configuration menu.
[Arguments] ${sb_menu}
${need_reset}= Run Keyword And Return Status Should Not Contain Match ${sb_menu} Enable Secure Boot *
IF ${need_reset} == ${TRUE}
${advanced_menu}= Enter Advanced Secure Boot Keys Management And Return Construction ${sb_menu}
Reset To Default Secure Boot Keys ${advanced_menu}
Exit From Current Menu
${sb_menu}= Get Secure Boot Menu Construction
END
RETURN ${sb_menu}
Enable Secure Boot
[Documentation] Expects to be executed when in Secure Boot configuration menu.
[Arguments] ${sb_menu}
${sb_menu}= Make Sure That Keys Are Provisioned ${sb_menu}
${changed}= Set Option State ${sb_menu} Enable Secure Boot ${TRUE}
IF ${changed} == ${TRUE}
# Changing Secure Boot state issues a special popup
Read From Terminal Until Configuration changed, please reset the platform to take effect!
# Dismiss the popup with any key
Press Enter
END
Disable Secure Boot
[Documentation] Expects to be executed when in Secure Boot configuration menu.
[Arguments] ${sb_menu}
${sb_menu}= Make Sure That Keys Are Provisioned ${sb_menu}
${changed}= Set Option State ${sb_menu} Enable Secure Boot ${FALSE}
IF ${changed} == ${TRUE}
# Changing Secure Boot state issues a special popup
Read From Terminal Until Configuration changed, please reset the platform to take effect!
# Dismiss the popup with any key
Press Enter
END
Check Secure Boot In Linux
[Documentation] Keyword checks Secure Boot state in Linux.
... Returns True when Secure Boot is enabled
... and False when disabled.
# The string in dmesg may be in two forms:
# secureboot: Secure boot disabled
# or just:
# Secure boot disabled
# Lines containing "Bluetooth" are ignored as they are not the target of this check and may cause false result.
${out}= Execute Command In Terminal journalctl -xb | grep "secureboot:"
Should Contain Any ${out} disabled enabled
${sb_status}= Run Keyword And Return Status
... Should Contain ${out} enabled
RETURN ${sb_status}
Check Secure Boot In Windows
[Documentation] Keyword checks Secure Boot state in Windows.
... Returns True when Secure Boot is enabled
... and False when disabled.
${out}= Execute Command In Terminal Confirm-SecureBootUEFI
Should Contain Any ${out} True False
${sb_status}= Run Keyword And Return Status
... Should Contain ${out} True
RETURN ${sb_status}
Enter Enroll DB Signature Using File In DB Options
[Documentation] Keyword checks Secure Boot state in Windows.
[Arguments] ${advanced_menu}
${db_opts_menu}= Enter Submenu From Snapshot And Return Construction
... ${advanced_menu}
... DB Options
... opt_only=${TRUE}
${enroll_sig_menu}= Enter Submenu From Snapshot And Return Construction
... ${db_opts_menu}
... Enroll Signature
... opt_only=${FALSE}
Enter Submenu From Snapshot ${enroll_sig_menu} Enroll Signature Using File
Enter Volume In File Explorer
[Documentation] Enter the given volume
[Arguments] ${target_volume}
# 1. Read out the whole File Explorer menu
${volumes}= Get Submenu Construction opt_only=${TRUE}
Log ${volumes}
# 2. See if our label is within these entries
${index}= Get Index Of Matching Option In Menu ${volumes} ${target_volume} ${TRUE}
# 3. If yes, go to the selected label
IF ${index} != -1
Press Key N Times And Enter ${index} ${ARROW_DOWN}
# 4. If no, get the number of entries and go that many times below
ELSE
${volumes_no}= Get Length ${volumes}
Press Key N Times ${volumes_no} ${ARROW_DOWN}
# - check if the label is what we need, if yes, select
FOR ${in} IN RANGE 20
${new_entry}= Read From Terminal
${status}= Run Keyword And Return Status
... Should Contain ${new_entry} ${target_volume}
IF ${status} == ${TRUE} BREAK
IF ${in} == 19 Fail Volume not found
Press Key N Times 1 ${ARROW_DOWN}
END
Press Key N Times 1 ${ENTER}
END
Enter Boot From File
[Documentation] Navigates from Tianocore Setup Menu
... to Boot Maintenance Manager and to Boot From File
${setup_menu}= Enter Setup Menu Tianocore And Return Construction
${boot_maintenance_mgr_menu}= Enter Submenu From Snapshot And Return Construction
... ${setup_menu}
... Boot Maintenance Manager
Enter Submenu From Snapshot ${boot_maintenance_mgr_menu} Boot From File
Execute File In File Explorer
[Documentation] Execute the given file (with ENTER key)
[Arguments] ${target_file}
# 1. Select desired file
${files}= Get Submenu Construction
Log ${files}
${index}= Get Index Of Matching Option In Menu ${files} ${target_file}
# FIXME: We must add 1 due to empty selecatble space in File Manager
Press Key N Times And Enter ${index} ${ARROW_DOWN}
Select File In File Explorer
[Documentation] Select the given file
[Arguments] ${target_file}
# 1. Select desired file
Execute File In File Explorer ${target_file}
# 2. Save Changes
${enroll_sig_menu}= Get Submenu Construction
# Unselectable filename appears between options after file was selected
Remove Values From List ${enroll_sig_menu} ${target_file}
${index}= Get Index Of Matching Option In Menu ${enroll_sig_menu} Commit Changes and Exit
Press Key N Times And Enter ${index} ${ARROW_DOWN}
Enter UEFI Shell
[Documentation] Boots into UEFI Shell. Should be called after Power On or
... reboot
Set Prompt For Terminal Shell>
${boot_menu}= Enter Boot Menu Tianocore And Return Construction
Enter Submenu From Snapshot ${boot_menu} UEFI Shell
Read From Terminal Until skip startup.nsh or any other key to continue.
# Skip startup.nsh counting. If not skipped, a next boot entry may be booted
# autoamtically for some reason.
Press Key N Times 1 ${ESC}
Read From Terminal Until Prompt
Sleep 1s
Execute File In UEFI Shell
# UEFI shell has different line ending than the one we have set for the
# Telnet connection. We cannot change it while the connection is open.
[Arguments] ${file}
Set Prompt For Terminal FS0:\\>
${out}= Execute UEFI Shell Command fs0:
${out}= Execute UEFI Shell Command ${file}
Set Prompt For Terminal Shell>
RETURN ${out}
Restore Secure Boot Defaults
[Documentation] Restore SB settings to default, by resetting keys
... and disabling SB, so it does not interfere with the followup tests.
Power On
${sb_menu}= Enter Secure Boot Menu And Return Construction
${advanced_menu}= Enter Advanced Secure Boot Keys Management And Return Construction ${sb_menu}
Reset To Default Secure Boot Keys ${advanced_menu}
# Changes to Secure Boot take action immediately, so we can just continue
Exit From Current Menu
${sb_menu}= Reenter Menu And Return Construction
IF '${SECURE_BOOT_DEFAULT_STATE}' == 'Disabled'
Disable Secure Boot ${sb_menu}
ELSE
Enable Secure Boot ${sb_menu}
END
# Changes to Secure Boot take action immediately, so we can just continue