Index: utils/lit/lit/Test.py =================================================================== --- utils/lit/lit/Test.py +++ utils/lit/lit/Test.py @@ -381,7 +381,9 @@ 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("]]>", "]]]]>")) fil.write("]]>\n") elif self.result.code == UNSUPPORTED: unsupported_features = self.getMissingRequiredFeatures() Index: utils/lit/tests/Inputs/xunit-output/bad&name.ini =================================================================== --- utils/lit/tests/Inputs/xunit-output/bad&name.ini +++ 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 Index: utils/lit/tests/xunit-output.py =================================================================== --- utils/lit/tests/xunit-output.py +++ utils/lit/tests/xunit-output.py @@ -1,11 +1,13 @@ # Check xunit output # RUN: %{lit} --xunit-xml-output %t.xunit.xml %{inputs}/xunit-output || true +# 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: # CHECK: # CHECK: # CHECK: -# CHECK-NEXT: "]]> +# CHECK-NEXT: ]]]]> &"]]> # CHECK: # CHECK: