IPMI auxiliary revision verification

Added:
     - Function to get the aux version from BMC version.
     - IPMI auxiliary version and derived aux version from BMC.

Resolves  openbmc/openbmc-test-automation#1297

Change-Id: I820941e16e8e8d6ae37f9b3dd97abfbc7823a1a4
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/ipmi_utils.py b/lib/ipmi_utils.py
index 7081730..e88bab8 100644
--- a/lib/ipmi_utils.py
+++ b/lib/ipmi_utils.py
@@ -288,3 +288,30 @@
     result = vf.key_value_outbuf_to_dict(ret_values, process_indent=1)
 
     return result
+
+
+def get_aux_version(version_id):
+    r"""
+    Get IPMI Aux version info data and return it.
+
+    Description of argument(s):
+    version_id    The data is obtained by from BMC /etc/os-release
+                  (e.g. "xxx-v2.1-438-g0030304-r3-gfea8585").
+
+    In the prior example, the 3rd field is "438" is the commit version and
+    the 5th field is "r3" and value "3" is the release version.
+
+    Aux version return from this function 4380003.
+    """
+
+    # Commit version.
+    count = re.findall("-(\d{1,4})-", version_id)
+
+    # Release version.
+    release = re.findall("-r(\d{1,4})", version_id)
+    if release:
+        aux_version = count[0] + "{0:0>4}".format(release[0])
+    else:
+        aux_version = count[0] + "0000"
+
+    return aux_version
diff --git a/tests/ipmi/test_general_ipmi.robot b/tests/ipmi/test_general_ipmi.robot
index efc0ac6..305ac2e 100644
--- a/tests/ipmi/test_general_ipmi.robot
+++ b/tests/ipmi/test_general_ipmi.robot
@@ -432,10 +432,10 @@
     #     FRU Inventory Device
     #     Chassis Device
     # Aux Firmware Rev Info     :
+    #     0x04
+    #     0x38
     #     0x00
-    #     0x00
-    #     0x00
-    #     0x00
+    #     0x03
 
     ${mc_info}=  Get MC Info
 
@@ -449,9 +449,9 @@
     ${ipmi_fw_minor_version}=  Convert To Integer  ${ipmi_fw_minor_version}
 
     # Get BMC version from BMC CLI i.e. 2.1 from "ibm-v2.1-338-r1-0-gbcd7765"
-    ${bmc_version}=  Get BMC Version
+    ${bmc_version_full}=  Get BMC Version
     ${bmc_version}=
-    ...  Remove String Using Regexp  ${bmc_version}  ^[^0-9]+  [^0-9\.].*
+    ...  Remove String Using Regexp  ${bmc_version_full}  ^[^0-9]+  [^0-9\.].*
 
     # Get major and minor version from BMC version i.e. 2 and 1 from 2.1
     ${bmc_major_version}  ${bmc_minor_version}=
@@ -477,8 +477,20 @@
     ...  ${mc_info['additional_device_support']}  FRU Inventory Device
     Should Contain  ${mc_info['additional_device_support']}  Chassis Device
 
-    # TODO: openbmc/openbmc-test-automation#1297
-    # Aux firmware revision verification.
+    # Auxiliary revision data verification.
+    ${aux_version}=  Get Aux Version  ${bmc_version_full}
+
+    # From aux_firmware_rev_info field ['0x04', '0x38', '0x00', '0x03']
+    ${bmc_aux_version}=  Catenate
+    ...  SEPARATOR=
+    ...  ${mc_info['aux_firmware_rev_info'][0][2:]}
+    ...  ${mc_info['aux_firmware_rev_info'][1][2:]}
+    ...  ${mc_info['aux_firmware_rev_info'][2][2:]}
+    ...  ${mc_info['aux_firmware_rev_info'][3][2:]}
+
+    Should Be Equal As Integers
+    ...  ${bmc_aux_version}  ${aux_version}
+    ...  msg=BMC aux version ${bmc_aux_version} does not match expected value of ${aux_version}.
 
 
 Verify SDR Info