Added test cases for uploading multiple images
Resolves openbmc/openbmc-test-automation#873
Change-Id: I2ac5b9acd6955c5d600099e39771f1feeeddc2c9
Signed-off-by: Charles Paul Hofer <Charles.Hofer@ibm.com>
diff --git a/lib/code_update_utils.py b/lib/code_update_utils.py
index 5026878..5dd0ca7 100644
--- a/lib/code_update_utils.py
+++ b/lib/code_update_utils.py
@@ -20,6 +20,34 @@
from robot.libraries.BuiltIn import BuiltIn
###############################################################################
+def verify_no_duplicate_image_priorities(image_purpose):
+
+ r"""
+ Check that there are no active images with the same purpose and priority.
+
+ Description of argument(s):
+ image_purpose The purpose that images must have to be checked for
+ priority duplicates.
+ """
+
+ taken_priorities = {}
+ _, image_names = keyword.run_key("Get Software Objects "
+ + "version_type=" + image_purpose)
+
+ for image_name in image_names:
+ _, image = keyword.run_key("Get Host Software Property " + image_name)
+ if image["Activation"] != var.ACTIVE:
+ continue
+ image_priority = image["Priority"]
+ if image_priority in taken_priorities:
+ BuiltIn().fail("Found active images with the same priority.\n"
+ + gp.sprint_vars(image, taken_priorities[image_priority]))
+ taken_priorities[image_priority] = image
+
+###############################################################################
+
+
+###############################################################################
def get_non_running_bmc_software_object():
r"""
diff --git a/lib/code_update_utils.robot b/lib/code_update_utils.robot
index a73a6a9..10e2171 100644
--- a/lib/code_update_utils.robot
+++ b/lib/code_update_utils.robot
@@ -117,6 +117,19 @@
Should Be Equal As Strings &{software_state}[Activation] ${ACTIVE}
+Activate Image And Verify No Duplicate Priorities
+ [Documentation] Upload an image, and then check that no images have the
+ ... same priority.
+ [Arguments] ${image_file_path} ${image_purpose}
+
+ # Description of argument(s):
+ # image_file_path The path to the image to upload.
+ # image_purpose The purpose in the image's MANIFEST file.
+
+ Upload And Activate Image ${image_file_path}
+ Verify No Duplicate Image Priorities ${image_purpose}
+
+
Delete Software Object
[Documentation] Deletes an image from the BMC.
[Arguments] ${software_object}
diff --git a/lib/resource.txt b/lib/resource.txt
index 74a5fcd..8f00efb 100755
--- a/lib/resource.txt
+++ b/lib/resource.txt
@@ -48,13 +48,14 @@
${DEBUG_TARBALL_PATH} ${EMPTY}
# Upload Image parameters
-${TFTP_SERVER} ${EMPTY}
-${PNOR_TFTP_FILE_NAME} ${EMPTY}
-${BMC_TFTP_FILE_NAME} ${EMPTY}
-${IMAGE_FILE_PATH} ${EMPTY}
-${PNOR_IMAGE_FILE_PATH} ${EMPTY}
-${BMC_IMAGE_FILE_PATH} ${EMPTY}
-${BAD_IMAGES_DIR_PATH} ${EMPTY}
+${TFTP_SERVER} ${EMPTY}
+${PNOR_TFTP_FILE_NAME} ${EMPTY}
+${BMC_TFTP_FILE_NAME} ${EMPTY}
+${IMAGE_FILE_PATH} ${EMPTY}
+${ALTERNATE_IMAGE_FILE_PATH} ${EMPTY}
+${PNOR_IMAGE_FILE_PATH} ${EMPTY}
+${BMC_IMAGE_FILE_PATH} ${EMPTY}
+${BAD_IMAGES_DIR_PATH} ${EMPTY}
# The caller must set this to the string "true" in order to delete images. The
# code is picky.