1*** Settings ***
2Documentation  Update the PNOR image on the host for hostboot CI purposes.
3
4Library                 OperatingSystem
5Library                 ../lib/gen_robot_keyword.py
6
7Resource                ../extended/obmc_boot_test_resource.robot
8Resource                ../lib/utils.robot
9Resource                ../lib/connection_client.robot
10Resource                ../lib/openbmc_ffdc.robot
11Resource                ../lib/state_manager.robot
12
13Test Teardown           Test Teardown Execution
14
15Force Tags  BIOS_Code_Update
16
17*** Variables ***
18
19${QUIET}                ${1}
20# OBMC Boot Test failures are not acceptable so we set the threshold to 0.
21${boot_fail_threshold}  ${0}
22# "skip" indicates to OBMC Boot Test that it should only process boot stack
23# items that would change the machine state, i.e. only if the action is
24# needed.
25${stack_mode}           skip
26${update_status}        True
27
28
29*** Test Cases ***
30
31Host BIOS Update
32    [Documentation]  Update PNOR image and verify.
33    [Tags]  Host_BIOS_Update  open-power
34
35    Validate Parameters
36    Prepare BMC For Update
37    Update PNOR Image
38    Verify PNOR Update
39
40Host BIOS Power On
41    [Documentation]  Power On the system and wait for OS
42    [Tags]  Host_BIOS_Power_On  open-power
43
44    Run Keyword If  '${PREV_TEST_STATUS}' == 'PASS'  Validate Power On
45
46*** Keywords ***
47
48Prepare BMC For Update
49    [Documentation]  Prepare system for PNOR update.
50
51    # Call 'OBMC Boot Test' to do a 'REST Power Off', if needed.
52    Run Key U  OBMC Boot Test \ REST Power Off
53    Run Key  Delete Error logs
54
55Update PNOR Image
56    [Documentation]  Copy the PNOR image to the BMC /tmp dir and flash it.
57
58    Run Key  Copy PNOR to BMC
59    ${pnor_path}  ${pnor_basename}=  Split Path  ${PNOR_IMAGE_PATH}
60    Run Key  Flash PNOR \ /tmp/${pnor_basename}
61    Run Key  Wait Until Keyword Succeeds \ 15 min \ 10 sec \ Is PNOR Flash Done
62
63Validate Power On
64    [Documentation]  Power the host on, and validate that the system booted.
65    [Teardown]  Validate Power On Teardown
66
67    # Have to start SOL logging here.  Starting SOL in test setup closes the
68    # connection when bmc reboots.
69    Run Key  Start SOL Console Logging
70    Run Key U  OBMC Boot Test \ REST Power On
71
72Validate Power On Teardown
73    [Documentation]  Teardown after Validate Power On.
74
75    ${keyword_buf}=  Catenate  Stop SOL Console Logging
76    ...  \ targ_file_path=${EXECDIR}${/}logs${/}SOL.log
77    Run Key  ${keyword_buf}
78
79Test Teardown Execution
80    [Documentation]  Log FFDC if test suite fails and collect SOL log for
81    ...              debugging purposes.
82
83    Printn
84    Run Key  FFDC On Test Case Fail
85
86Validate Parameters
87    [Documentation]   Validate parameter and file existence.
88    Should Not Be Empty
89    ...   ${PNOR_IMAGE_PATH}  msg=PNOR image path not set
90
91    OperatingSystem.File Should Exist  ${PNOR_IMAGE_PATH}
92    ...   msg=${PNOR_IMAGE_PATH} File not found
93
94