Atest: Error message to indicate failed xml file.
BUG: 234406161
Test: atest vts_ltp_test_x86_64 --verbose
Change-Id: I3a43fa4512eb2d2281f21a07d4450f8474ab6555
diff --git a/atest/atest_enum.py b/atest/atest_enum.py
index 7c9d940..0df8c3d 100644
--- a/atest/atest_enum.py
+++ b/atest/atest_enum.py
@@ -71,6 +71,7 @@
DEVICE_NOT_FOUND = 11
MIXED_TYPE_FILTER = 12
INPUT_TEST_REFERENCE_ERROR = 13
+ CONFIG_INVALID_FORMAT = 14
@unique
class FilterType(Enum):
diff --git a/atest/atest_utils.py b/atest/atest_utils.py
index bd9169d..c0c2582 100644
--- a/atest/atest_utils.py
+++ b/atest/atest_utils.py
@@ -44,7 +44,7 @@
import xml.etree.ElementTree as ET
-from atest_enum import DetectType, FilterType
+from atest_enum import DetectType, FilterType, ExitCode
# This is a workaround of b/144743252, where the http.client failed to loaded
# because the googleapiclient was found before the built-in libs; enabling
@@ -1344,11 +1344,16 @@
A set include all the device name of the input config.
"""
devices = set()
- xml_root = ET.parse(test_config).getroot()
- device_tags = xml_root.findall('.//device')
- for tag in device_tags:
- name = tag.attrib['name'].strip()
- devices.add(name)
+ try:
+ xml_root = ET.parse(test_config).getroot()
+ device_tags = xml_root.findall('.//device')
+ for tag in device_tags:
+ name = tag.attrib['name'].strip()
+ devices.add(name)
+ except ET.ParseError as e:
+ colorful_print('Config has invalid format.', constants.RED)
+ colorful_print('File %s : %s' % (test_config, str(e)), constants.YELLOW)
+ sys.exit(ExitCode.CONFIG_INVALID_FORMAT)
return devices
def get_mainline_param(test_config):