147f8013bSSushil Singh*** Settings ***
247f8013bSSushil SinghDocumentation         Test upload image with invalid images.
347f8013bSSushil Singh...                   This test expects the following bad tarball image files
4c51eee7dSSushil Singh...                   to exist in the BAD_IMAGES_DIR_PATH/TFTP_SERVER:
547f8013bSSushil Singh...                       bmc_bad_manifest.ubi.mtd.tar
647f8013bSSushil Singh...                       bmc_nokernel_image.ubi.mtd.tar
747f8013bSSushil Singh...                       bmc_invalid_key.ubi.mtd.tar
847f8013bSSushil Singh...                       pnor_bad_manifest.pnor.squashfs.tar
947f8013bSSushil Singh...                       pnor_nokernel_image.pnor.squashfs.tar
1047f8013bSSushil Singh...                       pnor_invalid_key.pnor.squashfs.tar
1147f8013bSSushil Singh
1247f8013bSSushil Singh# Test Parameters:
1347f8013bSSushil Singh# OPENBMC_HOST         The BMC host name or IP address.
1447f8013bSSushil Singh# OPENBMC_USERNAME     The OS login userid.
1547f8013bSSushil Singh# OPENBMC_PASSWORD     The password for the OS login.
1647f8013bSSushil Singh# BAD_IMAGES_DIR_PATH  The path to the directory which contains the bad image files.
17c51eee7dSSushil Singh# TFTP_SERVER          The host name or IP of the TFTP server.
1847f8013bSSushil Singh
1947f8013bSSushil SinghResource               ../../lib/connection_client.robot
2047f8013bSSushil SinghResource               ../../lib/rest_client.robot
2147f8013bSSushil SinghResource               ../../lib/openbmc_ffdc.robot
2247f8013bSSushil SinghResource               ../../lib/bmc_redfish_resource.robot
2347f8013bSSushil SinghResource               ../../lib/code_update_utils.robot
2447f8013bSSushil SinghLibrary                OperatingSystem
2547f8013bSSushil SinghLibrary                ../../lib/code_update_utils.py
2647f8013bSSushil SinghLibrary                ../../lib/gen_robot_valid.py
2747f8013bSSushil Singh
2847f8013bSSushil SinghSuite Setup            Suite Setup Execution
2947f8013bSSushil SinghSuite Teardown         Redfish.Logout
3047f8013bSSushil SinghTest Setup             Printn
31*19269021SSushil SinghTest Teardown          Test Teardown Execution
3247f8013bSSushil Singh
3347f8013bSSushil SinghForce Tags  Upload_Test
3447f8013bSSushil Singh
3547f8013bSSushil Singh*** Variables ***
3647f8013bSSushil Singh${timeout}             20
3747f8013bSSushil Singh${QUIET}               ${1}
3847f8013bSSushil Singh${image_id}            ${EMPTY}
3947f8013bSSushil Singh
4047f8013bSSushil Singh*** Test Cases ***
4147f8013bSSushil Singh
425236ec54SGeorge KeishingRedfish Failure To Upload BMC Image With Bad Manifest
4347f8013bSSushil Singh    [Documentation]  Upload a BMC firmware with a bad MANFIEST file.
4447f8013bSSushil Singh    [Tags]  Redfish_Failure_To_Upload_BMC_Image_With_Bad_Manifest
4547f8013bSSushil Singh    [Template]  Redfish Bad Firmware Update
4647f8013bSSushil Singh
4747f8013bSSushil Singh    # Image File Name
4847f8013bSSushil Singh    bmc_bad_manifest.ubi.mtd.tar
4947f8013bSSushil Singh
5047f8013bSSushil Singh
515236ec54SGeorge KeishingRedfish Failure To Upload Empty BMC Image
5247f8013bSSushil Singh    [Documentation]  Upload a BMC firmware with no kernel image.
5347f8013bSSushil Singh    [Tags]  Redfish_Failure_To_Upload_Empty_BMC_Image
5447f8013bSSushil Singh    [Template]  Redfish Bad Firmware Update
5547f8013bSSushil Singh
5647f8013bSSushil Singh    # Image File Name
5747f8013bSSushil Singh    bmc_nokernel_image.ubi.mtd.tar
5847f8013bSSushil Singh
5947f8013bSSushil Singh
605236ec54SGeorge KeishingRedfish Failure To Upload Host Image With Bad Manifest
6147f8013bSSushil Singh    [Documentation]  Upload a PNOR firmware with a bad MANIFEST file.
6247f8013bSSushil Singh    [Tags]  Redfish_Failure_To_Upload_Host_Image_With_Bad_Manifest
6347f8013bSSushil Singh    [Template]  Redfish Bad Firmware Update
6447f8013bSSushil Singh
6547f8013bSSushil Singh    # Image File Name
6647f8013bSSushil Singh    pnor_bad_manifest.pnor.squashfs.tar
6747f8013bSSushil Singh
6847f8013bSSushil Singh
695236ec54SGeorge KeishingRedfish Failure To Upload Empty Host Image
7047f8013bSSushil Singh    [Documentation]  Upload a PNOR firmware with no kernel Image.
7147f8013bSSushil Singh    [Tags]  Redfish_Failure_To_Upload_Empty_Host_Image
7247f8013bSSushil Singh    [Template]  Redfish Bad Firmware Update
7347f8013bSSushil Singh
7447f8013bSSushil Singh    # Image File Name
7547f8013bSSushil Singh    pnor_nokernel_image.pnor.squashfs.tar
7647f8013bSSushil Singh
7747f8013bSSushil Singh
785236ec54SGeorge KeishingRedfish TFTP Failure To Upload BMC Image With Bad Manifest
79c51eee7dSSushil Singh    [Documentation]  Upload a BMC firmware with a bad MANFIEST file via TFTP.
80c51eee7dSSushil Singh    [Tags]  Redfish_TFTP_Failure_To_Upload_BMC_Image_With_Bad_Manifest
81c51eee7dSSushil Singh    [Template]  Redfish TFTP Bad Firmware Update
82c51eee7dSSushil Singh
83c51eee7dSSushil Singh    # Image File Name
84c51eee7dSSushil Singh    bmc_bad_manifest.ubi.mtd.tar
85c51eee7dSSushil Singh
86c51eee7dSSushil Singh
875236ec54SGeorge KeishingRedfish TFTP Failure To Upload Empty BMC Image
88c51eee7dSSushil Singh    [Documentation]  Upload a BMC firmware with no kernel image via TFTP.
89c51eee7dSSushil Singh    [Tags]  Redfish_TFTP_Failure_To_Upload_Empty_BMC_Image
90c51eee7dSSushil Singh    [Template]  Redfish TFTP Bad Firmware Update
91c51eee7dSSushil Singh
92c51eee7dSSushil Singh    # Image File Name
93c51eee7dSSushil Singh    bmc_nokernel_image.ubi.mtd.tar
94c51eee7dSSushil Singh
95c51eee7dSSushil Singh
965236ec54SGeorge KeishingRedfish TFTP Failure To Upload Host Image With Bad Manifest
97c51eee7dSSushil Singh    [Documentation]  Upload a PNOR firmware with a bad MANIFEST file via TFTP.
98c51eee7dSSushil Singh    [Tags]  Redfish_TFTP_Failure_To_Upload_Host_Image_With_Bad_Manifest
99c51eee7dSSushil Singh    [Template]  Redfish TFTP Bad Firmware Update
100c51eee7dSSushil Singh
101c51eee7dSSushil Singh    # Image File Name
102c51eee7dSSushil Singh    pnor_bad_manifest.pnor.squashfs.tar
103c51eee7dSSushil Singh
104c51eee7dSSushil Singh
1055236ec54SGeorge KeishingRedfish TFTP Failure To Upload Empty Host Image
106c51eee7dSSushil Singh    [Documentation]  Upload a PNOR firmware with no kernel Image via TFTP.
107c51eee7dSSushil Singh    [Tags]  Redfish_TFTP_Failure_To_Upload_Empty_Host_Image
108c51eee7dSSushil Singh    [Template]  Redfish TFTP Bad Firmware Update
109c51eee7dSSushil Singh
110c51eee7dSSushil Singh    # Image File Name
111c51eee7dSSushil Singh    pnor_nokernel_image.pnor.squashfs.tar
112c51eee7dSSushil Singh
113c51eee7dSSushil Singh
11447f8013bSSushil Singh*** Keywords ***
11547f8013bSSushil Singh
11647f8013bSSushil SinghSuite Setup Execution
11747f8013bSSushil Singh    [Documentation]  Do the suite setup.
11847f8013bSSushil Singh
119*19269021SSushil Singh    Valid Value  OPENBMC_HOST
120*19269021SSushil Singh    Valid Value  OPENBMC_USERNAME
121*19269021SSushil Singh    Valid Value  OPENBMC_PASSWORD
122*19269021SSushil Singh    Valid Value  BAD_IMAGES_DIR_PATH
123*19269021SSushil Singh    Valid Value  TFTP_SERVER
12447f8013bSSushil Singh    Redfish.Login
1254aff2d02STim Lee    Redfish Delete All BMC Dumps
12647f8013bSSushil Singh    Redfish Purge Event Log
12747f8013bSSushil Singh
12847f8013bSSushil Singh
12947f8013bSSushil SinghRedfish Bad Firmware Update
13047f8013bSSushil Singh    [Documentation]  Redfish firmware update.
13147f8013bSSushil Singh    [Arguments]  ${image_file_name}
13247f8013bSSushil Singh
13347f8013bSSushil Singh    # Description of argument(s):
13447f8013bSSushil Singh    # image_file_name  The file name of the image.
13547f8013bSSushil Singh
136c51eee7dSSushil Singh    Valid Dir Path  BAD_IMAGES_DIR_PATH
13747f8013bSSushil Singh    ${image_file_path}=  OperatingSystem.Join Path  ${BAD_IMAGES_DIR_PATH}
13847f8013bSSushil Singh    ...  ${image_file_name}
13947f8013bSSushil Singh    Valid File Path  image_file_path
14047f8013bSSushil Singh    Set ApplyTime  policy=OnReset
14147f8013bSSushil Singh    ${image_data}=  OperatingSystem.Get Binary File  ${image_file_path}
14247f8013bSSushil Singh    ${status_code}=  Upload Image To BMC
14347f8013bSSushil Singh    ...  ${REDFISH_BASE_URI}UpdateService
14447f8013bSSushil Singh    ...  ${timeout}
14547f8013bSSushil Singh    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_INTERNAL_SERVER_ERROR}]
14647f8013bSSushil Singh    ...  data=${image_data}
14747f8013bSSushil Singh
14847f8013bSSushil Singh    Return From Keyword If  ${status_code} == ${HTTP_INTERNAL_SERVER_ERROR}
14947f8013bSSushil Singh
15047f8013bSSushil Singh    ${image_id}=  Get Latest Image ID
15147f8013bSSushil Singh    Rprint Vars  image_id
15247f8013bSSushil Singh    Check Image Update Progress State
15347f8013bSSushil Singh    ...  match_state='Updating', 'Disabled'  image_id=${image_id}
15447f8013bSSushil Singh
155c51eee7dSSushil Singh
156c51eee7dSSushil SinghRedfish TFTP Bad Firmware Update
157c51eee7dSSushil Singh    [Documentation]  Redfish bad firmware update via TFTP.
158c51eee7dSSushil Singh    [Arguments]  ${image_file_name}
159c51eee7dSSushil Singh
160c51eee7dSSushil Singh    # Description of argument(s):
161c51eee7dSSushil Singh    # image_file_name  The file name of the image.
162c51eee7dSSushil Singh
163c51eee7dSSushil Singh    Set ApplyTime  policy=OnReset
164c51eee7dSSushil Singh    # Download image from TFTP server to BMC.
165c51eee7dSSushil Singh    Redfish.Post  /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate
166c51eee7dSSushil Singh    ...  body={"TransferProtocol" : "TFTP", "ImageURI" : "${TFTP_SERVER}/${image_file_name}"}
167c51eee7dSSushil Singh    Sleep  60s
168c51eee7dSSushil Singh    ${image_version}=  Get Image Version From TFTP Server  ${TFTP_SERVER}  ${image_file_name}
169c51eee7dSSushil Singh    Return From Keyword If  '${image_version}' == '${EMPTY}'
170c51eee7dSSushil Singh    # Wait for image tar file to download complete.
171c51eee7dSSushil Singh    ${image_id}=  Wait Until Keyword Succeeds  60 sec  10 sec  Get Latest Image ID
172c51eee7dSSushil Singh    Rprint Vars  image_id
173c51eee7dSSushil Singh
174c51eee7dSSushil Singh    Check Image Update Progress State
175c51eee7dSSushil Singh    ...  match_state='Updating', 'Disabled'  image_id=${image_id}
176c51eee7dSSushil Singh
177c51eee7dSSushil Singh
17847f8013bSSushil SinghTest Teardown Execution
17947f8013bSSushil Singh    [Documentation]  Do the post test teardown.
18047f8013bSSushil Singh
18147f8013bSSushil Singh    FFDC On Test Case Fail
18247f8013bSSushil Singh    Run Keyword If  '${image_id}'  Delete Software Object
18347f8013bSSushil Singh    ...  /xyz/openbmc_project/software/${image_id}
184c51eee7dSSushil Singh
185