diff options
| author | Alexander Richardson <arichardson.kde@gmail.com> | 2018-05-16 09:00:28 +0000 | 
|---|---|---|
| committer | Alexander Richardson <arichardson.kde@gmail.com> | 2018-05-16 09:00:28 +0000 | 
| commit | 1bffd0f7414623ca4ed8ae4768b827f29fa173ad (patch) | |
| tree | 9472990a5c7480f74c77ac075aebd9c6f55e3d33 /llvm/utils/lit | |
| parent | 8f44579d0bf1da80adebf6a7cd1095eabc1e1e0e (diff) | |
| download | bcm5719-llvm-1bffd0f7414623ca4ed8ae4768b827f29fa173ad.tar.gz bcm5719-llvm-1bffd0f7414623ca4ed8ae4768b827f29fa173ad.zip | |
Escape ]]> in xunit xml output
Summary:
This sequence ends the CDATA block so any characters after that are no
longer escaped. This can be fixed by replacing "]]>" with "]]]]><![CDATA[>".
Reviewers: cmatthews
Reviewed By: cmatthews
Differential Revision: https://reviews.llvm.org/D46886
llvm-svn: 332440
Diffstat (limited to 'llvm/utils/lit')
| -rw-r--r-- | llvm/utils/lit/lit/Test.py | 4 | ||||
| -rw-r--r-- | llvm/utils/lit/tests/Inputs/xunit-output/bad&name.ini | 4 | ||||
| -rw-r--r-- | llvm/utils/lit/tests/xunit-output.py | 4 | 
3 files changed, 8 insertions, 4 deletions
| diff --git a/llvm/utils/lit/lit/Test.py b/llvm/utils/lit/lit/Test.py index 73289f18a00..9c18d7efc44 100644 --- a/llvm/utils/lit/lit/Test.py +++ b/llvm/utils/lit/lit/Test.py @@ -381,7 +381,9 @@ class Test:                  encoded_output = self.result.output.encode("utf-8", 'ignore')              else:                  encoded_output = self.result.output -            fil.write(encoded_output) +            # In the unlikely case that the output contains the CDATA terminator +            # we wrap it by creating a new CDATA block +            fil.write(encoded_output.replace("]]>", "]]]]><![CDATA[>"))              fil.write("]]></failure>\n</testcase>")          elif self.result.code == UNSUPPORTED:              unsupported_features = self.getMissingRequiredFeatures() diff --git a/llvm/utils/lit/tests/Inputs/xunit-output/bad&name.ini b/llvm/utils/lit/tests/Inputs/xunit-output/bad&name.ini index 8dfc6852b24..3234da66aa4 100644 --- a/llvm/utils/lit/tests/Inputs/xunit-output/bad&name.ini +++ b/llvm/utils/lit/tests/Inputs/xunit-output/bad&name.ini @@ -1,7 +1,7 @@  [global]  result_code = FAIL -result_output = & < > " +result_output = & < > ]]> &"  [results]  value0 = 1 -value1 = 2.3456
\ No newline at end of file +value1 = 2.3456 diff --git a/llvm/utils/lit/tests/xunit-output.py b/llvm/utils/lit/tests/xunit-output.py index 436acd37247..9d3cd762df4 100644 --- a/llvm/utils/lit/tests/xunit-output.py +++ b/llvm/utils/lit/tests/xunit-output.py @@ -1,12 +1,14 @@  # Check xunit output  # RUN: rm -rf %t.xunit.xml  # RUN: not %{lit} --xunit-xml-output %t.xunit.xml %{inputs}/xunit-output +# If xmllint is installed verify that the generated xml is well-formed +# RUN: sh -c 'if command -v xmllint 2>/dev/null; then xmllint --noout %t.xunit.xml; fi'  # RUN: FileCheck < %t.xunit.xml %s  # CHECK: <?xml version="1.0" encoding="UTF-8" ?>  # CHECK: <testsuites>  # CHECK: <testsuite name='test-data' tests='1' failures='1' skipped='0'>  # CHECK: <testcase classname='test-data.test-data' name='bad&name.ini' time='{{[0-1]}}.{{[0-9]+}}'> -# CHECK-NEXT: <failure ><![CDATA[& < > "]]></failure> +# CHECK-NEXT: <failure ><![CDATA[& < > ]]]]><![CDATA[> &"]]></failure>  # CHECK: </testsuite>  # CHECK: </testsuites> | 

