Add BMC driver version as argument to CSV generation program

Resolves openbmc/openbmc-test-automation#1255

Change-Id: Ie6a2376d5069334f041b7972e5af33eee416afae
Signed-off-by: manasarm <manashsarma@in.ibm.com>
diff --git a/tools/oem/ibm/gen_csv_results.py b/tools/oem/ibm/gen_csv_results.py
index 6236a97..2578da8 100755
--- a/tools/oem/ibm/gen_csv_results.py
+++ b/tools/oem/ibm/gen_csv_results.py
@@ -49,6 +49,16 @@
     '-d',
     help='The directory path where the generated .csv files will go.')
 
+parser.add_argument(
+    '--version_id',
+    help='Driver version of openbmc firmware which was used during test,\
+          e.g. "v2.1-215-g6e7eacb".')
+
+parser.add_argument(
+    '--platform',
+    help='Openbmc platform which was used during test,\
+          e.g. "Witherspoon".')
+
 # Populate stock_list with options we want.
 stock_list = [("test_mode", 0), ("quiet", 0), ("debug", 0)]
 
@@ -105,7 +115,7 @@
     return True
 
 
-def parse_output_xml(xml_file_path, csv_dir_path):
+def parse_output_xml(xml_file_path, csv_dir_path, version_id, platform):
 
     r"""
     Parse the robot-generated output.xml file and extract various test
@@ -113,9 +123,12 @@
     folder.
 
     Description of argument(s):
-    xml_file_path  The path to a Robot-generated output.xml file.
-    csv_dir_path   The path to the directory that is to contain the .csv files
-                   generated by this function.
+    xml_file_path   The path to a Robot-generated output.xml file.
+    csv_dir_path    The path to the directory that is to contain the .csv files
+                    generated by this function.
+    version_id      Version of the openbmc firmware
+                    (e.g. "v2.1-215-g6e7eacb").
+    platform        Platform of the openbmc system.
     """
 
     result = ExecutionResult(xml_file_path)
@@ -155,13 +168,29 @@
     l_platform_type = ""
     l_func_area = ""
 
-    # System data from XML meta data
-    l_system_info = get_system_details(xml_file_path)
-    l_driver = l_system_info[0]
-    if l_system_info[1]:
-        l_platform_type = l_system_info[1]
+    ## System data from XML meta data
+    #l_system_info = get_system_details(xml_file_path)
+
+    # First let us try to collect information from keyboard input
+    # If keyboard input cannot give both information, then find from xml file.
+    if version_id and platform:
+        l_driver = version_id
+        l_platform_type = platform
+        print "BMC Version_id:", version_id
+        print "BMC Platform:", platform
     else:
-        print "System model is not set"
+        # System data from XML meta data
+        l_system_info = get_system_details(xml_file_path)
+        l_driver = l_system_info[0]
+        l_platform_type = l_system_info[1]
+
+    # Driver version id and platform are mandatorily required for CSV file
+    # generation. If any one is not avaulable, exit CSV file generation process.
+    if l_driver and l_platform_type:
+        print "Driver and system info set."
+    else:
+        print "\
+        Both driver and system info need to be set. CSV file is not generated."
         sys.exit()
 
     # Default header
@@ -239,7 +268,7 @@
     xml_file_path  The relative or absolute path to the output.xml file.
     """
 
-    bmc_version = ""
+    bmc_version_id = ""
     bmc_platform = ""
     with open(xml_file_path, 'rt') as output:
         tree = ElementTree.parse(output)
@@ -249,16 +278,15 @@
         # Example: ${output} = VERSION_ID="v1.99.2-71-gbc49f79-dirty"
         if '${output} = VERSION_ID=' in node.text:
             # Get BMC version (e.g. v1.99.1-96-g2a46570-dirty)
-            bmc_version = str(node.text.split("VERSION_ID=")[1])[1:-1]
+            bmc_version_id = str(node.text.split("VERSION_ID=")[1])[1:-1]
 
         # Platform is logged in the XML as msg.
         # Example: ${bmc_model} = Witherspoon BMC
         if '${bmc_model} = ' in node.text:
             bmc_platform = node.text.split(" = ")[1]
 
-    print "BMC Version:", bmc_version
-    print "BMC Platform:", bmc_platform
-    return [str(bmc_version), str(bmc_platform)]
+    print_vars(bmc_version_id, bmc_platform)
+    return [str(bmc_version_id), str(bmc_platform)]
 
 
 def main():
@@ -271,7 +299,7 @@
 
     qprint_pgm_header()
 
-    parse_output_xml(source, dest)
+    parse_output_xml(source, dest, version_id, platform)
 
     return True