blob: ceac1e420732044cae9a75c692708efb5c380b13 [file] [log] [blame]
Sweta Potthuri39255032018-03-28 10:12:14 -05001*** Settings ***
2Documentation Secure boot related test cases.
3
Sweta Potthurid3c03432018-04-19 11:30:27 -05004# Test Parameters:
5# FFDC_TOOL_DIR_PATH The path to the directory containing FFDC translation
6# tools such as eSEL.pl.
7
George Keishinga8b25492018-06-07 01:15:37 -05008Resource ../../lib/utils.robot
9Resource ../../lib/boot_utils.robot
10Resource ../../lib/secure_utils.robot
11Resource ../../lib/open_power_utils.robot
12Resource ../../lib/logging_utils.robot
13Resource ../../lib/openbmc_ffdc_methods.robot
Sweta Potthuri39255032018-03-28 10:12:14 -050014
George Keishinga8b25492018-06-07 01:15:37 -050015Library ../../lib/gen_misc.py
Sweta Potthurid3c03432018-04-19 11:30:27 -050016
17Suite Setup Suite Setup Execution
Sweta Potthuri39255032018-03-28 10:12:14 -050018Test Setup Test Setup Execution
19Test Teardown Test Teardown Execution
20
21*** Variables ***
22
23${security_access_bit_mask} ${0xC000000000000000}
Sweta Potthurid3c03432018-04-19 11:30:27 -050024# Description of BC8A1E07 A problem occurred during the IPL of the system.
25${pnor_corruption_src} BC8A1E07
26${bmc_image_dir_path} /usr/local/share/pnor
Lakshminarayana R. Kammath077fbf92019-02-20 11:15:18 -060027${bmc_guard_dir_path} /var/lib/phosphor-software-manager/pnor/prsv
Sweta Potthurid3c03432018-04-19 11:30:27 -050028${FFDC_TOOL_DIR_PATH} ${EMPTY}
Sweta Potthuri39255032018-03-28 10:12:14 -050029
30*** Test Cases ***
31
32Validate Secure Boot With TPM Policy Disabled
33 [Documentation] Validate secure boot with TPM policy disabled.
34 [Tags] Validate_Secure_Boot_With_TPM_Policy_Disabled
35
36 Validate Secure Boot With TPM Policy Enabled Or Disabled ${0}
37
38
39Validate Secure Boot With TPM Policy Enabled
40 [Documentation] Validate secure boot with TPM policy enabled.
41 [Tags] Validate_Secure_Boot_With_TPM_Policy_Enabled
42
43 Validate Secure Boot With TPM Policy Enabled Or Disabled ${1}
44
45
Sweta Potthurid3c03432018-04-19 11:30:27 -050046Violate Secure Boot Via Corrupt Key In SBE During Host Boot
47 [Documentation] Violate secure boot via corrupt key SBE during host boot.
48 [Tags] Violate_Secure_Boot_Via_Corrupt_Key_In_SBE_During_Host_Boot
49
50 Violate Secure Boot Via Corrupt Key
51 ... SBE ${pnor_corruption_src} ${bmc_image_dir_path}
52
53
Sweta Potthuri39255032018-03-28 10:12:14 -050054*** Keywords ***
55
Sweta Potthurid3c03432018-04-19 11:30:27 -050056Violate Secure Boot Via Corrupt Key
57 [Documentation] Cause secure boot violation during host boot
58 ... with corrupted key.
59 [Arguments] ${partition} ${error_src} ${bmc_image_dir_path}
60
Gunnar Mills7732c7e2018-08-14 11:54:24 -050061 # Description of argument(s):
Sweta Potthurid3c03432018-04-19 11:30:27 -050062 # partition The partition which is to be corrupted
63 # (e.g. "SBE", "HBI", "HBB", "HBRT", "HBBL", "OCC").
64 # error_src The system reference code that is expected as a
65 # result of the secure boot violation
66 # (e.g. "BC8A1E07").
67 # bmc_image_dir_path BMC image path.
68
69 Set And Verify TPM Policy ${1}
70
71 # Descipiton:
72 # Cause a secure boot violation by copying an BMC image file to the
73 # target BMC and then starting a power on.
74 # This action should result in:
75 # 1) an error log entry
76 # 2) the system going to "Quiesced" state.
77
78 # Load corrupted image to /usr/local/share/pnor.
79 Open Connection For SCP
80 Log ${bmc_image_dir_path}
81 scp.Put File
82 ... ${EXEC_DIR}/data/pnor_test_data/${partition} ${bmc_image_dir_path}
83
84 # Starting a power on.
85 BMC Execute Command /usr/sbin/obmcutil poweron
86 Wait Until Keyword Succeeds 10 min 10 sec Error Logs Should Exist
87
88 Wait Until Keyword Succeeds 10 min 10 sec Collect Error Logs and Verify SRC ${error_src}
89
90 # Remove the file from /usr/local/share/pnor/.
91 BMC Execute Command rm -rf ${bmc_image_dir_path}*
92
93 # Check if system reaches quiesce state.
94 Run Keywords
95 ... Wait Until Keyword Succeeds 3 min 5 sec Is Host Quiesced AND
96 ... Recover Quiesced Host
97
98
99Collect Error Logs and Verify SRC
100 [Documentation] Collect error logs and verify src.
101 [Arguments] ${system_reference_code}
102
103 # Description of argument(s):
104 # system_reference_code The system reference code that the caller
105 # expects to be found among the existing
106 # error log entries (e.g. "BC8A1E07").
107 # system_reference_code Src code.
108
109 Convert eSEL To Elog Format ${FFDC_TOOL_DIR_PATH}
110
111 ${cmd}= Catenate
112 ... grep -i ${system_reference_code} ${FFDC_TOOL_DIR_PATH}/esel.out.txt
113 ${rc} ${output}= Run and Return RC and Output ${cmd}
114 Should Be Equal ${rc} ${0}
115 ... msg=${system_reference_code} not found in the existing error logs.
116
117
Sweta Potthuri39255032018-03-28 10:12:14 -0500118Get And Verify Security Access Bit
119 [Documentation] Get and verify security access bit.
120 [Arguments] ${sol_log_file_path}
121
122 # Description of argument(s):
123 # sol_log_file_path The path to the file containing SOL data
124 # which was collected during a REST Power On.
125
126 # Sample output:
127 # 19.68481|SECURE|Security Access Bit> 0xC000000000000000
128
129 ${cmd}= Catenate
130 ... grep "Security Access Bit" ${sol_log_file_path} | awk '{ print $4 }'
131 ${rc} ${security_access_bit_str}= Run and Return RC and Output ${cmd}
132 Should Be Equal ${rc} ${0}
133 ... msg=Return code from ${cmd} not zero.
134
135 # Verify the value of "Security Access Bit".
136
137 ${security_access_bit}= Convert to Integer ${security_access_bit_str}
138 ${result}= Evaluate ${security_access_bit_mask} & ${security_access_bit}
139 Should Be Equal ${result} ${security_access_bit_mask}
140 ... msg=System is not booted in secure mode. values=False
141
142
143Validate Secure Boot With TPM Policy Enabled Or Disabled
144 [Documentation] Validate secure boot with TPM policy enabled or disabled.
145 [Arguments] ${tpm_policy}
146
147 # Description of argument(s):
148 # tpm_policy Enable-0 or Disable-1.
149
150 Set And Verify TPM Policy ${tpm_policy}
151 REST Power On quiet=1
152 Validate Secure Boot ${sol_log_file_path}
153
154
155Validate Secure Boot
156 [Documentation] Validate secure boot.
157 [Arguments] ${sol_log_file_path}
158
159 # Description of argument(s):
160 # sol_log_file_path The path to the file containing SOL data
161 # which was collected during a REST Power On.
162
163 Get And Verify Security Access Bit ${sol_log_file_path}
164 Error Logs Should Not Exist
165 REST Verify No Gard Records
166
167
Sweta Potthurid3c03432018-04-19 11:30:27 -0500168Suite Setup Execution
169 [Documentation] Suite Setup Execution
170
171 Run export PATH=$PATH:${FFDC_TOOL_DIR_PATH}
172 Set Environment Variable ${FFDC_TOOL_DIR_PATH} ${FFDC_TOOL_DIR_PATH}
173 ${bmc_image_dir_path}= Add Trailing Slash ${bmc_image_dir_path}
Lakshminarayana R. Kammath077fbf92019-02-20 11:15:18 -0600174 ${bmc_guard_dir_path}= Add Trailing Slash ${bmc_guard_dir_path}
175
Sweta Potthurid3c03432018-04-19 11:30:27 -0500176 Set Global Variable ${bmc_image_dir_path}
177 Log ${bmc_image_dir_path}
178 BMC Execute Command rm -rf ${bmc_image_dir_path}*
179
Lakshminarayana R. Kammath077fbf92019-02-20 11:15:18 -0600180 Set Global Variable ${bmc_guard_dir_path}
181 Log ${bmc_guard_dir_path}
182 BMC Execute Command rm -rf ${bmc_guard_dir_path}*
183
Sweta Potthurid3c03432018-04-19 11:30:27 -0500184
Sweta Potthuri39255032018-03-28 10:12:14 -0500185Test Setup Execution
186 [Documentation] Test setup execution.
187
188 ${timestamp}= Get Current Date result_format=%Y%m%d%H%M%S
189 ${sol_log_file_path}= Catenate ${EXECDIR}/Secure_SOL${timestamp}
190 Start SOL Console Logging ${sol_log_file_path}
191 Set Suite Variable ${sol_log_file_path}
192
193 REST Power Off stack_mode=skip quiet=1
194 Delete Error Logs And Verify
Lakshminarayana R. Kammath077fbf92019-02-20 11:15:18 -0600195
Sweta Potthuri39255032018-03-28 10:12:14 -0500196
197
198Test Teardown Execution
199 [Documentation] Test teardown execution.
200
201 Stop SOL Console Logging
202 Run rm -rf ${sol_log_file_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500203
204 # Removing the corrupted file from BMC.
205 BMC Execute Command rm -rf ${bmc_image_dir_path}*