Remove M code and add "Test Case Name" column.

BUG=b:69798350
TEST=./upload_cts.py <build_id> <results_dir_path>

Change-Id: Ic36f23a3f4a92c4152c91f18c168a4e66ebaf71c
Reviewed-on: https://chromium-review.googlesource.com/791940
Commit-Ready: Nita Nair <nnita@chromium.org>
Tested-by: Nita Nair <nnita@chromium.org>
Reviewed-by: Rohit Makasana <rohitbm@chromium.org>
diff --git a/provingground/cts/lib/upload_utils.py b/provingground/cts/lib/upload_utils.py
index 23c911e..a31d5f6 100755
--- a/provingground/cts/lib/upload_utils.py
+++ b/provingground/cts/lib/upload_utils.py
@@ -25,19 +25,21 @@
   SPACE_COUNT_CTS_BUILD_VERSION = 12
   SPACE_COUNT_CTS_BOARD_ABI = 13
   SPACE_COUNT_PACKAGE_NAME = 30
-  SPACE_COUNT_FAILED_TESTS = 6
-  SPACE_COUNT_PASSED_TESTS = 6
+  SPACE_COUNT_FAILED_TESTS = 8
+  SPACE_COUNT_PASSED_TESTS = 8
+  SPACE_COUNT_TEST_NAME = 70
   C_PURPLE = '\033[95m'
   C_RED = '\033[91m'
   C_BLACK = '\033[98m'
   BOLD = '\033[1m'
   C_END = '\033[00m'
-  TABLE_HEADER_CTS = (' Time Stamp           : Board   :'
-                      'Build Version : Board ABI : '
-                      'TEST PACKAGE / MODULE NAME  : FAILED :'
-                      ' PASSED')
-  TABLE_HEADER_CTSV = (' Build Board Name : '
-                       'Build Board Version : '
+  TABLE_HEADER_CTS = (' TIME STAMP           : BOARD   : '
+                      'BUILD VERSION    : BOARD ABI  '
+                      ' : TEST MODULE NAME         : TEST CASE NAME '
+                      '                                                    '
+                      ': FAILED : PASSED')
+  TABLE_HEADER_CTSV = (' BUILD BOARD NAME : '
+                       'BUILD BOARD VERSION : '
                        'CTS VERIFIER VERSION')
   def __init__(self):
     self.build_info_list = []
@@ -141,8 +143,9 @@
           ('{:^%s}'%self.SPACE_COUNT_CTS_BUILD_VERSION).format(item[2]),
           ('{:>%s}'%self.SPACE_COUNT_CTS_BOARD_ABI).format(item[3]),
           ('{:^%s}'%self.SPACE_COUNT_PACKAGE_NAME).format(item[4]),
-          ('{:<%s}'%self.SPACE_COUNT_FAILED_TESTS).format(item[5]),
-          ('{:<%s}'%self.SPACE_COUNT_PASSED_TESTS).format(item[6]))
+          ('{:<%s}'%self.SPACE_COUNT_TEST_NAME).format(item[5]),
+          ('{:<%s}'%self.SPACE_COUNT_FAILED_TESTS).format(item[6]),
+          ('{:<%s}'%self.SPACE_COUNT_PASSED_TESTS).format(item[7]))
 
   def GetXmlTagNamesCtsv(self):
     """Get xml tag names.
@@ -150,61 +153,51 @@
     Returns:
       tag_list: List of xml tag names.
     """
-    BUILD_N = 'Build'
-    RESULT = 'Result'
-    SUITE_VERSION = 'suite_version'
-    BUILD_BOARD = 'build_board'
-    BUILD_ID_N = 'build_id'
-    TEST = 'Test'
-    return [BUILD_N,
-            RESULT,
-            SUITE_VERSION,
-            BUILD_BOARD,
-            BUILD_ID_N,
-            TEST]
+    BUILD_N_XML_TAG = 'Build'
+    RESULT_XML_TAG = 'Result'
+    SUITE_VERSION_XML_TAG = 'suite_version'
+    BUILD_BOARD_XML_TAG = 'build_board'
+    BUILD_ID_N_XML_TAG = 'build_id'
+    TEST_XML_TAG = 'Test'
+    return [BUILD_N_XML_TAG,
+            RESULT_XML_TAG,
+            SUITE_VERSION_XML_TAG,
+            BUILD_BOARD_XML_TAG,
+            BUILD_ID_N_XML_TAG,
+            TEST_XML_TAG]
 
