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 122ee19d39SSushil Singh# Refer below document to generate bad firmware images for testing. 132ee19d39SSushil Singh# openbmc/openbmc-test-automation/blob/master/docs/code_update.md#generating-bad-firmware-image-for-testing 142ee19d39SSushil Singh 1547f8013bSSushil Singh# Test Parameters: 1647f8013bSSushil Singh# OPENBMC_HOST The BMC host name or IP address. 1747f8013bSSushil Singh# OPENBMC_USERNAME The OS login userid. 1847f8013bSSushil Singh# OPENBMC_PASSWORD The password for the OS login. 1947f8013bSSushil Singh# BAD_IMAGES_DIR_PATH The path to the directory which contains the bad image files. 20c51eee7dSSushil Singh# TFTP_SERVER The host name or IP of the TFTP server. 2147f8013bSSushil Singh 2247f8013bSSushil SinghResource ../../lib/connection_client.robot 2347f8013bSSushil SinghResource ../../lib/rest_client.robot 2447f8013bSSushil SinghResource ../../lib/openbmc_ffdc.robot 2547f8013bSSushil SinghResource ../../lib/bmc_redfish_resource.robot 2647f8013bSSushil SinghResource ../../lib/code_update_utils.robot 2747f8013bSSushil SinghLibrary OperatingSystem 2847f8013bSSushil SinghLibrary ../../lib/code_update_utils.py 2947f8013bSSushil SinghLibrary ../../lib/gen_robot_valid.py 3047f8013bSSushil Singh 3147f8013bSSushil SinghSuite Setup Suite Setup Execution 3247f8013bSSushil SinghSuite Teardown Redfish.Logout 3347f8013bSSushil SinghTest Setup Printn 3419269021SSushil SinghTest Teardown Test Teardown Execution 3547f8013bSSushil Singh 36*6fb70d98SMatt FischerTest Tags Redfish_Image_Upload 3747f8013bSSushil Singh 3847f8013bSSushil Singh*** Variables *** 3947f8013bSSushil Singh${timeout} 20 4047f8013bSSushil Singh${QUIET} ${1} 4147f8013bSSushil Singh${image_id} ${EMPTY} 4247f8013bSSushil Singh 4347f8013bSSushil Singh*** Test Cases *** 4447f8013bSSushil Singh 455236ec54SGeorge KeishingRedfish Failure To Upload BMC Image With Bad Manifest 4647f8013bSSushil Singh [Documentation] Upload a BMC firmware with a bad MANFIEST file. 4747f8013bSSushil Singh [Tags] Redfish_Failure_To_Upload_BMC_Image_With_Bad_Manifest 4847f8013bSSushil Singh [Template] Redfish Bad Firmware Update 4947f8013bSSushil Singh 5047f8013bSSushil Singh # Image File Name 5147f8013bSSushil Singh bmc_bad_manifest.ubi.mtd.tar 5247f8013bSSushil Singh 5347f8013bSSushil Singh 545236ec54SGeorge KeishingRedfish Failure To Upload Empty BMC Image 5547f8013bSSushil Singh [Documentation] Upload a BMC firmware with no kernel image. 5647f8013bSSushil Singh [Tags] Redfish_Failure_To_Upload_Empty_BMC_Image 5747f8013bSSushil Singh [Template] Redfish Bad Firmware Update 5847f8013bSSushil Singh 5947f8013bSSushil Singh # Image File Name 6047f8013bSSushil Singh bmc_nokernel_image.ubi.mtd.tar 6147f8013bSSushil Singh 6247f8013bSSushil Singh 635236ec54SGeorge KeishingRedfish Failure To Upload Host Image With Bad Manifest 6447f8013bSSushil Singh [Documentation] Upload a PNOR firmware with a bad MANIFEST file. 6547f8013bSSushil Singh [Tags] Redfish_Failure_To_Upload_Host_Image_With_Bad_Manifest 6647f8013bSSushil Singh [Template] Redfish Bad Firmware Update 6747f8013bSSushil Singh 6847f8013bSSushil Singh # Image File Name 6947f8013bSSushil Singh pnor_bad_manifest.pnor.squashfs.tar 7047f8013bSSushil Singh 7147f8013bSSushil Singh 725236ec54SGeorge KeishingRedfish Failure To Upload Empty Host Image 7347f8013bSSushil Singh [Documentation] Upload a PNOR firmware with no kernel Image. 7447f8013bSSushil Singh [Tags] Redfish_Failure_To_Upload_Empty_Host_Image 7547f8013bSSushil Singh [Template] Redfish Bad Firmware Update 7647f8013bSSushil Singh 7747f8013bSSushil Singh # Image File Name 7847f8013bSSushil Singh pnor_nokernel_image.pnor.squashfs.tar 7947f8013bSSushil Singh 8047f8013bSSushil Singh 815236ec54SGeorge KeishingRedfish TFTP Failure To Upload BMC Image With Bad Manifest 82c51eee7dSSushil Singh [Documentation] Upload a BMC firmware with a bad MANFIEST file via TFTP. 83c51eee7dSSushil Singh [Tags] Redfish_TFTP_Failure_To_Upload_BMC_Image_With_Bad_Manifest 84c51eee7dSSushil Singh [Template] Redfish TFTP Bad Firmware Update 85c51eee7dSSushil Singh 86c51eee7dSSushil Singh # Image File Name 87c51eee7dSSushil Singh bmc_bad_manifest.ubi.mtd.tar 88c51eee7dSSushil Singh 89c51eee7dSSushil Singh 905236ec54SGeorge KeishingRedfish TFTP Failure To Upload Empty BMC Image 91c51eee7dSSushil Singh [Documentation] Upload a BMC firmware with no kernel image via TFTP. 92c51eee7dSSushil Singh [Tags] Redfish_TFTP_Failure_To_Upload_Empty_BMC_Image 93c51eee7dSSushil Singh [Template] Redfish TFTP Bad Firmware Update 94c51eee7dSSushil Singh 95c51eee7dSSushil Singh # Image File Name 96c51eee7dSSushil Singh bmc_nokernel_image.ubi.mtd.tar 97c51eee7dSSushil Singh 98c51eee7dSSushil Singh 995236ec54SGeorge KeishingRedfish TFTP Failure To Upload Host Image With Bad Manifest 100c51eee7dSSushil Singh [Documentation] Upload a PNOR firmware with a bad MANIFEST file via TFTP. 101c51eee7dSSushil Singh [Tags] Redfish_TFTP_Failure_To_Upload_Host_Image_With_Bad_Manifest 102c51eee7dSSushil Singh [Template] Redfish TFTP Bad Firmware Update 103c51eee7dSSushil Singh 104c51eee7dSSushil Singh # Image File Name 105c51eee7dSSushil Singh pnor_bad_manifest.pnor.squashfs.tar 106c51eee7dSSushil Singh 107c51eee7dSSushil Singh 1085236ec54SGeorge KeishingRedfish TFTP Failure To Upload Empty Host Image 109c51eee7dSSushil Singh [Documentation] Upload a PNOR firmware with no kernel Image via TFTP. 110c51eee7dSSushil Singh [Tags] Redfish_TFTP_Failure_To_Upload_Empty_Host_Image 111c51eee7dSSushil Singh [Template] Redfish TFTP Bad Firmware Update 112c51eee7dSSushil Singh 113c51eee7dSSushil Singh # Image File Name 114c51eee7dSSushil Singh pnor_nokernel_image.pnor.squashfs.tar 115c51eee7dSSushil Singh 116c51eee7dSSushil Singh 11747f8013bSSushil Singh*** Keywords *** 11847f8013bSSushil Singh 11947f8013bSSushil SinghSuite Setup Execution 12047f8013bSSushil Singh [Documentation] Do the suite setup. 12147f8013bSSushil Singh 12219269021SSushil Singh Valid Value OPENBMC_HOST 12319269021SSushil Singh Valid Value OPENBMC_USERNAME 12419269021SSushil Singh Valid Value OPENBMC_PASSWORD 12519269021SSushil Singh Valid Value BAD_IMAGES_DIR_PATH 12619269021SSushil Singh Valid Value TFTP_SERVER 12747f8013bSSushil Singh Redfish.Login 1284aff2d02STim Lee Redfish Delete All BMC Dumps 12947f8013bSSushil Singh Redfish Purge Event Log 13047f8013bSSushil Singh 13147f8013bSSushil Singh 13247f8013bSSushil SinghRedfish Bad Firmware Update 13347f8013bSSushil Singh [Documentation] Redfish firmware update. 13447f8013bSSushil Singh [Arguments] ${image_file_name} 13547f8013bSSushil Singh 13647f8013bSSushil Singh # Description of argument(s): 13747f8013bSSushil Singh # image_file_name The file name of the image. 13847f8013bSSushil Singh 139c51eee7dSSushil Singh Valid Dir Path BAD_IMAGES_DIR_PATH 14047f8013bSSushil Singh ${image_file_path}= OperatingSystem.Join Path ${BAD_IMAGES_DIR_PATH} 14147f8013bSSushil Singh ... ${image_file_name} 14247f8013bSSushil Singh Valid File Path image_file_path 14347f8013bSSushil Singh Set ApplyTime policy=OnReset 14447f8013bSSushil Singh ${image_data}= OperatingSystem.Get Binary File ${image_file_path} 1456209865aSSushil Singh ${resp}= Upload Image To BMC 14647f8013bSSushil Singh ... ${REDFISH_BASE_URI}UpdateService 14747f8013bSSushil Singh ... ${timeout} 14847f8013bSSushil Singh ... valid_status_codes=[${HTTP_OK}, ${HTTP_INTERNAL_SERVER_ERROR}] 14947f8013bSSushil Singh ... data=${image_data} 15047f8013bSSushil Singh 1516209865aSSushil Singh Return From Keyword If ${resp.status_code} == ${HTTP_INTERNAL_SERVER_ERROR} 15247f8013bSSushil Singh 15347f8013bSSushil Singh ${image_id}= Get Latest Image ID 15447f8013bSSushil Singh Rprint Vars image_id 15547f8013bSSushil Singh Check Image Update Progress State 15647f8013bSSushil Singh ... match_state='Updating', 'Disabled' image_id=${image_id} 15747f8013bSSushil Singh 158c51eee7dSSushil Singh 159c51eee7dSSushil SinghRedfish TFTP Bad Firmware Update 160c51eee7dSSushil Singh [Documentation] Redfish bad firmware update via TFTP. 161c51eee7dSSushil Singh [Arguments] ${image_file_name} 162c51eee7dSSushil Singh 163c51eee7dSSushil Singh # Description of argument(s): 164c51eee7dSSushil Singh # image_file_name The file name of the image. 165c51eee7dSSushil Singh 166c51eee7dSSushil Singh Set ApplyTime policy=OnReset 167c51eee7dSSushil Singh # Download image from TFTP server to BMC. 168c51eee7dSSushil Singh Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate 169c51eee7dSSushil Singh ... body={"TransferProtocol" : "TFTP", "ImageURI" : "${TFTP_SERVER}/${image_file_name}"} 170c51eee7dSSushil Singh Sleep 60s 171c51eee7dSSushil Singh ${image_version}= Get Image Version From TFTP Server ${TFTP_SERVER} ${image_file_name} 172c51eee7dSSushil Singh Return From Keyword If '${image_version}' == '${EMPTY}' 173c51eee7dSSushil Singh # Wait for image tar file to download complete. 174c51eee7dSSushil Singh ${image_id}= Wait Until Keyword Succeeds 60 sec 10 sec Get Latest Image ID 175c51eee7dSSushil Singh Rprint Vars image_id 176c51eee7dSSushil Singh 177c51eee7dSSushil Singh Check Image Update Progress State 178c51eee7dSSushil Singh ... match_state='Updating', 'Disabled' image_id=${image_id} 179c51eee7dSSushil Singh 180c51eee7dSSushil Singh 18147f8013bSSushil SinghTest Teardown Execution 18247f8013bSSushil Singh [Documentation] Do the post test teardown. 18347f8013bSSushil Singh 18447f8013bSSushil Singh FFDC On Test Case Fail 18547f8013bSSushil Singh Run Keyword If '${image_id}' Delete Software Object 18647f8013bSSushil Singh ... /xyz/openbmc_project/software/${image_id} 187c51eee7dSSushil Singh 188