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