1*** Settings *** 2Documentation Do random repeated boots based on the state of the BMC machine. 3... The number of repetitions is designated by ${max_num_tests}. Keyword 4... names that are listed in @{AVAIL_BOOTS} become the selection of possible 5... boots for the test. 6 7Resource ../lib/dvt/obmc_driver_vars.txt 8Resource ../lib/list_utils.robot 9Resource ../lib/openbmc_ffdc.robot 10 11Library ../lib/gen_robot_print.py 12Library ../lib/gen_robot_plug_in.py 13Library ../lib/gen_robot_valid.py 14Library ../lib/state.py 15Library ../lib/boot/powerons.py 16Library ../lib/boot/poweroffs.py 17Library ../lib/obmc_boot_test.py 18 19# WITH NAME boot_results 20 21*** Variables *** 22# Initialize program parameters variables. 23# Create parm_list containing all of our program parameters. This is used by 24# 'Rqprint Pgm Header' 25@{parm_list} openbmc_nickname openbmc_host openbmc_username 26... openbmc_password os_host os_username os_password pdu_host 27... pdu_username pdu_password pdu_slot_no openbmc_serial_host 28... openbmc_serial_port boot_stack boot_list max_num_tests 29... plug_in_dir_paths status_file_path openbmc_model boot_pass boot_fail 30... ffdc_dir_path_style ffdc_check test_mode quiet debug 31 32# Initialize each program parameter. 33${openbmc_nickname} ${EMPTY} 34${openbmc_host} ${EMPTY} 35${openbmc_username} root 36${openbmc_password} 0penBmc 37${os_host} ${EMPTY} 38${os_username} root 39${os_password} P@ssw0rd 40${pdu_host} ${EMPTY} 41${pdu_username} admin 42${pdu_password} admin 43${pdu_slot_no} ${EMPTY} 44${openbmc_serial_host} ${EMPTY} 45${openbmc_serial_port} ${EMPTY} 46${boot_stack} ${EMPTY} 47${boot_list} ${EMPTY} 48${max_num_tests} 0 49${plug_in_dir_paths} ${EMPTY} 50${status_file_path} ${EMPTY} 51${openbmc_model} ${EMPTY} 52# The reason boot_pass and boot_fail are parameters is that it is possible to 53# be called by a program that has already done some tests. This allows us to 54# keep the grand total. 55${boot_pass} ${0} 56${boot_fail} ${0} 57${ffdc_dir_path_style} ${EMPTY} 58${ffdc_check} ${EMPTY} 59${test_mode} 0 60${quiet} 0 61${debug} 0 62 63 64# Plug-in variables. 65${shell_rc} 0x00000000 66${fail_on_plug_in_failure} 1 67${return_on_non_zero_rc} 0 68 69${next_boot} ${EMPTY} 70# State dictionary. Initializing to a realistic state for testing in 71# test_mode. 72&{default_state} power=1 73... bmc=HOST_BOOTED 74... boot_progress=FW Progress, Starting OS 75... os_ping=1 76... os_login=1 77... os_run_cmd=1 78&{state} &{default_state} 79 80# Flag variables. 81${cp_setup_called} ${0} 82# test_really_running is needed by DB_Logging plug-in. 83${test_really_running} ${1} 84 85*** Test Cases *** 86Randomized Boot Testing 87 [Documentation] Performs random, repeated boots. 88 [Tags] Randomized_boot_testing 89 90 # Call the Main keyword to prevent any dots from appearing in the console 91 # due to top level keywords. 92 Main 93 94*** Keywords *** 95############################################################################### 96Main 97 [Teardown] Program Teardown 98 99 Setup 100 101 :For ${BOOT_COUNT} IN RANGE ${max_num_tests} 102 \ Test Loop Body ${BOOT_COUNT} 103 104 Rprint Timen Completed all requested boot tests. 105 106############################################################################### 107 108 109############################################################################### 110Setup 111 [Documentation] Do general program setup tasks. 112 113 Rprintn 114 115 Validate Parms 116 117 Rqprint Pgm Header 118 119 Create Boot Results Table 120 121 # Preserve the values of boot_pass/boot_fail that were passed in. 122 Set Global Variable ${initial_boot_pass} ${boot_pass} 123 Set Global Variable ${initial_boot_fail} ${boot_fail} 124 125 # Call "setup" plug-ins, if any. 126 Plug In Setup 127 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages 128 ... call_point=setup 129 Should Be Equal '${rc}' '${0}' 130 131 # Keyword "FFDC" will fail if TEST_MESSAGE is not set. 132 Set Global Variable ${TEST_MESSAGE} ${EMPTY} 133 134 # Setting cp_setup_called lets our Teardown know that it needs to call 135 # the cleanup plug-in call point. 136 Set Global Variable ${cp_setup_called} ${1} 137 138 Rqprint Timen Getting system state. 139 # The state dictionary must be primed before calling Test Loop Body. 140 ${temp_state}= Run Keyword If '${test_mode}' == '0' Get State 141 ... ELSE Create Dictionary &{default_state} 142 Set Global Variable &{state} &{temp_state} 143 rpvars state 144 145############################################################################### 146 147 148############################################################################### 149Validate Parms 150 [Documentation] Validate all program parameters. 151 152 rprintn 153 154 Rvalid Value AVAIL_BOOTS 155 Rvalid Value openbmc_host 156 Rvalid Value openbmc_username 157 Rvalid Value openbmc_password 158 # os_host is optional so no validation is being done. 159 Run Keyword If '${OS_HOST}' != '${EMPTY}' Run Keywords 160 ... Rvalid Value os_username AND 161 ... Rvalid Value os_password 162 Rvalid Value pdu_host 163 Rvalid Value pdu_username 164 Rvalid Value pdu_password 165 Rvalid Integer pdu_slot_no 166 Rvalid Value openbmc_serial_host 167 Rvalid Integer openbmc_serial_port 168 Rvalid Integer max_num_tests 169 Rvalid Value openbmc_model 170 Rvalid Integer boot_pass 171 Rvalid Integer boot_fail 172 173 ${boot_pass_temp}= Convert To Integer ${boot_pass} 174 Set Global Variable ${boot_pass} ${boot_pass_temp} 175 ${boot_fail_temp}= Convert To Integer ${boot_fail} 176 Set Global Variable ${boot_fail} ${boot_fail_temp} 177 178 ${temp_arr}= Rvalidate Plug Ins ${plug_in_dir_paths} 179 Set Global Variable @{plug_in_packages_list} @{temp_arr} 180 181 Set FFDC Dir Path Style 182 183############################################################################### 184 185 186############################################################################### 187Set FFDC Dir Path Style 188 189 Run Keyword If '${ffdc_dir_path_style}' != '${EMPTY}' Return from Keyword 190 191 ${temp}= Run Keyword and Continue On Failure Get Environment Variable 192 ... FFDC_DIR_PATH_STYLE ${0} 193 194 Set Global Variable ${ffdc_dir_path_style} ${temp} 195 196############################################################################### 197 198 199############################################################################### 200Program Teardown 201 [Documentation] Clean up after this program. 202 203 Run Keyword If '${cp_setup_called}' == '1' Run Keywords 204 ... Plug In Setup AND 205 ... Rprocess Plug In Packages call_point=cleanup 206 ... stop_on_plug_in_failure=1 207 208 Rqprint Pgm Footer 209 210############################################################################### 211 212 213############################################################################### 214Test Loop Body 215 [Documentation] The main loop body for the loop in "main". 216 [Arguments] ${BOOT_COUNT} 217 218 Rqprintn 219 Rqprint Timen Starting boot ${BOOT_COUNT+1} of ${max_num_tests}. 220 221 ${loc_next_boot}= Select Boot ${state['power']} 222 Set Global Variable ${next_boot} ${loc_next_boot} 223 224 ${status} ${msg}= Run Keyword And Ignore Error Run Boot ${next_boot} 225 Run Keyword If '${status}' == 'FAIL' rprint ${msg} 226 227 rprintn 228 Run Keyword If '${BOOT_STATUS}' == 'PASS' Run Keywords 229 ... Set Global Variable ${boot_success} ${1} AND 230 ... Rqprint Timen BOOT_SUCCESS: "${next_boot}" succeeded. 231 ... ELSE Run Keywords 232 ... Set Global Variable ${boot_success} ${0} AND 233 ... Rqprint Timen BOOT_FAILED: ${next_boot} failed. 234 235 Update Boot Results Table ${next_boot} ${BOOT_STATUS} 236 237 # NOTE: A post_test_case call point failure is NOT counted as a boot 238 # failure. 239 Plug In Setup 240 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages 241 ... call_point=post_test_case stop_on_plug_in_failure=1 242 243 Run Keyword If '${BOOT_STATUS}' != 'PASS' or '${FFDC_CHECK}' == 'All' 244 ... Run Keyword and Continue On Failure My FFDC 245 246 # Run plug-ins to see if we ought to stop execution. 247 Plug In Setup 248 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages 249 ... call_point=stop_check 250 Run Keyword If '${rc}' != '${0}' Run Keywords 251 ... Rprint Error Report Stopping as requested by user. 252 ... Fail 253 254 Print Boot Results Table 255 Rqprint Timen Finished boot ${BOOT_COUNT+1} of ${max_num_tests}. 256 257 Rqprint Timen Getting system state. 258 # The state must be refreshed before calling Test Loop Body again. 259 ${temp_state}= Run Keyword If '${test_mode}' == '0' Get State 260 ... quiet=${1} 261 ... ELSE Create Dictionary &{default_state} 262 Set Global Variable &{state} &{temp_state} 263 rpvars state 264 265############################################################################### 266 267 268############################################################################### 269Select Boot 270 [Documentation] Select a boot test to be run based on our current state. 271 ... Return the chosen boot type. 272 [Arguments] ${power} 273 274 # power The power state of the machine, either zero or one. 275 276 ${boot}= Run Keyword If ${power} == ${0} Select Power On 277 ... ELSE Run Keyword If ${power} == ${1} Select Power Off 278 ... ELSE Run Keywords Log to Console 279 ... **ERROR** BMC not in state to power on or off: "${power}" AND 280 ... Fatal Error 281 282 [Return] ${boot} 283 284############################################################################### 285 286 287############################################################################### 288Select Power On 289 [Documentation] Randomly chooses a boot from the list of Power On boots. 290 291 @{power_on_choices}= Intersect Lists ${VALID_POWER_ON} ${AVAIL_BOOTS} 292 293 ${length}= Get Length ${power_on_choices} 294 295 # Currently selects the first boot in the list of options, rather than 296 # selecting randomly. 297 ${chosen}= Set Variable @{power_on_choices}[0] 298 299 [Return] ${chosen} 300 301############################################################################### 302 303 304############################################################################### 305Select Power Off 306 [Documentation] Randomly chooses an boot from the list of Power Off boots. 307 308 @{power_off_choices}= Intersect Lists ${VALID_POWER_OFF} ${AVAIL_BOOTS} 309 310 ${length}= Get Length ${power_off_choices} 311 312 # Currently selects the first boot in the list of options, rather than 313 # selecting randomly. 314 ${chosen}= Set Variable @{power_off_choices}[0] 315 316 [Return] ${chosen} 317 318############################################################################### 319 320 321############################################################################### 322Run Boot 323 [Documentation] Run the selected boot and mark the status when complete. 324 [Arguments] ${boot_keyword} 325 [Teardown] Set Global Variable ${BOOT_STATUS} ${KEYWORD STATUS} 326 327 # boot_keyword The name of the boot to run, which corresponds to the 328 # keyword to run. (i.e "BMC Power On") 329 330 Print Test Start Message ${boot_keyword} 331 332 Plug In Setup 333 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages 334 ... call_point=pre_boot 335 Should Be Equal '${rc}' '${0}' 336 337 @{cmd_buf}= Create List ${boot_keyword} 338 rqpissuing_keyword ${cmd_buf} ${test_mode} 339 Run Keyword If '${test_mode}' == '0' Run Keyword @{cmd_buf} 340 341 Plug In Setup 342 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages 343 ... call_point=post_boot 344 Should Be Equal '${rc}' '${0}' 345 346############################################################################### 347 348 349############################################################################### 350Print Test Start Message 351 [Documentation] Print a message indicating what boot test is about to run. 352 [Arguments] ${boot_keyword} 353 354 ${doing_msg}= Sprint Timen Doing "${boot_keyword}". 355 rqprint ${doing_msg} 356 357 Append to List ${LAST_TEN} ${doing_msg} 358 ${length}= Get Length ${LAST_TEN} 359 360 Run Keyword If '${length}' > '${10}' Remove From List ${LAST_TEN} 0 361 362############################################################################### 363 364 365############################################################################### 366My FFDC 367 [Documentation] Collect FFDC data. 368 369 # FFDC_LOG_PATH is used by "FFDC" keyword. 370 Set Global Variable ${FFDC_LOG_PATH} ${FFDC_DIR_PATH} 371 372 @{cmd_buf}= Create List FFDC 373 rqpissuing_keyword ${cmd_buf} ${test_mode} 374 Run Keyword If '${test_mode}' == '0' @{cmd_buf} 375 376 Plug In Setup 377 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages 378 ... call_point=ffdc stop_on_plug_in_failure=1 379 380 Log Defect Information 381 382############################################################################### 383 384 385############################################################################### 386Log Defect Information 387 [Documentation] Logs information needed for a defect. This information 388 ... can also be found within the FFDC gathered. 389 390 Rqprintn 391 # indent=0, width=90, linefeed=1, char="=" 392 Rqprint Dashes ${0} ${90} ${1} = 393 Rqprintn Copy this data to the defect: 394 Rqprintn 395 396 Rqpvars @{parm_list} 397 Print Last Ten Boots 398 399 ${rc} ${output}= Run Keyword If '${test_mode}' == '0' 400 ... Run and return RC and Output ls ${LOG_PREFIX}* 401 ... ELSE Set Variable ${0} ${EMPTY} 402 403 Run Keyword If '${rc}' != '${0}' and '${rc}' != 'None' rqpvars rc 404 405 Rqprintn 406 Rqprintn FFDC data files: 407 Rqprintn ${output} 408 409 Rqprintn 410 Rqprint Dashes ${0} ${90} ${1} = 411 412############################################################################### 413 414 415############################################################################### 416Print Last Ten Boots 417 [Documentation] Logs the last ten boots that were performed with their 418 ... starting time stamp. 419 420 # indent 0, 90 chars wide, linefeed, char is "=" 421 Rqprint Dashes ${0} ${90} 422 Rqprintn Last 10 boots: 423 Rqprintn 424 :FOR ${boot_entry} IN @{LAST_TEN} 425 \ rqprint ${boot_entry} 426 Rqprint Dashes ${0} ${90} 427 428############################################################################### 429 430 431