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