-  def GetXmlTagNamesCts(self, test_result_filename):
-    """Get xml tag names from M/N test result xml file.
+  def GetXmlTagNamesCts(self):
+    """Get xml tag names from test result xml file.
 
     Args:
-      test_result_filename: M/N Build Test Result file name.
+      test_result_filename: Build Test Result file name.
 
     Returns:
       tag_list: List of xml tag names.
     """
-    TEST_RESULT_FILENAME_M_BUILD = 'testResult.xml'
-    SUMMARY = 'Summary'
-    BUILD_M = 'BuildInfo'
-    BUILD_N = 'Build'
-    BUILD_BOARD_VERSION = 'build_board'
-    BUILD_ID_M = 'buildID'
-    BUILD_ID_N = 'build_id'
-    TEST_PACKAGE_LIST_M = 'TestPackage'
-    TEST_PACKAGE_LIST_N = 'Module'
-    TEST_PACKAGE_NAME_M = 'appPackageName'
-    TEST_PACKAGE_NAME_N = 'name'
-    BUILD_ABI_TYPE = 'abi'
-    FAILED = 'failed'
-    PASSED = 'pass'
-    if test_result_filename == TEST_RESULT_FILENAME_M_BUILD:
-      BUILD_VERSION = BUILD_M
-      BUILD_ID_TYPE = BUILD_ID_M
-      TEST_PACKAGE_LIST_VERSION = TEST_PACKAGE_LIST_M
-      TEST_PACKAGE_NAME_VERSION = TEST_PACKAGE_NAME_M
-    else:
-      BUILD_VERSION = BUILD_N
-      BUILD_ID_TYPE = BUILD_ID_N
-      TEST_PACKAGE_LIST_VERSION = TEST_PACKAGE_LIST_N
-      TEST_PACKAGE_NAME_VERSION = TEST_PACKAGE_NAME_N
-    return [SUMMARY,
-            BUILD_VERSION,
-            BUILD_BOARD_VERSION,
-            BUILD_ID_TYPE,
-            TEST_PACKAGE_LIST_VERSION,
-            TEST_PACKAGE_NAME_VERSION,
-            BUILD_ABI_TYPE,
-            FAILED,
-            PASSED]
+    SUMMARY_XML_TAG = 'Summary'
+    BUILD_N_XML_TAG = 'Build'
+    BUILD_BOARD_VERSION_XML_TAG = 'build_board'
+    BUILD_ID_N_XML_TAG = 'build_id'
+    TEST_PACKAGE_LIST_N_XML_TAG = 'Module'
+    TEST_PACKAGE_NAME_N_XML_TAG = 'name'
+    BUILD_ABI_TYPE_XML_TAG = 'abi'
+    FAILED_XML_TAG = 'failed'
+    PASSED_XML_TAG = 'pass'
+    TEST_XML_TAG = 'Test'
+    NAME_XML_TAG = 'name'
+
+    return [SUMMARY_XML_TAG,
+            BUILD_N_XML_TAG,
+            BUILD_BOARD_VERSION_XML_TAG,
+            BUILD_ID_N_XML_TAG,
+            TEST_PACKAGE_LIST_N_XML_TAG,
+            TEST_PACKAGE_NAME_N_XML_TAG,
+            BUILD_ABI_TYPE_XML_TAG,
+            FAILED_XML_TAG,
+            PASSED_XML_TAG,
+            TEST_XML_TAG,
+            NAME_XML_TAG]
 
   def UpdateBuildInfoList(self, obj):
     """Appends object to list.
diff --git a/provingground/cts/upload_cts.py b/provingground/cts/upload_cts.py
index f21cbac..42168c1 100755
--- a/provingground/cts/upload_cts.py
+++ b/provingground/cts/upload_cts.py
@@ -83,7 +83,7 @@
 
 
   def ParseXmlFile(self, abs_input_file_path, test_result_filename, dir_path):
