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_misc.py
13Library   ../lib/gen_robot_plug_in.py
14Library   ../lib/gen_robot_valid.py
15Library   ../lib/state.py
16Library   ../lib/boot/powerons.py
17Library   ../lib/boot/poweroffs.py
18Library   ../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
31...  ffdc_dir_path_style  ffdc_check  state_change_timeout  power_on_timeout
32...  power_on_timeout  test_mode  quiet  debug
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}
59${ffdc_dir_path_style}      ${EMPTY}
60${ffdc_check}               ${EMPTY}
61${state_change_timeout}     1 min
62${power_on_timeout}         14 mins
63${power_off_timeout}        2 mins
64${test_mode}                0
65${quiet}                    0
66${debug}                    0
67
68
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.
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}
82
83*** Test Cases ***
84Randomized Boot Testing
85    [Documentation]  Performs random, repeated boots.
86    [Tags]  Randomized_boot_testing
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 ***
93###############################################################################
94Main
95    [Teardown]  Program Teardown
96
97    Setup
98
99    :For  ${BOOT_COUNT}  IN RANGE  ${max_num_tests}
100    \  Test Loop Body  ${BOOT_COUNT}
101
102    Rqprint Timen  Completed all requested boot tests.
103
104###############################################################################
105
106
107###############################################################################
108Setup
109    [Documentation]  Do general program setup tasks.
110
111    Validate Parms
112
113    Rqprint Pgm Header
114
115    Create Boot Results Table
116
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}
120
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}
139    Rqpvars  state
140
141###############################################################################
142
143
144###############################################################################
145Validate Parms
146    [Documentation]  Validate all program parameters.
147
148    Rqprintn
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.
155    Run Keyword If  '${OS_HOST}' != '${EMPTY}'  Run Keywords
156    ...  Rvalid Value  os_username  AND
157    ...  Rvalid Value  os_password
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
177    Run Keyword If  '${openbmc_nickname}' == '${EMPTY}'
178    ...  Set Global Variable  ${openbmc_nickname}  ${openbmc_host}
179
180    Set FFDC Dir Path Style
181
182    ${default_state}=  Return Default State
183    Set Global Variable  ${state}  ${default_state}
184    Set Global Variable  ${default_state}  ${default_state}
185
186###############################################################################
187
188
189###############################################################################
190Set 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
199###############################################################################
200
201
202###############################################################################
203Program 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###############################################################################
217Test 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
224    Rqpvars  state
225
226    ${loc_next_boot}=  Select Boot  ${state}
227    Set Global Variable  ${next_boot}  ${loc_next_boot}
228
229    # Clear this file.  Plug-ins may now write to it.
230    Remove File  ${FFDC_LIST_FILE_PATH}
231
232    ${status}  ${msg}=  Run Keyword And Ignore Error  Run Boot  ${next_boot}
233    Run Keyword If  '${status}' == 'FAIL'  rprint  ${msg}
234
235    Rqprintn
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
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}'
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}
276    Rqpvars  state
277
278###############################################################################
279
280
281###############################################################################
282Run 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
288    #                  keyword to run. (i.e "BMC Power On")
289
290    Print Test Start Message  ${boot_keyword}
291
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
309