1*** Settings *** 2 3Documentation Module to test IPMI SEL functionality. 4Resource ../lib/ipmi_client.robot 5Resource ../lib/openbmc_ffdc.robot 6Resource ../../../lib/logging_utils.robot 7 8Library ../lib/ipmi_utils.py 9Library ../../../lib/logging_utils.py 10 11Variables ../data/ipmi_raw_cmd_table.py 12 13Test Setup Test Setup Execution 14Test Teardown FFDC On Test Case Fail 15 16Force Tags IPMI_SEL 17 18*** Variables *** 19 20# Based on 13th byte of add SEL entry command as per IPMI spec 21# event_dir and event_type variable value needs to be given. 22${sel_no_entry_msg} SEL has no entries 23${event_type} Lower Non-critical going low 24${event_dir} Asserted 25 26*** Test Cases *** 27 28Verify IPMI SEL Version 29 [Documentation] Verify IPMI SEL's version info. 30 [Tags] Verify_IPMI_SEL_Version 31 ${version_info}= Get IPMI SEL Setting Version 32 ${setting_status}= Fetch From Left ${version_info} ( 33 ${setting_status}= Evaluate $setting_status.replace(' ','') 34 35 Should Be True ${setting_status} >= 1.5 36 Should Contain ${version_info} v2 compliant case_insensitive=True 37 38 39Verify Empty SEL 40 [Documentation] Verify IPMI sel clear command clears the SEL entry. 41 [Tags] Verify_Empty_SEL 42 43 Redfish Power Off stack_mode=skip 44 45 # Generate an error log and verify there is one at least. 46 Create Test PEL Log 47 ${resp}= Run IPMI Standard Command sel elist last 1 48 Log To Console ${resp} 49 50 Should Contain Any ${resp} system hardware failure Asserted 51 ... msg=Add SEL Entry failed. 52 53 # Send SEL clear command and verify if it really clears up the SEL entry. 54 Run IPMI Standard Command sel clear 55 56 # Added a delay for IPMI SEL to clear completely. 57 Sleep 5s 58 59 ${resp}= Run IPMI Standard Command sel list 60 61 # After executing the IPMI SEL clear command, there will be an informational 62 # SEL entry in the IPMI SEL. Therefore, checking if the IPMI SEL count is 1 63 # after clearing SEL. 64 65 ${sel_count}= Get Line Count ${resp} 66 Should Be Equal As Strings ${sel_count} 1 67 68 69Verify Add SEL Entry 70 [Documentation] Verify add SEL entry. 71 [Tags] Verify_Add_SEL_Entry 72 [Teardown] Run Keywords FFDC On Test Case Fail AND Run IPMI Standard Command sel clear 73 74 # The IPMI raw command to generate Temp sensor error is no longer working. 75 # Our aim is to check if the SEL command is listed in IPMI or not. 76 # Original keyword "Create User Defined SEL" for reference 77 Create Test PEL Log 78 79 # Get last SEL entry. 80 ${resp}= Run IPMI Standard Command sel elist last 1 81 # output: 82 # 1 | 11/17/2021 | 07:49:20 | System Event #0x01 | Undetermined system hardware failure | Asserted 83 Run Keywords Should Contain ${resp} system hardware failure AND 84 ... Should Contain ${resp} Asserted msg=Add SEL Entry failed. 85 86 87Verify Add SEL Entry For Any Random Sensor 88 [Documentation] Create SEL entry and verify for any given random sensor. 89 [Tags] Verify_Add_SEL_Entry_For_Any_Random_Sensor 90 [Teardown] Run Keywords FFDC On Test Case Fail AND Run IPMI Standard Command sel clear 91 92 # Get any sensor available from sensor list. 93 ${sensor_name}= Fetch One Threshold Sensor From Sensor List 94 95 # Get Sensor ID from SDR get "sensor". 96 ${sensor_data1}= Fetch Sensor Details From SDR ${sensor_name} Sensor ID 97 ${sensor_number}= Get Bytes From SDR Sensor ${sensor_data1} 98 99 # Get Sensor Type from SDR get "sensor". 100 ${sensor_data2}= Fetch Sensor Details From SDR ${sensor_name} Sensor Type (Threshold) 101 ${sensor_type_id}= Get Bytes From SDR Sensor ${sensor_data2} 102 103 # Add SEL Entry. 104 # ${sel_entry_id} is the Record ID for added record (LSB First). 105 ${sel_create_resp}= Create SEL ${sensor_type_id} ${sensor_number} 106 ${sel_entry_id}= Split String ${sel_create_resp} 107 108 # Get last SEL entry. 109 ${resp}= Run IPMI Standard Command sel elist 110 Should Not Contain ${resp} ${sel_no_entry_msg} 111 112 # Output of the Sel elist. 113 # Below example is a continuous line statement. 114 # N | MM/DD/YYYY | HH:MM:SS | Sensor_Type Sensor_Name | 115 # Lower Non-critical going low | Asserted | Reading 0. 116 117 ${get_sel_entry}= Get Lines Containing String ${resp} ${sensor_name} 118 ${sel_entry}= Get Lines Containing String ${get_sel_entry} ${event_type} 119 Should Contain ${sel_entry} ${event_dir} msg=Add SEL Entry failed. 120 121 # Get SEL Entry IPMI Raw Command. 122 ${entry}= Get SEL Entry Via IPMI ${sel_entry_id[0]} ${sel_entry_id[1]} 123 124 # Compare SEL Record ID. 125 ${sel_record_id}= Set Variable ${entry[2:4]} 126 Should Be Equal ${sel_record_id} ${sel_entry_id} 127 128 # Sensor type compare. 129 Should Be Equal ${sensor_type_id} ${entry[12]} 130 131 # Sensor number compare. 132 Should Be Equal ${sensor_number} ${entry[13]} 133 134 135Verify Reserve SEL 136 [Documentation] Verify reserve SEL. 137 [Tags] Verify_Reserve_SEL 138 139 ${resp}= Run IPMI Command 140 ... ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]} 141 ${reserve_id}= Split String ${resp} 142 143 # Execute clear SEL raw command with Reservation ID. 144 # Command will not execute unless the correct Reservation ID value is provided. 145 Run IPMI Command 146 ... 0x0a 0x47 0x${reserve_id[0]} 0x${reserve_id[1]} 0x43 0x4c 0x52 0xaa 147 148 # Check SEL list. 149 ${resp}= Run IPMI Standard Command sel list 150 Should Contain ${resp} SEL has no entries case_insensitive=True 151 152 153Verify IPMI SEL Most Recent Addition Timestamp 154 [Documentation] Verify most recent addition timestamp in SEL info. 155 [Tags] Verify_IPMI_SEL_Most_Recent_Addition_Timestamp 156 157 # Get Most Recent Addition Timestamp from SEL Info. 158 ${addition_timestamp}= Get Most Recent Addition Timestamp From SEL Info 159 160 IF '${addition_timestamp}' != 'ffffffff' 161 # Convert to epoch timestamp. 162 ${epoch_addition}= Convert To Integer ${addition_timestamp} 16 163 164 # Get SEL List last 1 entry date and time and convert to epoch timestamp. 165 ${sel_epoch_time}= Get SEL Elist Last Entry Date In Epoch 166 167 # Compare epoch of sel entry timestamp and last addition timestamp. 168 ${diff}= Evaluate int(${sel_epoch_time}) - int(${epoch_addition}) 169 Should Be True ${diff}<=600 170 171 ELSE 172 # Get any Sensor available from Sensor list 173 ${sensor_name}= Fetch One Threshold Sensor From Sensor List 174 175 # Get Sensor ID from SDR Get "sensor" and Identify Sensor ID. 176 ${sensor_data1}= Fetch Sensor Details From SDR ${sensor_name} Sensor ID 177 ${sensor_number}= Get Bytes From SDR Sensor ${sensor_data1} 178 179 # Get Sensor Type from SDR Get "sensor" and Identify Sensor Type. 180 ${sensor_data2}= Fetch Sensor Details From SDR ${sensor_name} Sensor Type (Threshold) 181 ${sensor_type_id}= Get Bytes From SDR Sensor ${sensor_data2} 182 183 # Add SEL Entry. 184 ${sel_create_resp}= Create SEL ${sensor_type_id} ${sensor_number} 185 186 # Get SEL List last 1 entry date and time and convert to epoch timestamp. 187 ${sel_epoch_time}= Get SEL Elist Last Entry Date In Epoch 188 189 # Get Most Recent Addition Timestamp from SEL Info. 190 ${addition}= Get Most Recent Addition Timestamp From SEL Info 191 ${epoch_addition}= Convert To Integer ${addition} 16 192 193 # Compare epoch of sel entry timestamp and last addition timestamp. 194 ${diff}= Evaluate int(${epoch_addition}) - int(${sel_epoch_time}) 195 Should Be True ${diff}<=5 196 END 197 198 199Verify IPMI SEL Most Recent Erase Timestamp 200 [Documentation] Verify Most Recent Erase Timestamp In SEL Info with current 201 ... BMC epoch timestamp. 202 [Tags] Verify_IPMI_SEL_Most_Recent_Erase_Timestamp 203 204 # Get BMC Current Time. 205 ${bmc_epoch_time}= Get BMC Time In Epoch 206 207 # Get Most Recent Addition Timestamp from SEL Info. 208 ${addition_timestamp}= Get Most Recent Addition Timestamp From SEL Info 209 Should Be Equal ${addition_timestamp} ffffffff 210 211 # Get Most Recent Erase Timestamp from SEL Info. 212 ${erase_timestamp}= Get Most Recent Erase Timestamp From SEL Info 213 ${epoch_erase}= Convert To Integer ${erase_timestamp} 16 214 215 # Compare epoch of erase timestamp and current bmc timestamp. 216 ${diff}= Evaluate int(${epoch_erase}) - int(${bmc_epoch_time}) 217 Should Be True ${diff}<=5 218 219 220Verify Clear SEL With Invalid Reservation ID 221 [Documentation] Verify clear SEL After generating another reserve ID. 222 [Tags] Verify_Clear_SEL_With_Invalid_Reservation_ID 223 224 # Reserve Sel command - 1. 225 ${resp}= Run IPMI Command 226 ... ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]} 227 ${reserve_id}= Split String ${resp} 228 229 # Reserve Sel command - 2. 230 ${resp}= Run IPMI Command 231 ... ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]} 232 233 ${cmd}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][0]} 0x${reserve_id[0]} 234 ... 0x${reserve_id[1]} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][1]} 235 236 # Clear SEL command. 237 ${clear_resp}= Run Keyword and Expect Error *${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][4]}* 238 ... Run IPMI Command ${cmd} 239 Should Contain ${clear_resp} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][5]} 240 241 242Verify Reservation ID Erasure Status 243 [Documentation] Verify Erasure status by clearing SEL with Reserve ID and verify the response byte, 244 ... whether erasure status is updated in clear sel command response data using new Reserve ID. 245 [Tags] Verify_Reservation_ID_Erasure_Status 246 247 # Generate Reserve ID 1. 248 ${resp}= Run IPMI Command 249 ... ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]} 250 ${reserve_id}= Split String ${resp} 251 252 ${cmd1}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][0]} 0x${reserve_id[0]} 253 ... 0x${reserve_id[1]} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][1]} 254 255 # Execute clear SEL raw command with Reservation ID. 256 # Command will not execute unless the correct Reservation ID value is provided. 257 Run IPMI Command ${cmd1} 258 259 # Generate Reserver ID 2. 260 ${resp}= Run IPMI Command 261 ... ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]} 262 ${reserve_id}= Split String ${resp} 263 264 ${cmd2}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][0]} 0x${reserve_id[0]} 265 ... 0x${reserve_id[1]} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][6]} 266 267 # Check the Erasure status of Clear SEL. 268 ${data}= Run IPMI Command ${cmd2} 269 270 # 00 - Erasure in Progress , 01 - Erasure Complete. 271 Should Contain Any ${data} 00 01 272 273 274Verify Clear SEL After Cold Reset 275 [Documentation] Verify Clear SEL for a reserve SEL ID after Cold Reset. 276 [Tags] Verify_Clear_SEL_After_Cold_Reset 277 278 # Reserve Sel command. 279 ${resp}= Run IPMI Command 280 ... ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]} 281 ${reserve_id}= Split String ${resp} 282 283 # Run Cold Reset. 284 IPMI MC Reset Cold (off) 285 286 ${cmd}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][0]} 0x${reserve_id[0]} 287 ... 0x${reserve_id[1]} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][1]} 288 289 # Clear SEL command. 290 ${clear_resp}= Run Keyword and Expect Error *${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][5]}* 291 ... Run IPMI Command ${cmd} 292 293 Should Contain ${clear_resp} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][4]} 294 295 296Delete Non Existing SEL Event Entry 297 [Documentation] Delete non existing SEL event entry. 298 [Tags] Delete_Non_Existing_SEL_Event_Entry 299 300 ${sel_delete}= Run Keyword And Expect Error * 301 ... Run IPMI Standard Command sel delete 100 302 Should Contain ${sel_delete} Unable to delete entry 303 ... case_insensitive=True 304 305 306Delete Invalid SEL Event Entry 307 [Documentation] Delete invalid SEL event entry. 308 [Tags] Delete_Invalid_SEL_Event_Entry 309 310 ${sel_delete}= Run Keyword And Expect Error * 311 ... Run IPMI Standard Command sel delete abc 312 Should Contain ${sel_delete} Given SEL ID 'abc' is invalid 313 ... case_insensitive=True 314 315 316Verify IPMI SEL Event Last Add Time 317 [Documentation] Verify IPMI SEL's last added timestamp. 318 [Tags] Verify_IPMI_SEL_Event_Last_Add_Time 319 [Setup] Install Tarball For Error Creation 320 321 Create Test Error Log 322 ${sel_time}= Run IPMI Standard Command sel time get 323 ${sel_time}= Convert Date ${sel_time} 324 ... date_format=%m/%d/%Y %H:%M:%S exclude_millis=True 325 326 ${sel_last_add_time}= Get IPMI SEL Setting Last Add Time 327 ${sel_last_add_time}= Convert Date ${sel_last_add_time} 328 ... date_format=%m/%d/%Y %H:%M:%S exclude_millis=True 329 330 ${time_diff}= 331 ... Subtract Date From Date ${sel_last_add_time} ${sel_time} 332 333 # Verify if the delay in current time check and last add SEL time 334 # is less or equals to 2 seconds. 335 Should Be True ${time_diff} <= 2 336 337 338Verify IPMI SEL Event Entries 339 [Documentation] Verify IPMI SEL's entries info. 340 [Tags] Verify_IPMI_SEL_Event_Entries 341 [Setup] Install Tarball For Error Creation 342 343 # Clear all SEL entries using IPMI command. 344 Run IPMI Standard Command sel clear 345 346 # Added a delay for IPMI SEL to clear completely. 347 Sleep 5s 348 349 # Generate error logs of random count. 350 ${count}= Evaluate random.randint(1, 5) modules=random 351 Repeat Keyword ${count} Create Test Error Log 352 353 ${sel_entries_count}= Get IPMI SEL Setting Entries 354 355 # After issuing the IPMI SEL clear command. 356 # There will be one informational SEL entry in the IPMI SEL. 357 # So comparing the IPMI SEL count with this additional single entry. 358 Should Be Equal As Strings ${sel_entries_count} ${count + 1} 359 360 361*** Keywords *** 362 363Create User Defined SEL 364 [Documentation] Create a user defined tempearature sensor SEL. 365 366 # Create a SEL. 367 # Example: 368 # a | 02/14/2020 | 01:16:58 | Temperature #0x17 | | Asserted 369 Run IPMI Command 370 ... 0x0a 0x44 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x04 0x01 ${sensor_number} 0x00 0xa0 0x04 0x07 371 372 373Get SEL Entry Via IPMI 374 [Documentation] Get SEL Entry Via IPMI raw command. 375 [Arguments] ${record1} ${record2} 376 377 # Description of Argument(s): 378 # ${record1} Record ID for added record, LS Byte 379 # ${record2} Record ID for added record, MS Byte 380 381 # For example, when a first sel entry is added with IPMI raw command, the response will be "01 00". 382 # Here, ${record1} is 01, and ${record2} is 00. 383 384 ${cmd}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Get_SEL_Entry'][0]} 0x${record1} 385 ... 0x${record2} ${IPMI_RAW_CMD['SEL_entry']['Get_SEL_Entry'][1]} 386 387 # Get SEL Entry Raw command. 388 ${resp}= Run IPMI Command ${cmd} 389 ${resp}= Split String ${resp} 390 391 [Return] ${resp} 392 393 394Get Most Recent Addition Timestamp From SEL Info 395 [Documentation] Get Most recent addition timestamp From SEL Info. 396 397 # Get SEL Info raw command. 398 ${sel_info}= Get SEL Info Via IPMI 399 400 # Get Most Recent Addition timestamp in hex. 401 ${addition_timestamp}= Set Variable ${sel_info[5:9]} 402 Reverse List ${addition_timestamp} 403 ${addition_timestamp}= Evaluate "".join(${addition_timestamp}) 404 405 [Return] ${addition_timestamp} 406 407 408Get Most Recent Erase Timestamp From SEL Info 409 [Documentation] Get Most recent erase timestamp From SEL Info. 410 411 # Get SEL Info Raw command. 412 ${sel_info}= Get SEL Info Via IPMI 413 414 # Get Most Recent Erase timestamp in hex. 415 ${erase_timestamp}= Set Variable ${sel_info[9:13]} 416 Reverse List ${erase_timestamp} 417 ${erase_timestamp}= Evaluate "".join(${erase_timestamp}) 418 419 [Return] ${erase_timestamp} 420 421 422Get SEL Elist Last Entry Date In Epoch 423 [Documentation] Get the time from SEL elist last entry and returns epoch time. 424 425 # Get SEL list last entry. 426 ${resp}= Run IPMI Standard Command sel elist last 1 427 428 # Get date from the sel entry and convert to epoch timestamp. 429 ${sel_entry_date}= Fetch Added SEL Date ${resp} 430 ${epoch_date}= Convert Date ${sel_entry_date} epoch exclude_millis=yes date_format=%m/%d/%Y %H:%M:%S 431 432 [Return] ${epoch_date} 433 434 435Get BMC Time In Epoch 436 [Documentation] Get the current time from BMC and returns epoch time. 437 438 # Get the bmc native bmc date command response. 439 ${date}= Get Current Date from BMC 440 441 ${epoch_date}= Convert Date ${date} epoch exclude_millis=yes date_format=%m/%d/%Y %H:%M:%S 442 443 [Return] ${epoch_date} 444 445 446Install Tarball For Error Creation 447 [Documentation] Install tarball for error log creation. 448 449 ${status}= Run Keyword And Return Status Logging Test Binary Exist 450 Run Keyword If ${status} == ${False} Install Tarball 451 452 453Test Setup Execution 454 [Documentation] Do test setup tasks. 455 456 Run IPMI Standard Command sel clear 457 Sleep 5s 458