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