#5178 Supply DTD/(XSD/RNG for cppcheck XML output. Add target to Makefile to create and validate XML from regular run. Update xmlV2.rng accordingly.

This commit is contained in:
amai2012 2018-05-24 16:12:43 +02:00
parent c07abdd382
commit ceff09d491
3 changed files with 67 additions and 55 deletions

View File

@ -319,10 +319,13 @@ validatePlatforms: ${PlatformFilesCHECKED}
# Validate XML output (to detect regressions) # Validate XML output (to detect regressions)
/tmp/errorlist.xml: cppcheck /tmp/errorlist.xml: cppcheck
cppcheck --errorlist >$@ cppcheck --errorlist >$@
/tmp/example.xml: cppcheck
cppcheck --xml --inconclusive -j 4 cli externals gui lib test 2>/tmp/example.xml
createXMLExamples:/tmp/errorlist.xml /tmp/example.xml
.PHONY: validateXMLV2 .PHONY: validateXMLV2
validateXMLV2: /tmp/errorlist.xml validateXMLV2: createXMLExamples
xmllint --noout --relaxng xmlV2.rng $< xmllint --noout --relaxng xmlV2.rng /tmp/errorlist.xml
xmllint --noout --relaxng xmlV2.rng /tmp/example.xml
###### Build ###### Build

View File

@ -417,9 +417,13 @@ int main(int argc, char **argv)
fout << "# Validate XML output (to detect regressions)\n"; fout << "# Validate XML output (to detect regressions)\n";
fout << "/tmp/errorlist.xml: cppcheck\n"; fout << "/tmp/errorlist.xml: cppcheck\n";
fout << "\tcppcheck --errorlist >$@\n"; fout << "\tcppcheck --errorlist >$@\n";
fout << "/tmp/example.xml: cppcheck\n";
fout << "\tcppcheck --xml --inconclusive -j 4 cli externals gui lib test 2>/tmp/example.xml\n";
fout << "createXMLExamples:/tmp/errorlist.xml /tmp/example.xml\n";
fout << ".PHONY: validateXMLV2\n"; fout << ".PHONY: validateXMLV2\n";
fout << "validateXMLV2: /tmp/errorlist.xml\n"; fout << "validateXMLV2: createXMLExamples\n";
fout << "\txmllint --noout --relaxng xmlV2.rng $<\n\n"; fout << "\txmllint --noout --relaxng xmlV2.rng /tmp/errorlist.xml\n";
fout << "\txmllint --noout --relaxng xmlV2.rng /tmp/example.xml\n";
fout << "\n###### Build\n\n"; fout << "\n###### Build\n\n";

105
xmlV2.rng Normal file → Executable file
View File

@ -1,50 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<grammar ns="" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <grammar ns="" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start> <start>
<element name="results"> <element name="results">
<attribute name="version"> <attribute name="version">
<data type="integer"/> <data type="integer"/>
</attribute> </attribute>
<element name="cppcheck"> <element name="cppcheck">
<attribute name="version"/> <attribute name="version"/>
</element> </element>
<element name="errors"> <element name="errors">
<oneOrMore> <oneOrMore>
<element name="error"> <element name="error">
<optional> <optional>
<attribute name="cwe"> <attribute name="cwe">
<data type="integer"/> <data type="integer"/>
</attribute> </attribute>
</optional> </optional>
<attribute name="id"> <attribute name="id">
<data type="NCName"/> <data type="NCName"/>
</attribute> </attribute>
<optional> <optional>
<attribute name="inconclusive"> <attribute name="inconclusive">
<data type="boolean"/> <data type="boolean"/>
</attribute> </attribute>
</optional> </optional>
<attribute name="msg"/> <attribute name="msg"/>
<attribute name="severity"> <attribute name="severity">
<data type="NCName"/> <data type="NCName"/>
</attribute> </attribute>
<attribute name="verbose"/> <attribute name="verbose"/>
<choice> <choice>
<element name="location"> <zeroOrMore>
<attribute name="file"/> <element name="location">
<attribute name="line"> <attribute name="file"/>
<data type="integer"/> <optional>
</attribute> <attribute name="info"/>
</element> </optional>
<zeroOrMore> <attribute name="line">
<element name="symbol"> <data type="integer"/>
<data type="string"/> </attribute>
</element> </element>
</zeroOrMore> </zeroOrMore>
</choice> <zeroOrMore>
</element> <element name="symbol">
</oneOrMore> <data type="anyURI"/>
</element> </element>
</element> </zeroOrMore>
</start> </choice>
</grammar> </element>
</oneOrMore>
</element>
</element>
</start>
</grammar>