Adds a flag to ignore invalid test control files in test image.

BUG=chromium:603302
TEST=Manually test the case on device.

Change-Id: I1d2ac46283f45e2c701a8c569f20b6ffdcf114c1
Reviewed-on: https://chromium-review.googlesource.com/339360
Commit-Ready: Michael Tang <ntang@chromium.org>
Tested-by: Michael Tang <ntang@chromium.org>
Reviewed-by: Michael Tang <ntang@chromium.org>
diff --git a/frontend/afe/site_rpc_interface.py b/frontend/afe/site_rpc_interface.py
index 2de8493..7947b9e 100644
--- a/frontend/afe/site_rpc_interface.py
+++ b/frontend/afe/site_rpc_interface.py
@@ -981,10 +981,11 @@
     stable_version_utils.delete(board=board)
 
 
-def get_tests_by_build(build):
+def get_tests_by_build(build, ignore_invalid_tests=False):
     """Get the tests that are available for the specified build.
 
     @param build: unique name by which to refer to the image.
+    @param ignore_invalid_tests: flag on if unparsable tests are ignored.
 
     @return: A sorted list of all tests that are in the build specified.
     """
@@ -1011,7 +1012,12 @@
         # Read and parse the control file
         control_file = cfile_getter.get_control_file_contents(
                 control_file_path)
-        control_obj = control_data.parse_control_string(control_file)
+        try:
+            control_obj = control_data.parse_control_string(control_file)
+        except:
+            logging.info('Failed to parse congtrol file: %s', control_file_path)
+            if not ignore_invalid_tests:
+                raise
 
         # Extract the values needed for the AFE from the control_obj.
         # The keys list represents attributes in the control_obj that