BMC version check logic fix when multiple images are active
Resolves openbmc/openbmc-test-automation#1023
Change-Id: I0f35c31323f6807c033ad944e294e0a56061c11e
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/code_update_utils.robot b/lib/code_update_utils.robot
index dd5c7f6..3ab26e6 100644
--- a/lib/code_update_utils.robot
+++ b/lib/code_update_utils.robot
@@ -4,6 +4,7 @@
Library code_update_utils.py
Library OperatingSystem
Library String
+Library utilities.py
Variables ../data/variables.py
Resource boot_utils.robot
Resource rest_client.robot
@@ -331,7 +332,6 @@
${pnor_version}= Get PNOR Version
Should Be Equal ${tar_version} ${pnor_version}
-
Reset Network Interface During Code Update
[Documentation] Disable and re-enable the network while doing code update.
[Arguments] ${image_file_path} ${reboot}
@@ -364,3 +364,23 @@
Sleep 30s
Execute Command On Serial Console ifconfig eth0 up
Read and Log BMC Serial Console Output
+
+
+Get Least Value Priority Image
+ [Documentation] Find the least value in "Priority" attribute and return.
+ [Arguments] ${version_type}
+
+ # Description of argument(s):
+ # version_type Either BMC or host version purpose.
+
+ ${priority_value_list}= Create List
+ ${sw_list}= Get Software Objects version_type=${version_type}
+
+ :FOR ${index} IN @{sw_list}
+ \ ${priority_value}=
+ ... Read Software Attribute ${index} Priority
+ \ Append To List ${priority_value_list} ${priority_value}
+
+ ${min_value}= Min List Value ${priority_value_list}
+
+ [Return] ${min_value}
diff --git a/lib/utilities.py b/lib/utilities.py
index da2f962..47586e5 100755
--- a/lib/utilities.py
+++ b/lib/utilities.py
@@ -253,3 +253,10 @@
return set(fru_list)
###############################################################################
+
+
+def min_list_value(value_list):
+ r"""
+ Returns the element from the list with minimum value.
+ """
+ return min(value_list)
diff --git a/tests/test_software_manager.robot b/tests/test_software_manager.robot
index 472f5b2..73af849 100755
--- a/tests/test_software_manager.robot
+++ b/tests/test_software_manager.robot
@@ -137,6 +137,8 @@
: FOR ${index} IN @{obj_list}
\ ${resp}= Get Host Software Property ${index}
\ Verify Software Properties ${resp} ${software_purpose}
+ \ Run Keyword If '${software_purpose}' == '${VERSION_PURPOSE_BMC}'
+ ... Check BMC Version ${index} ${resp["Version"]}
Verify Software Properties
@@ -150,16 +152,20 @@
# "xyz.openbmc_project.Software.Version.VersionPurpose.Host").
Check Activation Status ${software_property["Activation"]}
- Run Keyword If '${software_purpose}' == '${VERSION_PURPOSE_BMC}'
- ... Check BMC Version ${software_property["Version"]}
Check BMC Version
[Documentation] Get BMC version from /etc/os-release and compare.
- [Arguments] ${version}
+ [Arguments] ${software_object} ${version}
# Description of argument(s):
- # version Software version (e.g. "v1.99.2-107-g2be34d2-dirty")
+ # software_object Software object path.
+ # version Software version (e.g. "v1.99.2-107-g2be34d2-dirty")
+
+ ${min_value}= Get Least Value Priority Image ${VERSION_PURPOSE_BMC}
+ ${priority_value}= Read Software Attribute ${software_object} Priority
+
+ Return From Keyword If ${priority_value} != ${min_value}
Open Connection And Log In
${cmd}= Set Variable grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '='