1*** Settings *** 2 3Documentation Module to test IPMI SEL functionality. 4Resource ../lib/ipmi_client.robot 5Resource ../lib/openbmc_ffdc.robot 6Library ../lib/ipmi_utils.py 7Variables ../data/ipmi_raw_cmd_table.py 8 9Test Setup Test Setup Execution 10Test Teardown FFDC On Test Case Fail 11 12*** Test Cases *** 13 14Verify IPMI SEL Version 15 [Documentation] Verify IPMI SEL's version info. 16 [Tags] Verify_IPMI_SEL_Version 17 ${version_info}= Get IPMI SEL Setting Version 18 ${setting_status}= Fetch From Left ${version_info} ( 19 ${setting_status}= Evaluate $setting_status.replace(' ','') 20 21 Should Be True ${setting_status} >= 1.5 22 Should Contain ${version_info} v2 compliant case_insensitive=True 23 24 25Verify Empty SEL 26 [Documentation] Verify IPMI sel clear command clears the SEL entry. 27 [Tags] Verify_Empty_SEL 28 29 # Generate an error log and verify there is one at least. 30 Create Test PEL Log 31 ${resp}= Run IPMI Standard Command sel elist last 1 32 Log To Console ${resp} 33 34 Should Contain Any ${resp} system hardware failure Asserted 35 ... msg=Add SEL Entry failed. 36 37 # Send SEL clear command and verify if it really clears up the SEL entry. 38 Run IPMI Standard Command sel clear 39 Sleep 5s 40 41 ${resp}= Run IPMI Standard Command sel list 42 Should Contain ${resp} SEL has no entries case_insensitive=True 43 44 45Verify Add SEL Entry 46 [Documentation] Verify add SEL entry. 47 [Tags] Verify_Add_SEL_Entry 48 [Teardown] Run Keywords FFDC On Test Case Fail AND Run IPMI Standard Command sel clear 49 50 # The IPMI raw command to generate Temp sensor error is no longer working. 51 # Our aim is to check if the SEL command is listed in IPMI or not. 52 # Original keyword "Create User Defined SEL" for reference 53 Create Test PEL Log 54 55 # Get last SEL entry. 56 ${resp}= Run IPMI Standard Command sel elist last 1 57 # output: 58 # 1 | 11/17/2021 | 07:49:20 | System Event #0x01 | Undetermined system hardware failure | Asserted 59 Run Keywords Should Contain ${resp} system hardware failure AND 60 ... Should Contain ${resp} Asserted msg=Add SEL Entry failed. 61 62 63Verify Add SEL Entry For Any Random Sensor 64 [Documentation] Create SEL entry and verify for any given random sensor. 65 [Tags] Verify_Add_SEL_Entry_For_Any_Random_Sensor 66 [Teardown] Run Keywords FFDC On Test Case Fail AND Run IPMI Standard Command sel clear 67 68 # Get any sensor available from sensor list. 69 ${sensor_name}= Fetch One Threshold Sensor From Sensor List 70 71 # Get Sensor ID from SDR get "sensor". 72 ${sensor_data1}= Fetch Sensor Details From SDR ${sensor_name} Sensor ID 73 ${name_sensor} ${sensor_number}= Get Data And Byte From SDR Sensor ${sensor_data1} 74 75 # Get Sensor Type from SDR get "sensor". 76 ${sensor_data2}= Fetch Sensor Details From SDR ${sensor_name} Sensor Type (Threshold) 77 ${sensor_type} ${sensor_type_id}= Get Data And Byte From SDR Sensor ${sensor_data2} 78 79 # Add SEL Entry. 80 # ${sel_entry_id} is the Record ID for added record (LSB First). 81 ${sel_create_resp}= Create SEL ${sensor_type_id} ${sensor_number} 82 ${sel_entry_id}= Split String ${sel_create_resp} 83 84 # Get last SEL entry. 85 ${resp}= Run IPMI Standard Command sel elist last 1 86 87 # Output of the Sel elist last 1. 88 # Below example is a continuous line statement. 89 # N | MM/DD/YYYY | HH:MM:SS | Sensor_Type Sensor_Name | 90 # Lower Non-critical going low | Asserted | Reading 0. 91 92 Run Keywords Should Contain ${resp} ${sensor_type} ${sensor_name} AND 93 ... Should Contain ${resp} Asserted msg=Add SEL Entry failed. 94 95 # Get SEL Entry IPMI Raw Command. 96 ${entry}= Get SEL Entry Via IPMI ${sel_entry_id[0]} ${sel_entry_id[1]} 97 98 # Compare SEL Record ID. 99 ${sel_record_id}= Set Variable ${entry[2:4]} 100 Should Be Equal ${sel_record_id} ${sel_entry_id} 101 102 # Sensor type compare. 103 Should Be Equal ${sensor_type_id} ${entry[12]} 104 105 # Sensor number compare. 106 Should Be Equal ${sensor_number} ${entry[13]} 107 108 109Verify Reserve SEL 110 [Documentation] Verify reserve SEL. 111 [Tags] Verify_Reserve_SEL 112 113 ${resp}= Run IPMI Standard Command 114 ... raw ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]} 115 ${reserve_id}= Split String ${resp} 116 117 # Execute clear SEL raw command with Reservation ID. 118 # Command will not execute unless the correct Reservation ID value is provided. 119 Run IPMI Standard Command 120 ... raw 0x0a 0x47 0x${reserve_id[0]} 0x${reserve_id[1]} 0x43 0x4c 0x52 0xaa 121 122 # Check SEL list. 123 ${resp}= Run IPMI Standard Command sel list 124 Should Contain ${resp} SEL has no entries case_insensitive=True 125 126 127Verify IPMI SEL Most Recent Addition Timestamp 128 [Documentation] Verify most recent addition timestamp in SEL info. 129 [Tags] Verify_IPMI_SEL_Most_Recent_Addition_Timestamp 130 131 # Get Most Recent Addition Timestamp from SEL Info. 132 ${addition_timestamp}= Get Most Recent Addition Timestamp From SEL Info 133 134 IF '${addition_timestamp}' != 'ffffffff' 135 # Convert to epoch timestamp. 136 ${epoch_addition}= Convert To Integer ${addition_timestamp} 16 137 138 # Get SEL List last 1 entry date and time and convert to epoch timestamp. 139 ${sel_epoch_time}= Get SEL Elist Last Entry Date In Epoch 140 141 # Compare epoch of sel entry timestamp and last addition timestamp. 142 ${diff}= Evaluate int(${sel_epoch_time}) - int(${epoch_addition}) 143 Should Be True ${diff}<=600 144 145 ELSE 146 # Get any Sensor available from Sensor list 147 ${sensor_name}= Fetch One Threshold Sensor From Sensor List 148 149 # Get Sensor ID from SDR Get "sensor" and Identify Sensor ID. 150 ${sensor_data1}= Fetch Sensor Details From SDR ${sensor_name} Sensor ID 151 ${name_sensor} ${sensor_number}= Get Data And Byte From SDR Sensor ${sensor_data1} 152 153 # Get Sensor Type from SDR Get "sensor" and Identify Sensor Type. 154 ${sensor_data2}= Fetch Sensor Details From SDR ${sensor_name} Sensor Type (Threshold) 155 ${sensor_type} ${sensor_type_id}= Get Data And Byte From SDR Sensor ${sensor_data2} 156 157 # Add SEL Entry. 158 ${sel_create_resp}= Create SEL ${sensor_type_id} ${sensor_number} 159 160 # Get SEL List last 1 entry date and time and convert to epoch timestamp. 161 ${sel_epoch_time}= Get SEL Elist Last Entry Date In Epoch 162 163 # Get Most Recent Addition Timestamp from SEL Info. 164 ${addition}= Get Most Recent Addition Timestamp From SEL Info 165 ${epoch_addition}= Convert To Integer ${addition} 16 166 167 # Compare epoch of sel entry timestamp and last addition timestamp. 168 ${diff}= Evaluate int(${epoch_addition}) - int(${sel_epoch_time}) 169 Should Be True ${diff}<=5 170 END 171 172 173Verify IPMI SEL Most Recent Erase Timestamp 174 [Documentation] Verify Most Recent Erase Timestamp In SEL Info with current 175 ... BMC epoch timestamp. 176 [Tags] Verify_IPMI_SEL_Most_Recent_Erase_Timestamp 177 178 # Get BMC Current Time. 179 ${bmc_epoch_time}= Get BMC Time In Epoch 180 181 # Get Most Recent Addition Timestamp from SEL Info. 182 ${addition_timestamp}= Get Most Recent Addition Timestamp From SEL Info 183 Should Be Equal ${addition_timestamp} ffffffff 184 185 # Get Most Recent Erase Timestamp from SEL Info. 186 ${erase_timestamp}= Get Most Recent Erase Timestamp From SEL Info 187 ${epoch_erase}= Convert To Integer ${erase_timestamp} 16 188 189 # Compare epoch of erase timestamp and current bmc timestamp. 190 ${diff}= Evaluate int(${epoch_erase}) - int(${bmc_epoch_time}) 191 Should Be True ${diff}<=5 192 193 194Verify Clear SEL With Invalid Reservation ID 195 [Documentation] Verify clear SEL After generating another reserve ID. 196 [Tags] Verify_Clear_SEL_With_Invalid_Reservation_ID 197 198 # Reserve Sel command - 1. 199 ${resp}= Run IPMI Standard Command 200 ... raw ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]} 201 ${reserve_id}= Split String ${resp} 202 203 # Reserve Sel command - 2. 204 ${resp}= Run IPMI Standard Command 205 ... raw ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]} 206 207 ${cmd}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][0]} 0x${reserve_id[0]} 208 ... 0x${reserve_id[1]} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][1]} 209 210 # Clear SEL command. 211 ${clear_resp}= Run Keyword and Expect Error *${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][4]}* 212 ... Run IPMI Standard Command raw ${cmd} 213 Should Contain ${clear_resp} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][5]} 214 215 216Verify Reservation ID Erasure Status 217 [Documentation] Verify Erasure status by clearing SEL with Reserve ID and verify the response byte, 218 ... whether erasure status is updated in clear sel command response data using new Reserve ID. 219 [Tags] Verify_Reservation_ID_Erasure_Status 220 221 # Generate Reserve ID 1. 222 ${resp}= Run IPMI Standard Command 223 ... raw ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]} 224 ${reserve_id}= Split String ${resp} 225 226 ${cmd1}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][0]} 0x${reserve_id[0]} 227 ... 0x${reserve_id[1]} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][1]} 228 229 # Execute clear SEL raw command with Reservation ID. 230 # Command will not execute unless the correct Reservation ID value is provided. 231 Run IPMI Standard Command raw ${cmd1} 232 233 # Generate Reserver ID 2. 234 ${resp}= Run IPMI Standard Command 235 ... raw ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]} 236 ${reserve_id}= Split String ${resp} 237 238 ${cmd2}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][0]} 0x${reserve_id[0]} 239 ... 0x${reserve_id[1]} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][6]} 240 241 # Check the Erasure status of Clear SEL. 242 ${data}= Run IPMI Standard Command raw ${cmd2} 243 244 # 00 - Erasure in Progress , 01 - Erasure Complete. 245 Should Contain Any ${data} 00 01 246 247 248Verify Clear SEL After Cold Reset 249 [Documentation] Verify Clear SEL for a reserve SEL ID after Cold Reset. 250 [Tags] Verify_Clear_SEL_After_Cold_Reset 251 252 # Reserve Sel command. 253 ${resp}= Run IPMI Standard Command 254 ... raw ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]} 255 ${reserve_id}= Split String ${resp} 256 257 # Run Cold Reset. 258 IPMI MC Reset Cold (off) 259 260 ${cmd}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][0]} 0x${reserve_id[0]} 261 ... 0x${reserve_id[1]} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][1]} 262 263 # Clear SEL command. 264 ${clear_resp}= Run Keyword and Expect Error *${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][5]}* 265 ... Run IPMI Standard Command raw ${cmd} 266 267 Should Contain ${clear_resp} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][4]} 268 269 270*** Keywords *** 271 272Create User Defined SEL 273 [Documentation] Create a user defined tempearature sensor SEL. 274 275 # Create a SEL. 276 # Example: 277 # a | 02/14/2020 | 01:16:58 | Temperature #0x17 | | Asserted 278 Run IPMI Command 279 ... 0x0a 0x44 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x04 0x01 ${sensor_number} 0x00 0xa0 0x04 0x07 280 281 282Get SEL Entry Via IPMI 283 [Documentation] Get SEL Entry Via IPMI raw command. 284 [Arguments] ${record1} ${record2} 285 286 # Description of Argument(s): 287 # ${record1} Record ID for added record, LS Byte 288 # ${record2} Record ID for added record, MS Byte 289 290 # For example, when a first sel entry is added with IPMI raw command, the response will be "01 00". 291 # Here, ${record1} is 01, and ${record2} is 00. 292 293 ${cmd}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Get_SEL_Entry'][0]} 0x${record1} 294 ... 0x${record2} ${IPMI_RAW_CMD['SEL_entry']['Get_SEL_Entry'][1]} 295 296 # Get SEL Entry Raw command. 297 ${resp}= Run IPMI Standard Command raw ${cmd} 298 ${resp}= Split String ${resp} 299 300 [Return] ${resp} 301 302 303Get Most Recent Addition Timestamp From SEL Info 304 [Documentation] Get Most recent addition timestamp From SEL Info. 305 306 # Get SEL Info raw command. 307 ${sel_info}= Get SEL Info Via IPMI 308 309 # Get Most Recent Addition timestamp in hex. 310 ${addition_timestamp}= Set Variable ${sel_info[5:9]} 311 Reverse List ${addition_timestamp} 312 ${addition_timestamp}= Evaluate "".join(${addition_timestamp}) 313 314 [Return] ${addition_timestamp} 315 316 317Get Most Recent Erase Timestamp From SEL Info 318 [Documentation] Get Most recent erase timestamp From SEL Info. 319 320 # Get SEL Info Raw command. 321 ${sel_info}= Get SEL Info Via IPMI 322 323 # Get Most Recent Erase timestamp in hex. 324 ${erase_timestamp}= Set Variable ${sel_info[9:13]} 325 Reverse List ${erase_timestamp} 326 ${erase_timestamp}= Evaluate "".join(${erase_timestamp}) 327 328 [Return] ${erase_timestamp} 329 330 331Get SEL Elist Last Entry Date In Epoch 332 [Documentation] Get the time from SEL elist last entry and returns epoch time. 333 334 # Get SEL list last entry. 335 ${resp}= Run IPMI Standard Command sel elist last 1 336 337 # Get date from the sel entry and convert to epoch timestamp. 338 ${sel_entry_date}= Fetch Added SEL Date ${resp} 339 ${epoch_date}= Convert Date ${sel_entry_date} epoch exclude_millis=yes date_format=%m/%d/%Y %H:%M:%S 340 341 [Return] ${epoch_date} 342 343 344Get BMC Time In Epoch 345 [Documentation] Get the current time from BMC and returns epoch time. 346 347 # Get the bmc native bmc date command response. 348 ${date}= Get Current Date from BMC 349 350 ${epoch_date}= Convert Date ${date} epoch exclude_millis=yes date_format=%m/%d/%Y %H:%M:%S 351 352 [Return] ${epoch_date} 353 354 355Test Setup Execution 356 [Documentation] Do test setup tasks. 357 358 Run IPMI Standard Command sel clear 359 Sleep 5s 360