summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-02-24 09:19:12 +0000
committerLinaro Code Review <review@review.linaro.org>2017-02-24 09:19:12 +0000
commitb28cd79d59c280be23e6f270e21774a2c45d3531 (patch)
treecc1dda549a2111bec4fd39e085f3800919cd75ec
parentb0daa860db52a2b14b92ec793e30c422a9d24756 (diff)
parent759fcf1e719700270f75f34d4522f48b1bf8e3bf (diff)
downloadtest-definitions-pipe-b28cd79d59c280be23e6f270e21774a2c45d3531.tar.gz
Merge "automated/android: add CTS result 'pre-parser'"
-rwxr-xr-xautomated/android/cts/cts-runner.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/automated/android/cts/cts-runner.py b/automated/android/cts/cts-runner.py
index 5bd7777..aa25e21 100755
--- a/automated/android/cts/cts-runner.py
+++ b/automated/android/cts/cts-runner.py
@@ -2,6 +2,7 @@
import datetime
import os
+import re
import sys
import shlex
import shutil
@@ -16,13 +17,37 @@ import py_test_lib # nopep8
def result_parser(xml_file):
+ etree_file = open(xml_file, 'rb')
+ etree_content = etree_file.read()
+ rx = re.compile("&#([0-9]+);|&#x([0-9a-fA-F]+);")
+ endpos = len(etree_content)
+ pos = 0
+ while pos < endpos:
+ # remove characters that don't conform to XML spec
+ m = rx.search(etree_content, pos)
+ if not m:
+ break
+ mstart, mend = m.span()
+ target = m.group(1)
+ if target:
+ num = int(target)
+ else:
+ num = int(m.group(2), 16)
+ # #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ if not(num in (0x9, 0xA, 0xD) or
+ 0x20 <= num <= 0xD7FF or
+ 0xE000 <= num <= 0xFFFD or
+ 0x10000 <= num <= 0x10FFFF):
+ etree_content = etree_content[:mstart] + etree_content[mend:]
+ endpos = len(etree_content)
+ pos = mend
+
try:
- tree = ET.parse(xml_file)
+ root = ET.fromstring(etree_content)
except ET.ParseError as e:
logger.error('xml.etree.ElementTree.ParseError: %s' % e)
logger.info('Please Check %s manually' % xml_file)
sys.exit(1)
- root = tree.getroot()
logger.info('Test modules in %s: %s'
% (xml_file, str(len(root.findall('Module')))))
for elem in root.findall('Module'):