Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 1 | *** Settings *** |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 2 | Documentation 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. |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 6 | |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 7 | Resource ../lib/dvt/obmc_driver_vars.txt |
| 8 | Resource ../lib/list_utils.robot |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 9 | Resource ../lib/openbmc_ffdc.robot |
| 10 | |
| 11 | Library ../lib/gen_robot_print.py |
Michael Walsh | 5530229 | 2017-01-10 11:43:02 -0600 | [diff] [blame] | 12 | Library ../lib/gen_misc.py |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 13 | Library ../lib/gen_robot_plug_in.py |
| 14 | Library ../lib/gen_robot_valid.py |
| 15 | Library ../lib/state.py |
| 16 | Library ../lib/boot/powerons.py |
| 17 | Library ../lib/boot/poweroffs.py |
| 18 | Library ../lib/obmc_boot_test.py |
| 19 | |
| 20 | # WITH NAME boot_results |
| 21 | |
| 22 | *** Variables *** |
| 23 | # Initialize program parameters variables. |
| 24 | # Create parm_list containing all of our program parameters. This is used by |
| 25 | # 'Rqprint Pgm Header' |
| 26 | @{parm_list} openbmc_nickname openbmc_host openbmc_username |
| 27 | ... openbmc_password os_host os_username os_password pdu_host |
| 28 | ... pdu_username pdu_password pdu_slot_no openbmc_serial_host |
| 29 | ... openbmc_serial_port boot_stack boot_list max_num_tests |
| 30 | ... plug_in_dir_paths status_file_path openbmc_model boot_pass boot_fail |
Michael Walsh | 5530229 | 2017-01-10 11:43:02 -0600 | [diff] [blame] | 31 | ... ffdc_dir_path_style ffdc_check state_change_timeout power_on_timeout |
| 32 | ... power_on_timeout test_mode quiet debug |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 33 | |
| 34 | # Initialize each program parameter. |
| 35 | ${openbmc_nickname} ${EMPTY} |
| 36 | ${openbmc_host} ${EMPTY} |
| 37 | ${openbmc_username} root |
| 38 | ${openbmc_password} 0penBmc |
| 39 | ${os_host} ${EMPTY} |
| 40 | ${os_username} root |
| 41 | ${os_password} P@ssw0rd |
| 42 | ${pdu_host} ${EMPTY} |
| 43 | ${pdu_username} admin |
| 44 | ${pdu_password} admin |
| 45 | ${pdu_slot_no} ${EMPTY} |
| 46 | ${openbmc_serial_host} ${EMPTY} |
| 47 | ${openbmc_serial_port} ${EMPTY} |
| 48 | ${boot_stack} ${EMPTY} |
| 49 | ${boot_list} ${EMPTY} |
| 50 | ${max_num_tests} 0 |
| 51 | ${plug_in_dir_paths} ${EMPTY} |
| 52 | ${status_file_path} ${EMPTY} |
| 53 | ${openbmc_model} ${EMPTY} |
| 54 | # The reason boot_pass and boot_fail are parameters is that it is possible to |
| 55 | # be called by a program that has already done some tests. This allows us to |
| 56 | # keep the grand total. |
| 57 | ${boot_pass} ${0} |
| 58 | ${boot_fail} ${0} |
Michael Walsh | b412595 | 2016-12-13 15:49:50 -0600 | [diff] [blame] | 59 | ${ffdc_dir_path_style} ${EMPTY} |
| 60 | ${ffdc_check} ${EMPTY} |
Michael Walsh | 5530229 | 2017-01-10 11:43:02 -0600 | [diff] [blame] | 61 | ${state_change_timeout} 1 min |
| 62 | ${power_on_timeout} 14 mins |
| 63 | ${power_off_timeout} 2 mins |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 64 | ${test_mode} 0 |
| 65 | ${quiet} 0 |
| 66 | ${debug} 0 |
| 67 | |
Michael Walsh | b412595 | 2016-12-13 15:49:50 -0600 | [diff] [blame] | 68 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 69 | # Plug-in variables. |
| 70 | ${shell_rc} 0x00000000 |
| 71 | ${fail_on_plug_in_failure} 1 |
| 72 | ${return_on_non_zero_rc} 0 |
| 73 | |
| 74 | ${next_boot} ${EMPTY} |
| 75 | # State dictionary. Initializing to a realistic state for testing in |
| 76 | # test_mode. |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 77 | |
| 78 | # Flag variables. |
| 79 | ${cp_setup_called} ${0} |
| 80 | # test_really_running is needed by DB_Logging plug-in. |
| 81 | ${test_really_running} ${1} |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 82 | |
| 83 | *** Test Cases *** |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 84 | Randomized Boot Testing |
| 85 | [Documentation] Performs random, repeated boots. |
| 86 | [Tags] Randomized_boot_testing |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 87 | |
| 88 | # Call the Main keyword to prevent any dots from appearing in the console |
| 89 | # due to top level keywords. |
| 90 | Main |
| 91 | |
| 92 | *** Keywords *** |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 93 | ############################################################################### |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 94 | Main |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 95 | [Teardown] Program Teardown |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 96 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 97 | Setup |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 98 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 99 | :For ${BOOT_COUNT} IN RANGE ${max_num_tests} |
| 100 | \ Test Loop Body ${BOOT_COUNT} |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 101 | |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 102 | Rqprint Timen Completed all requested boot tests. |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 103 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 104 | ############################################################################### |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 105 | |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 106 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 107 | ############################################################################### |
| 108 | Setup |
| 109 | [Documentation] Do general program setup tasks. |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 110 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 111 | Validate Parms |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 112 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 113 | Rqprint Pgm Header |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 114 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 115 | Create Boot Results Table |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 116 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 117 | # Preserve the values of boot_pass/boot_fail that were passed in. |
| 118 | Set Global Variable ${initial_boot_pass} ${boot_pass} |
| 119 | Set Global Variable ${initial_boot_fail} ${boot_fail} |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 120 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 121 | # Call "setup" plug-ins, if any. |
| 122 | Plug In Setup |
| 123 | ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages |
| 124 | ... call_point=setup |
| 125 | Should Be Equal '${rc}' '${0}' |
| 126 | |
| 127 | # Keyword "FFDC" will fail if TEST_MESSAGE is not set. |
| 128 | Set Global Variable ${TEST_MESSAGE} ${EMPTY} |
| 129 | |
| 130 | # Setting cp_setup_called lets our Teardown know that it needs to call |
| 131 | # the cleanup plug-in call point. |
| 132 | Set Global Variable ${cp_setup_called} ${1} |
| 133 | |
| 134 | Rqprint Timen Getting system state. |
| 135 | # The state dictionary must be primed before calling Test Loop Body. |
| 136 | ${temp_state}= Run Keyword If '${test_mode}' == '0' Get State |
| 137 | ... ELSE Create Dictionary &{default_state} |
| 138 | Set Global Variable &{state} &{temp_state} |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 139 | Rqpvars state |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 140 | |
| 141 | ############################################################################### |
| 142 | |
| 143 | |
| 144 | ############################################################################### |
| 145 | Validate Parms |
| 146 | [Documentation] Validate all program parameters. |
| 147 | |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 148 | Rqprintn |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 149 | |
| 150 | Rvalid Value AVAIL_BOOTS |
| 151 | Rvalid Value openbmc_host |
| 152 | Rvalid Value openbmc_username |
| 153 | Rvalid Value openbmc_password |
| 154 | # os_host is optional so no validation is being done. |
Michael Walsh | b412595 | 2016-12-13 15:49:50 -0600 | [diff] [blame] | 155 | Run Keyword If '${OS_HOST}' != '${EMPTY}' Run Keywords |
| 156 | ... Rvalid Value os_username AND |
| 157 | ... Rvalid Value os_password |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 158 | Rvalid Value pdu_host |
| 159 | Rvalid Value pdu_username |
| 160 | Rvalid Value pdu_password |
| 161 | Rvalid Integer pdu_slot_no |
| 162 | Rvalid Value openbmc_serial_host |
| 163 | Rvalid Integer openbmc_serial_port |
| 164 | Rvalid Integer max_num_tests |
| 165 | Rvalid Value openbmc_model |
| 166 | Rvalid Integer boot_pass |
| 167 | Rvalid Integer boot_fail |
| 168 | |
| 169 | ${boot_pass_temp}= Convert To Integer ${boot_pass} |
| 170 | Set Global Variable ${boot_pass} ${boot_pass_temp} |
| 171 | ${boot_fail_temp}= Convert To Integer ${boot_fail} |
| 172 | Set Global Variable ${boot_fail} ${boot_fail_temp} |
| 173 | |
| 174 | ${temp_arr}= Rvalidate Plug Ins ${plug_in_dir_paths} |
| 175 | Set Global Variable @{plug_in_packages_list} @{temp_arr} |
| 176 | |
Michael Walsh | 5530229 | 2017-01-10 11:43:02 -0600 | [diff] [blame] | 177 | Run Keyword If '${openbmc_nickname}' == '${EMPTY}' |
| 178 | ... Set Global Variable ${openbmc_nickname} ${openbmc_host} |
| 179 | |
Michael Walsh | b412595 | 2016-12-13 15:49:50 -0600 | [diff] [blame] | 180 | Set FFDC Dir Path Style |
| 181 | |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 182 | ${default_state}= Return Default State |
| 183 | Set Global Variable ${state} ${default_state} |
| 184 | Set Global Variable ${default_state} ${default_state} |
| 185 | |
Michael Walsh | b412595 | 2016-12-13 15:49:50 -0600 | [diff] [blame] | 186 | ############################################################################### |
| 187 | |
| 188 | |
| 189 | ############################################################################### |
| 190 | Set FFDC Dir Path Style |
| 191 | |
| 192 | Run Keyword If '${ffdc_dir_path_style}' != '${EMPTY}' Return from Keyword |
| 193 | |
| 194 | ${temp}= Run Keyword and Continue On Failure Get Environment Variable |
| 195 | ... FFDC_DIR_PATH_STYLE ${0} |
| 196 | |
| 197 | Set Global Variable ${ffdc_dir_path_style} ${temp} |
| 198 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 199 | ############################################################################### |
| 200 | |
| 201 | |
| 202 | ############################################################################### |
| 203 | Program Teardown |
| 204 | [Documentation] Clean up after this program. |
| 205 | |
| 206 | Run Keyword If '${cp_setup_called}' == '1' Run Keywords |
| 207 | ... Plug In Setup AND |
| 208 | ... Rprocess Plug In Packages call_point=cleanup |
| 209 | ... stop_on_plug_in_failure=1 |
| 210 | |
| 211 | Rqprint Pgm Footer |
| 212 | |
| 213 | ############################################################################### |
| 214 | |
| 215 | |
| 216 | ############################################################################### |
| 217 | Test Loop Body |
| 218 | [Documentation] The main loop body for the loop in "main". |
| 219 | [Arguments] ${BOOT_COUNT} |
| 220 | |
| 221 | Rqprintn |
| 222 | Rqprint Timen Starting boot ${BOOT_COUNT+1} of ${max_num_tests}. |
| 223 | |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 224 | Rqpvars state |
| 225 | |
| 226 | ${loc_next_boot}= Select Boot ${state} |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 227 | Set Global Variable ${next_boot} ${loc_next_boot} |
| 228 | |
Michael Walsh | 5530229 | 2017-01-10 11:43:02 -0600 | [diff] [blame] | 229 | # Clear this file. Plug-ins may now write to it. |
| 230 | Remove File ${FFDC_LIST_FILE_PATH} |
| 231 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 232 | ${status} ${msg}= Run Keyword And Ignore Error Run Boot ${next_boot} |
| 233 | Run Keyword If '${status}' == 'FAIL' rprint ${msg} |
| 234 | |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 235 | Rqprintn |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 236 | Run Keyword If '${BOOT_STATUS}' == 'PASS' Run Keywords |
| 237 | ... Set Global Variable ${boot_success} ${1} AND |
| 238 | ... Rqprint Timen BOOT_SUCCESS: "${next_boot}" succeeded. |
| 239 | ... ELSE Run Keywords |
| 240 | ... Set Global Variable ${boot_success} ${0} AND |
| 241 | ... Rqprint Timen BOOT_FAILED: ${next_boot} failed. |
| 242 | |
| 243 | Update Boot Results Table ${next_boot} ${BOOT_STATUS} |
| 244 | |
| 245 | # NOTE: A post_test_case call point failure is NOT counted as a boot |
| 246 | # failure. |
| 247 | Plug In Setup |
| 248 | ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages |
| 249 | ... call_point=post_test_case stop_on_plug_in_failure=1 |
| 250 | |
Michael Walsh | 5530229 | 2017-01-10 11:43:02 -0600 | [diff] [blame] | 251 | ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages |
| 252 | ... call_point=ffdc_check shell_rc=${0x00000200} |
| 253 | ... stop_on_plug_in_failure=1 stop_on_non_zero_rc=1 |
| 254 | |
| 255 | Run Keyword If |
| 256 | ... '${BOOT_STATUS}' != 'PASS' or '${FFDC_CHECK}' == 'All' or '${shell_rc}' == '${0x00000200}' |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 257 | ... Run Keyword and Continue On Failure My FFDC |
| 258 | |
| 259 | # Run plug-ins to see if we ought to stop execution. |
| 260 | Plug In Setup |
| 261 | ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages |
| 262 | ... call_point=stop_check |
| 263 | Run Keyword If '${rc}' != '${0}' Run Keywords |
| 264 | ... Rprint Error Report Stopping as requested by user. |
| 265 | ... Fail |
| 266 | |
| 267 | Print Boot Results Table |
| 268 | Rqprint Timen Finished boot ${BOOT_COUNT+1} of ${max_num_tests}. |
| 269 | |
| 270 | Rqprint Timen Getting system state. |
| 271 | # The state must be refreshed before calling Test Loop Body again. |
| 272 | ${temp_state}= Run Keyword If '${test_mode}' == '0' Get State |
| 273 | ... quiet=${1} |
| 274 | ... ELSE Create Dictionary &{default_state} |
| 275 | Set Global Variable &{state} &{temp_state} |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 276 | Rqpvars state |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 277 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 278 | ############################################################################### |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 279 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 280 | |
| 281 | ############################################################################### |
| 282 | Run Boot |
| 283 | [Documentation] Run the selected boot and mark the status when complete. |
| 284 | [Arguments] ${boot_keyword} |
| 285 | [Teardown] Set Global Variable ${BOOT_STATUS} ${KEYWORD STATUS} |
| 286 | |
| 287 | # boot_keyword The name of the boot to run, which corresponds to the |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 288 | # keyword to run. (i.e "BMC Power On") |
| 289 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 290 | Print Test Start Message ${boot_keyword} |
Leah McNutt | c9c9cde | 2016-10-07 16:53:52 +0000 | [diff] [blame] | 291 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 292 | Plug In Setup |
| 293 | ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages |
| 294 | ... call_point=pre_boot |
| 295 | Should Be Equal '${rc}' '${0}' |
| 296 | |
| 297 | @{cmd_buf}= Create List ${boot_keyword} |
| 298 | rqpissuing_keyword ${cmd_buf} ${test_mode} |
| 299 | Run Keyword If '${test_mode}' == '0' Run Keyword @{cmd_buf} |
| 300 | |
| 301 | Plug In Setup |
| 302 | ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages |
| 303 | ... call_point=post_boot |
| 304 | Should Be Equal '${rc}' '${0}' |
| 305 | |
| 306 | ############################################################################### |
| 307 | |
| 308 | |