Skip to content

Commit cc303dd

Browse files
dasharo-compatibility/custom-boot-order.robot: Add new test suite
Additionally, create new lib entry for boot order mgmt keywords. Signed-off-by: Sebastian Czapla <sebastian.czapla@3mdeb.com>
1 parent 7e0fc55 commit cc303dd

File tree

4 files changed

+175
-34
lines changed

4 files changed

+175
-34
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
*** Settings ***
2+
Resource ../lib/platform/power.robot
3+
Resource ../lib/platform/boot.robot
4+
5+
Suite Setup Prepare Test Suite
6+
Suite Teardown Log Out And Close Connection
7+
8+
9+
*** Test Cases ***
10+
CBO001.101 Custom Boot Order (EDK2)
11+
[Documentation] Check if customization of Boot Order persists and
12+
... correct OS boots.
13+
Depends On ${TESTS_IN_FIRMWARE_SUPPORT}
14+
15+
# Windows SOL
16+
Power Cycle Into Firmware Setup
17+
Set Selected OS As First In Boot Order Via EDK2 ${ENV_ID_WINDOWS}
18+
Sleep 15s
19+
IF '${DUT_CONNECTION_METHOD}' != 'SSH'
20+
Set Test Variable ${DUT_CONNECTION_METHOD} SSH
21+
END
22+
Login To Windows Via SSH user windows
23+
${out}= Execute Command In Terminal
24+
... Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version
25+
Should Contain ${out} Microsoft Windows
26+
Restore Initial DUT Connection Method
27+
28+
# Ubuntu SOL
29+
Power Cycle Into Firmware Setup
30+
Set Selected OS As First In Boot Order Via EDK2 ${ENV_ID_UBUNTU}
31+
Sleep 15s
32+
Login To Linux
33+
${out}= Execute Command In Terminal
34+
... cat /etc/os-release
35+
Should Contain ${out} Ubuntu

dasharo-performance/fast-boot.robot

+2-34
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
*** Settings ***
2-
Library Collections
3-
Library OperatingSystem
4-
Library Process
5-
Library String
62
Library Telnet timeout=20 seconds connection_timeout=120 seconds
73
Library SSHLibrary timeout=90 seconds
8-
Library RequestsLibrary
9-
# TODO: maybe have a single file to include if we need to include the same
10-
# stuff in all test cases
11-
Resource ../variables.robot
12-
Resource ../keywords.robot
13-
Resource ../keys.robot
4+
Resource ../lib/platform/boot.robot
145

156
Suite Setup Initialize Fast Boot Suite
167
Suite Teardown Log Out And Close Connection
@@ -130,27 +121,4 @@ Initialize Fast Boot Suite
130121
Prepare Test Suite
131122
Skip If not ${FAST_AND_QUIET_BOOT_SUPPORT} Boot performance measurement tests not supported
132123
Skip If not ${TESTS_IN_UBUNTU_SUPPORT} Boot performance measurement tests not supported
133-
134-
Boot System Or From Connected Disk ${ENV_ID_UBUNTU}
135-
Login To Linux
136-
Switch To Root User
137-
138-
${ubuntu_boot_id}= Execute Linux Command
139-
... efibootmgr | grep -i "ubuntu" | awk 'NR==1 {print $1}' | sed 's/Boot//g' | sed 's/*//g'
140-
Should Not Be Empty ${ubuntu_boot_id}
141-
142-
${order_check}= Execute Linux Command
143-
... efibootmgr | grep "BootOrder: ${ubuntu_boot_id}"
144-
145-
IF '${order_check}' == '${EMPTY}'
146-
${boot_order_no_ubuntu}= Execute Linux Command
147-
... efibootmgr | grep "BootOrder" | awk '{print $2}' | sed -e 's/,${ubuntu_boot_id}//g'
148-
Should Not Be Empty ${boot_order_no_ubuntu}
149-
150-
${set_order_cmd}= Set Variable efibootmgr -o
151-
${set_order_cmd}= Catenate ${set_order_cmd}
152-
... ${ubuntu_boot_id},${boot_order_no_ubuntu}
153-
154-
${out}= Execute Linux Command ${set_order_cmd}
155-
Should Contain ${out} BootOrder: ${ubuntu_boot_id}
156-
END
124+
Set Selected OS As First In Boot Order Via Efibootmgr ${ENV_ID_UBUNTU}

keys.robot

+1
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ ${ENTER}= \x0d
2323
${BACKSPACE}= \x08
2424
${KEY_SPACE}= \x20
2525
${DELETE}= \x1b\x5b\x33\x7e
26+
${KEY_PLUS}= \x2b

