blob: 75ba8a081fbf8c2c5febdb82e984016cc7fea492 [file] [log] [blame]
Sushil Singh47f80132019-08-27 04:53:24 -05001*** Settings ***
2Documentation Test upload image with invalid images.
3... This test expects the following bad tarball image files
Sushil Singhc51eee72019-09-01 11:13:37 -05004... to exist in the BAD_IMAGES_DIR_PATH/TFTP_SERVER:
Sushil Singh47f80132019-08-27 04:53:24 -05005... bmc_bad_manifest.ubi.mtd.tar
6... bmc_nokernel_image.ubi.mtd.tar
7... bmc_invalid_key.ubi.mtd.tar
8... pnor_bad_manifest.pnor.squashfs.tar
9... pnor_nokernel_image.pnor.squashfs.tar
10... pnor_invalid_key.pnor.squashfs.tar
11
Sushil Singh2ee19d32022-04-01 06:23:25 -050012# Refer below document to generate bad firmware images for testing.
13# openbmc/openbmc-test-automation/blob/master/docs/code_update.md#generating-bad-firmware-image-for-testing
14
Sushil Singh47f80132019-08-27 04:53:24 -050015# Test Parameters:
16# OPENBMC_HOST The BMC host name or IP address.
17# OPENBMC_USERNAME The OS login userid.
18# OPENBMC_PASSWORD The password for the OS login.
19# BAD_IMAGES_DIR_PATH The path to the directory which contains the bad image files.
Sushil Singhc51eee72019-09-01 11:13:37 -050020# TFTP_SERVER The host name or IP of the TFTP server.
Sushil Singh47f80132019-08-27 04:53:24 -050021
22Resource ../../lib/connection_client.robot
23Resource ../../lib/rest_client.robot
24Resource ../../lib/openbmc_ffdc.robot
25Resource ../../lib/bmc_redfish_resource.robot
26Resource ../../lib/code_update_utils.robot
27Library OperatingSystem
28Library ../../lib/code_update_utils.py
29Library ../../lib/gen_robot_valid.py
30
31Suite Setup Suite Setup Execution
32Suite Teardown Redfish.Logout
33Test Setup Printn
Sushil Singh19269022022-04-01 02:50:50 -050034Test Teardown Test Teardown Execution
Sushil Singh47f80132019-08-27 04:53:24 -050035
36Force Tags Upload_Test
37
38*** Variables ***
39${timeout} 20
40${QUIET} ${1}
41${image_id} ${EMPTY}
42
43*** Test Cases ***
44
George Keishing5236ec52022-01-31 12:07:58 -060045Redfish Failure To Upload BMC Image With Bad Manifest
Sushil Singh47f80132019-08-27 04:53:24 -050046 [Documentation] Upload a BMC firmware with a bad MANFIEST file.
47 [Tags] Redfish_Failure_To_Upload_BMC_Image_With_Bad_Manifest
48 [Template] Redfish Bad Firmware Update
49
50 # Image File Name
51 bmc_bad_manifest.ubi.mtd.tar
52
53
George Keishing5236ec52022-01-31 12:07:58 -060054Redfish Failure To Upload Empty BMC Image
Sushil Singh47f80132019-08-27 04:53:24 -050055 [Documentation] Upload a BMC firmware with no kernel image.
56 [Tags] Redfish_Failure_To_Upload_Empty_BMC_Image
57 [Template] Redfish Bad Firmware Update
58
59 # Image File Name
60 bmc_nokernel_image.ubi.mtd.tar
61
62
George Keishing5236ec52022-01-31 12:07:58 -060063Redfish Failure To Upload Host Image With Bad Manifest
Sushil Singh47f80132019-08-27 04:53:24 -050064 [Documentation] Upload a PNOR firmware with a bad MANIFEST file.
65 [Tags] Redfish_Failure_To_Upload_Host_Image_With_Bad_Manifest
66 [Template] Redfish Bad Firmware Update
67
68 # Image File Name
69 pnor_bad_manifest.pnor.squashfs.tar
70
71
George Keishing5236ec52022-01-31 12:07:58 -060072Redfish Failure To Upload Empty Host Image
Sushil Singh47f80132019-08-27 04:53:24 -050073 [Documentation] Upload a PNOR firmware with no kernel Image.
74 [Tags] Redfish_Failure_To_Upload_Empty_Host_Image
75 [Template] Redfish Bad Firmware Update
76
77 # Image File Name
78 pnor_nokernel_image.pnor.squashfs.tar
79
80
George Keishing5236ec52022-01-31 12:07:58 -060081Redfish TFTP Failure To Upload BMC Image With Bad Manifest
Sushil Singhc51eee72019-09-01 11:13:37 -050082 [Documentation] Upload a BMC firmware with a bad MANFIEST file via TFTP.
83 [Tags] Redfish_TFTP_Failure_To_Upload_BMC_Image_With_Bad_Manifest
84 [Template] Redfish TFTP Bad Firmware Update
85
86 # Image File Name
87 bmc_bad_manifest.ubi.mtd.tar
88
89
George Keishing5236ec52022-01-31 12:07:58 -060090Redfish TFTP Failure To Upload Empty BMC Image
Sushil Singhc51eee72019-09-01 11:13:37 -050091 [Documentation] Upload a BMC firmware with no kernel image via TFTP.
92 [Tags] Redfish_TFTP_Failure_To_Upload_Empty_BMC_Image
93 [Template] Redfish TFTP Bad Firmware Update
94
95 # Image File Name
96 bmc_nokernel_image.ubi.mtd.tar
97
98
George Keishing5236ec52022-01-31 12:07:58 -060099Redfish TFTP Failure To Upload Host Image With Bad Manifest
Sushil Singhc51eee72019-09-01 11:13:37 -0500100 [Documentation] Upload a PNOR firmware with a bad MANIFEST file via TFTP.
101 [Tags] Redfish_TFTP_Failure_To_Upload_Host_Image_With_Bad_Manifest
102 [Template] Redfish TFTP Bad Firmware Update
103
104 # Image File Name
105 pnor_bad_manifest.pnor.squashfs.tar
106
107
George Keishing5236ec52022-01-31 12:07:58 -0600108Redfish TFTP Failure To Upload Empty Host Image
Sushil Singhc51eee72019-09-01 11:13:37 -0500109 [Documentation] Upload a PNOR firmware with no kernel Image via TFTP.
110 [Tags] Redfish_TFTP_Failure_To_Upload_Empty_Host_Image
111 [Template] Redfish TFTP Bad Firmware Update
112
113 # Image File Name
114 pnor_nokernel_image.pnor.squashfs.tar
115
116
Sushil Singh47f80132019-08-27 04:53:24 -0500117*** Keywords ***
118
119Suite Setup Execution
120 [Documentation] Do the suite setup.
121
Sushil Singh19269022022-04-01 02:50:50 -0500122 Valid Value OPENBMC_HOST
123 Valid Value OPENBMC_USERNAME
124 Valid Value OPENBMC_PASSWORD
125 Valid Value BAD_IMAGES_DIR_PATH
126 Valid Value TFTP_SERVER
Sushil Singh47f80132019-08-27 04:53:24 -0500127 Redfish.Login
Tim Lee4aff2d02021-06-08 13:26:25 +0800128 Redfish Delete All BMC Dumps
Sushil Singh47f80132019-08-27 04:53:24 -0500129 Redfish Purge Event Log
130
131
132Redfish Bad Firmware Update
133 [Documentation] Redfish firmware update.
134 [Arguments] ${image_file_name}
Sushil Singh47f80132019-08-27 04:53:24 -0500135
136 # Description of argument(s):
137 # image_file_name The file name of the image.
138
Sushil Singhc51eee72019-09-01 11:13:37 -0500139 Valid Dir Path BAD_IMAGES_DIR_PATH
Sushil Singh47f80132019-08-27 04:53:24 -0500140 ${image_file_path}= OperatingSystem.Join Path ${BAD_IMAGES_DIR_PATH}
141 ... ${image_file_name}
142 Valid File Path image_file_path
143 Set ApplyTime policy=OnReset
144 ${image_data}= OperatingSystem.Get Binary File ${image_file_path}
145 ${status_code}= Upload Image To BMC
146 ... ${REDFISH_BASE_URI}UpdateService
147 ... ${timeout}
148 ... valid_status_codes=[${HTTP_OK}, ${HTTP_INTERNAL_SERVER_ERROR}]
149 ... data=${image_data}
150
151 Return From Keyword If ${status_code} == ${HTTP_INTERNAL_SERVER_ERROR}
152
153 ${image_id}= Get Latest Image ID
154 Rprint Vars image_id
155 Check Image Update Progress State
156 ... match_state='Updating', 'Disabled' image_id=${image_id}
157
Sushil Singhc51eee72019-09-01 11:13:37 -0500158
159Redfish TFTP Bad Firmware Update
160 [Documentation] Redfish bad firmware update via TFTP.
161 [Arguments] ${image_file_name}
Sushil Singhc51eee72019-09-01 11:13:37 -0500162
163 # Description of argument(s):
164 # image_file_name The file name of the image.
165
166 Set ApplyTime policy=OnReset
167 # Download image from TFTP server to BMC.
168 Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate
169 ... body={"TransferProtocol" : "TFTP", "ImageURI" : "${TFTP_SERVER}/${image_file_name}"}
170 Sleep 60s
171 ${image_version}= Get Image Version From TFTP Server ${TFTP_SERVER} ${image_file_name}
172 Return From Keyword If '${image_version}' == '${EMPTY}'
173 # Wait for image tar file to download complete.
174 ${image_id}= Wait Until Keyword Succeeds 60 sec 10 sec Get Latest Image ID
175 Rprint Vars image_id
176
177 Check Image Update Progress State
178 ... match_state='Updating', 'Disabled' image_id=${image_id}
179
180
Sushil Singh47f80132019-08-27 04:53:24 -0500181Test Teardown Execution
182 [Documentation] Do the post test teardown.
183
184 FFDC On Test Case Fail
185 Run Keyword If '${image_id}' Delete Software Object
186 ... /xyz/openbmc_project/software/${image_id}
Sushil Singhc51eee72019-09-01 11:13:37 -0500187