-    """Gets build information for M or N Builds.
+    """Gets build information from test_result.xml file.
 
     Parses the test result xml file to obtain build information. Adds build
     information to a list. Handles Untested tests if they exist. Untested
@@ -93,13 +93,13 @@
     Args:
       abs_input_file_path: Absolute input file path.
                            Eg: ~/Downloads/Manual/2017.09.22_14.27.09.zip
-      test_result_filename: M/N build test result file name.
-                            Eg: testResult.xml(M) or test_result.xml(N)
+      test_result_filename: test result file name.
+                            Eg: test_result.xml
       dir_path: Results directory path.
                 Eg: ~/Downloads/Manual
     """
-    self.GetXmlTagNamesCts(test_result_filename)
-    tag_list = self.GetXmlTagNamesCts(test_result_filename)
+    self.GetXmlTagNamesCts()
+    tag_list = self.GetXmlTagNamesCts()
     summary = tag_list[0]
     build_version = tag_list[1]
     build_board_version = tag_list[2]
@@ -109,6 +109,8 @@
     build_abi_type = tag_list[6]
     failed = tag_list[7]
     passed = tag_list[8]
+    test = tag_list[9]
+    name = tag_list[10]
     split_file_list = self.SplitFileName(abs_input_file_path)
     basename = split_file_list[1]
     full_base_name = os.path.join(dir_path, basename)
@@ -123,6 +125,7 @@
     summary = xml_doc.getElementsByTagName(summary)
     build_info = xml_doc.getElementsByTagName(build_version)
     test_package_list = xml_doc.getElementsByTagName(test_package_list)
+    test = xml_doc.getElementsByTagName(test)
     if not build_info:
       self.UpdateBuildInfoList([timestamp,
                                 'null',
@@ -157,19 +160,20 @@
       build_abi = test_package_list[0].attributes[build_abi_type].value
       failed = summary[0].attributes[failed].value
       passed = summary[0].attributes[passed].value
+      test = test[0].attributes[name].value
       self.UpdateBuildInfoList([timestamp,
                                 build_board,
                                 build_id,
                                 build_abi,
                                 test_package,
+                                test,
                                 failed,
                                 passed])
 
   def ProcessFilesToUpload(self, input_build_id, dir_path):
     """Process Files to Upload to CTS and APFE Buckets.
 
-    Checks if Test Result File has M build or N Build and parses the
-    corresponding xml file to obtain build information.Checks for file
+    Parses the test_result.xml file to obtain build information.Checks for file
     validity by comparing with provided input BuildID. Pushes valid files to
     appropriate folders to upload to APFE and CTS buckets.Pushes invalid
     files to Obsolete Folder.Pushes untested files if any to UnTested
@@ -180,28 +184,15 @@
       dir_path: Results directory path.
     """
     test_result_filename_n_build = 'test_result.xml'
-    test_result_filename_m_build = 'testResult.xml'
     build_id = ' '
     item = ' '
     for the_file in os.listdir(dir_path):
       if the_file.endswith('.zip'):
         full_file_path = os.path.join(dir_path, the_file)
         self.ExtractZipFile(full_file_path, dir_path)
-        split_file_list = self.SplitFileName(full_file_path)
-        basename = split_file_list[1]
-        full_base_name = os.path.join(dir_path, basename)
-        src_file = os.path.join(full_base_name,
-                                test_result_filename_m_build)
-        is_m_build = os.path.isfile(src_file)
-        if is_m_build is True:
-          self.ParseXmlFile(full_file_path,
-                            test_result_filename_m_build,
-                            dir_path)
-
-        else:
-          self.ParseXmlFile(full_file_path,
-                            test_result_filename_n_build,
-                            dir_path)
+        self.ParseXmlFile(full_file_path,
+                          test_result_filename_n_build,
+                          dir_path)
 
         for item in self.build_info_list:
           build_id = item[2]
@@ -255,7 +246,7 @@
                       help='upload_cts.py <build_id> <results_dir_path>')
   args = parser.parse_args()
 
-  cts = UploadCts(args.build_id,args.dir_path)
+  cts = UploadCts(args.build_id, args.dir_path)
 
   if len(sys.argv) == 1:
     parser.print_help()