lib/platform/boot.robot

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
*** Settings ***
2+
Documentation Common header for OSFV boot management
3+
4+
Library Collections
5+
Library OperatingSystem
6+
Library Process
7+
Library String
8+
Library RequestsLibrary
9+
Library SSHLibrary
10+
Resource ../../variables.robot
11+
Resource ../../keywords.robot
12+
Resource ../../keys.robot
13+
14+
15+
*** Keywords ***
16+
Set Selected OS As First In Boot Order Via EDK2
17+
[Documentation] Uses EDK2 menu to select given OS as first in
18+
... boot menu.
19+
...
20+
... === Requirements ===
21+
... - Serial port connection has to be supported by the platform
22+
... - Must be within Dasharo's main UEFI firmware setup
23+
...
24+
... === Arguments ===
25+
... - ``${os}``: ``string`` - ENV_ID of the OS we want to boot
26+
...
27+
... === Return Value ===
28+
... - None
29+
...
30+
... === Effects ===
31+
... - OS specified by ENV_ID will be priority during subsequent boots
32+
... - Resets the DUT via EDK2 reset
33+
[Arguments] ${os}
34+
${system_name}= Get From Dictionary ${ENV_ID_OS_BOOTMENU_NAMES} ${os}
35+
36+
# When ESP scanning feature is there, boot entries are named differently than
37+
# they used to
38+
IF ${ESP_SCANNING_SUPPORT} == ${TRUE}
39+
IF "${system_name}" == "ubuntu"
40+
${system_name}= Set Variable Ubuntu
41+
ELSE IF "${system_name}" == "fedora"
42+
${system_name}= Set Variable Fedora
43+
ELSE IF "${system_name}" == "trenchboot" and "${MANUFACTURER}" == "QEMU"
44+
${system_name}= Set Variable QEMU HARDDISK
45+
END
46+
END
47+
48+
${menu}= Get Setup Menu Construction
49+
${menu}= Enter Submenu From Snapshot And Return Construction
50+
... ${menu}
51+
... Boot Maintenance Manager
52+
${menu}= Enter Submenu From Snapshot And Return Construction
53+
... ${menu}
54+
... Boot Options
55+
${menu}= Enter Submenu From Snapshot And Return Construction
56+
... ${menu}
57+
... Change Boot Order
58+
Press Enter
59+
${os_list_raw}= Read From Terminal Until ---/
60+
${os_list}= Extract Strings From Frame ${os_list_raw}
61+
${first_item}= Set Variable ${os_list}[0]
62+
${is_first}= Run Keyword And Return Status Should Contain ${first_item} ${system_name}
63+
64+
IF '${is_first}' == 'False'
65+
${index}= Set Variable -1
66+
FOR ${i} ${item} IN ENUMERATE @{os_list}
67+
${item_lower}= Convert To Lowercase ${item}
68+
${system_lower}= Convert To Lowercase ${system_name}
69+
${found}= Run Keyword And Return Status Should Contain ${item_lower} ${system_lower}
70+
IF '${found}' == 'True'
71+
${index}= Set Variable ${i}
72+
BREAK
73+
END
74+
END
75+
76+
Should Not Be Equal As Integers ${index} -1
77+
... System name '${system_name}' not found in boot menu list
78+
79+
Press Key N Times ${index} ${ARROW_DOWN}
80+
Press Key N Times ${index} ${KEY_PLUS}
81+
Press Enter
82+
Write Bare Into Terminal ${F10}
83+
Sleep 1s
84+
Write Bare Into Terminal y
85+
# Return to main menu
86+
Press Key N Times 3 ${ESC}
87+
Sleep 1s
88+
# Issue reset in the menu
89+
Press Key N Times 2 ${ARROW_DOWN}
90+
Press Enter
91+
ELSE
92+
Log To Console ${system_name} already set as prio.
93+
END
94+
95+
Set Selected OS As First In Boot Order Via Efibootmgr
96+
[Documentation] Uses Ubuntu and efibootmgr to select boot prioroty
97+
...
98+
... === Requirements ===
99+
... - Connection to DUT must be established.
100+
... - Platform must boot Ubuntu to access efibootmgr
101+
...
102+
... === Arguments ===
103+
... - ``${os}``: ``string`` - ENV_ID of the OS we want to boot
104+
...
105+
... === Return Value ===
106+
... - None
107+
...
108+
... === Effects ===
109+
... - OS specified by ENV_ID will be priority during subsequent
110+
[Arguments] ${os}
111+
${system_name}= Get From Dictionary ${ENV_ID_OS_BOOTMENU_NAMES} ${os}
112+
Log To Console Setting ${system_name} as boot priority.
113+
114+
Boot System Or From Connected Disk ${ENV_ID_UBUNTU}
115+
Login To Linux
116+
Switch To Root User
117+
118+
${os_boot_id}= Execute Linux Command
119+
... efibootmgr | grep -i "${system_name}" | awk 'NR==1 {print $1}' | sed 's/Boot//g' | sed 's/*//g'
120+
Should Not Be Empty ${os_boot_id}
121+
122+
${order_check}= Execute Linux Command
123+
... efibootmgr | grep "BootOrder: ${os_boot_id}"
124+
125+
# Trim the boot list to exclude target OS
126+
IF '${order_check}' == '${EMPTY}'
127+
${boot_order_trimmed}= Execute Linux Command
128+
... efibootmgr | grep "BootOrder" | awk '{print $2}' | sed -e 's/,${os_boot_id}//g'
129+
Should Not Be Empty ${boot_order_trimmed}
130+
131+
${set_order_cmd}= Set Variable efibootmgr -o
132+
${set_order_cmd}= Catenate ${set_order_cmd}
133+
... ${os_boot_id},${boot_order_trimmed}
134+
135+
${out}= Execute Linux Command ${set_order_cmd}
136+
Should Contain ${out} BootOrder: ${os_boot_id}
137+
END

0 commit comments

Comments
 (0)