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 Bios Teardown
14
15*** Variables ***
16
17${QUIET}                ${1}
18# OBMC Boot Test failures are not acceptable so we set the threshold to 0.
19${boot_fail_threshold}  ${0}
20# "skip" indicates to OBMC Boot Test that it should only process boot stack
21# items that would change the machine state, i.e. only if the action is
22# needed.
23${stack_mode}           skip
24${update_status}        True
25
26${pflash_cmd}           /usr/sbin/pflash -r /dev/stdout -P VERSION
27
28*** Test Cases ***
29
30Host BIOS Update
31    [Documentation]  Update PNOR image and verify.
32    [Tags]  Host_BIOS_Update  open-power
33
34    Validate Parameters
35    Prepare BMC For Update
36    Update PNOR Image
37    Verify PNOR Update
38
39Host BIOS Power On
40    [Documentation]  Power On the system and wait for OS
41    [Tags]  Host_BIOS_Power_On  open-power
42
43    Run Keyword If  '${PREV_TEST_STATUS}' == 'PASS'  Validate Power On
44
45*** Keywords ***
46
47Verify PNOR Update
48    [Documentation]  Verify that the PNOR is not corrupted.
49    # Example:
50    # FFS: Flash header not found. Code: 100
51    # Error 100 opening ffs !
52
53    Open Connection And Log In
54    ${pnor_info}=  Execute Command On BMC  ${pflash_cmd}
55    Should Not Contain Any  ${pnor_info}  Flash header not found  Error
56
57Prepare BMC For Update
58    [Documentation]  Prepare system for PNOR update.
59
60    # Call 'OBMC Boot Test' to do a 'REST Power Off', if needed.
61    Run Key U  OBMC Boot Test \ REST Power Off
62    Run Key  Clear BMC Record Log
63
64Update PNOR Image
65    [Documentation]  Copy the PNOR image to the BMC /tmp dir and flash it.
66
67    Run Key  Copy PNOR to BMC
68    ${pnor_path}  ${pnor_basename}=  Split Path  ${PNOR_IMAGE_PATH}
69    Run Key  Flash PNOR \ /tmp/${pnor_basename}
70    Run Key  Wait Until Keyword Succeeds \ 7 min \ 10 sec \ Is PNOR Flash Done
71
72Validate Power On
73    [Documentation]  Power the host on, and validate that the sytem booted.
74    [Teardown]  Validate Power On Teardown
75
76    # Have to start SOL logging here.  Starting SOL in test setup closes the
77    # connection when bmc reboots.
78    Run Key  Start SOL Console Logging
79    Run Key U  OBMC Boot Test \ REST Power On
80
81Validate Power On Teardown
82    [Documentation]  Teardown after Validate Power On.
83
84    ${keyword_buf}=  Catenate  Stop SOL Console Logging
85    ...  \ targ_file_path=${EXECDIR}${/}logs${/}SOL.log
86    Run Key  ${keyword_buf}
87
88Test Bios Teardown
89    [Documentation]  Log FFDC if test suite fails and collect SOL log for
90    ...              debugging purposes.
91
92    Printn
93    Run Key  FFDC On Test Case Fail
94
95Validate Parameters
96    [Documentation]   Validate parameter and file existence.
97    Should Not Be Empty
98    ...   ${PNOR_IMAGE_PATH}  msg=PNOR image path not set
99
100    OperatingSystem.File Should Exist  ${PNOR_IMAGE_PATH}
101    ...   msg=${PNOR_IMAGE_PATH} File not found
102
103