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
23*** Test Cases ***
24
25REST BMC Code Update
26    [Documentation]  Do a BMC code update by uploading image on BMC via REST.
27    [Tags]  REST_BMC_Code_Update
28    [Setup]  Code Update Setup
29
30    Upload And Activate Image  ${IMAGE_FILE_PATH}
31    OBMC Reboot (off)
32
33
34Upload And Activate Multiple BMC Images
35    [Documentation]  Upload another BMC image and verify that its state is
36    ...              different from all others.
37    [Tags]  Upload_And_Activate_Multiple_BMC_Images
38    [Template]  Activate Image And Verify No Duplicate Priorities
39    [Setup]  Upload And Activate Multiple BMC Images Setup
40
41    # Image File Path              Image Purpose
42    ${ALTERNATE_IMAGE_FILE_PATH}   ${VERSION_PURPOSE_BMC}
43
44
45BMC Set Priority To Invalid Values
46    [Documentation]  Attempt to set the priority of an image to an invalid
47    ...              value and expect an error.
48    [Tags]  BMC_Set_Priority_To_Invalid_Values
49    [Template]  Set Priority To Invalid Value And Expect Error
50
51    # Version Type              Priority
52    ${VERSION_PURPOSE_BMC}     ${-1}
53    ${VERSION_PURPOSE_BMC}     ${256}
54
55
56Delete BMC Image
57    [Documentation]  Delete a BMC image from the BMC flash chip.
58    [Tags]  Delete_BMC_Image
59
60    ${software_object}=  Get Non Running BMC Software Object
61    Delete Image And Verify  ${software_object}  ${VERSION_PURPOSE_BMC}
62
63
64*** Keywords ***
65
66Upload And Activate Multiple BMC Images Setup
67    [Documentation]  Check that the ALTERNATE_FILE_PATH variable is set.
68
69    Should Not Be Empty  ${ALTERNATE_IMAGE_FILE_PATH}
70
71Code Update Setup
72    [Documentation]  Do code update test case setup.
73    # - Clean up all existing BMC dumps.
74
75    Delete All Dumps
76
77Code Update Test Teardown
78    [Documentation]  Do code update test case teardown.
79    # 1. Collect FFDC if test case failed.
80    # 2. Collect FFDC if test PASS but error log exists.
81
82    FFDC On Test Case Fail
83    Run Keyword If  '${TEST_STATUS}' == 'PASS'  Check Error And Collect FFDC
84