xref: /openbmc/openbmc-test-automation/extended/code_update/bmc_code_update.robot (revision b926408efc0148c21eff6cf14dbef6b42c6ec9ae)
1*** Settings ***
2Documentation     Update the BMC code on a target BMC.
3...               Execution Method:
4...               python -m robot -v OPENBMC_HOST:<hostname>
5...               -v IMAGE_FILE_PATH:<path/*.tar>  bmc_code_update.robot
6
7Library           ../../lib/code_update_utils.py
8Variables         ../../data/variables.py
9Resource          ../../lib/boot_utils.robot
10Resource          code_update_utils.robot
11Resource          ../../lib/code_update_utils.robot
12Resource          ../../lib/openbmc_ffdc.robot
13Resource          ../../lib/dump_utils.robot
14
15Test Teardown     Code Update Test Teardown
16
17*** Variables ***
18
19${QUIET}                          ${1}
20${IMAGE_FILE_PATH}                ${EMPTY}
21${ALTERNATE_IMAGE_FILE_PATH}      ${EMPTY}
22${SKIP_UPDATE_IF_ACTIVE}          false
23
24*** Test Cases ***
25
26REST BMC Code Update
27    [Documentation]  Do a BMC code update by uploading image on BMC via REST.
28    [Tags]  REST_BMC_Code_Update
29    [Setup]  Code Update Setup
30
31    Upload And Activate Image  ${IMAGE_FILE_PATH}
32    ...  skip_if_active=${SKIP_UPDATE_IF_ACTIVE}
33    OBMC Reboot (off)
34    Verify Running BMC Image  ${IMAGE_FILE_PATH}
35
36
37Upload And Activate Multiple BMC Images
38    [Documentation]  Upload another BMC image and verify that its state is
39    ...              different from all others.
40    [Tags]  Upload_And_Activate_Multiple_BMC_Images
41    [Template]  Activate Image And Verify No Duplicate Priorities
42    [Setup]  Upload And Activate Multiple BMC Images Setup
43
44    # Image File Path              Image Purpose
45    ${ALTERNATE_IMAGE_FILE_PATH}   ${VERSION_PURPOSE_BMC}
46
47
48BMC Set Priority To Invalid Values
49    [Documentation]  Attempt to set the priority of an image to an invalid
50    ...              value and expect an error.
51    [Tags]  BMC_Set_Priority_To_Invalid_Values
52    [Template]  Set Priority To Invalid Value And Expect Error
53
54    # Version Type              Priority
55    ${VERSION_PURPOSE_BMC}     ${-1}
56    ${VERSION_PURPOSE_BMC}     ${256}
57
58
59Delete BMC Image
60    [Documentation]  Delete a BMC image from the BMC flash chip.
61    [Tags]  Delete_BMC_Image
62
63    ${software_object}=  Get Non Running BMC Software Object
64    Delete Image And Verify  ${software_object}  ${VERSION_PURPOSE_BMC}
65
66
67BMC Image Priority Attribute Test
68    [Documentation]  Set "Priority" attribute.
69    [Tags]  BMC_Image_Priority_Attribute_Test
70    [Template]  Temporarily Set BMC Attribute
71
72    # Property        Value
73    Priority          ${0}
74    Priority          ${1}
75    Priority          ${127}
76    Priority          ${255}
77
78
79*** Keywords ***
80
81Temporarily Set BMC Attribute
82    [Documentation]  Update the BMC attribute value.
83    [Arguments]  ${attribute_name}  ${attribute_value}
84
85    # Description of argument(s):
86    # attribute_name    BMC software attribute name (e.g. "Priority").
87    # attribute_value   Value to be written.
88
89    ${image_ids}=  Get Software Objects  ${VERSION_PURPOSE_BMC}
90    ${init_bmc_properties}=  Get Host Software Property  ${image_ids[0]}
91    ${initial_priority}=  Set Variable  ${init_bmc_properties["Priority"]}
92
93    Set Host Software Property  ${image_ids[0]}  ${attribute_name}
94    ...  ${attribute_value}
95
96    ${cur_bmc_properties}=  Get Host Software Property  ${image_ids[0]}
97    Should Be Equal As Integers  ${cur_bmc_properties["Priority"]}
98    ...  ${attribute_value}
99
100    # Revert to to initial value.
101    Set Host Software Property
102    ...  ${image_ids[0]}  ${attribute_name}  ${initial_priority}
103
104
105Upload And Activate Multiple BMC Images Setup
106    [Documentation]  Check that the ALTERNATE_FILE_PATH variable is set.
107
108    Should Not Be Empty  ${ALTERNATE_IMAGE_FILE_PATH}
109
110Code Update Setup
111    [Documentation]  Do code update test case setup.
112    # - Clean up all existing BMC dumps.
113
114    Delete All Dumps
115    Run Keyword And Ignore Error  Smart Power Off
116
117Code Update Test Teardown
118    [Documentation]  Do code update test case teardown.
119    # 1. Collect FFDC if test case failed.
120    # 2. Collect FFDC if test PASS but error log exists.
121
122    FFDC On Test Case Fail
123    Run Keyword If  '${TEST_STATUS}' == 'PASS'  Check Error And Collect FFDC
124