2013-10-12 15:49:42 +02:00
|
|
|
#!/bin/bash -ex
|
|
|
|
|
2019-11-01 15:06:44 +01:00
|
|
|
# Command for checking HTML syntax with HTML Tidy, see http://www.html-tidy.org/
|
2021-04-09 07:47:11 +02:00
|
|
|
tidy_version=$(tidy --version)
|
|
|
|
|
|
|
|
if [[ "$tidy_version" == *"5.6.0"* ]] ;then
|
|
|
|
# newer tidy (5.6.0) command, if using this it is not necessary to ignore warnings:
|
|
|
|
tidy_cmd='tidy -o /dev/null -eq --drop-empty-elements no'
|
|
|
|
else
|
|
|
|
# older tidy from 2009 (Ubuntu 16.04 Xenial comes with this old version):
|
|
|
|
tidy_cmd='tidy -o /dev/null -eq'
|
|
|
|
fi
|
2019-11-01 15:06:44 +01:00
|
|
|
|
|
|
|
function validate_html {
|
2020-11-04 21:03:46 +01:00
|
|
|
if [ ! -f "$1" ]; then
|
|
|
|
echo "File $1 does not exist!"
|
2021-04-09 07:47:11 +02:00
|
|
|
exit 1
|
2020-11-04 21:03:46 +01:00
|
|
|
fi
|
2021-04-09 07:47:11 +02:00
|
|
|
if ! ${tidy_cmd} "$1"; then
|
|
|
|
echo "HTML validation failed!"
|
2019-11-01 15:06:44 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
2013-10-12 15:49:42 +02:00
|
|
|
|
2020-11-04 21:03:46 +01:00
|
|
|
if [ -z "$PYTHON" ]; then
|
|
|
|
PYTHON=python
|
|
|
|
fi
|
|
|
|
|
|
|
|
REPORT_DIR=$(mktemp -d -t htmlreport-XXXXXXXXXX)
|
|
|
|
INDEX_HTML="$REPORT_DIR/index.html"
|
|
|
|
STATS_HTML="$REPORT_DIR/stats.html"
|
|
|
|
GUI_TEST_XML="$REPORT_DIR/gui_test.xml"
|
|
|
|
ERRORLIST_XML="$REPORT_DIR/errorlist.xml"
|
|
|
|
UNMATCHEDSUPPR_XML="$REPORT_DIR/unmatchedSuppr.xml"
|
|
|
|
|
|
|
|
$PYTHON cppcheck-htmlreport --file ../gui/test/data/xmlfiles/xmlreport_v2.xml --title "xml2 test" --report-dir "$REPORT_DIR" --source-dir ../test/
|
2013-10-12 15:49:42 +02:00
|
|
|
echo -e "\n"
|
2019-11-01 15:06:44 +01:00
|
|
|
# Check HTML syntax
|
2020-11-04 21:03:46 +01:00
|
|
|
validate_html "$INDEX_HTML"
|
|
|
|
validate_html "$STATS_HTML"
|
2013-10-12 15:49:42 +02:00
|
|
|
|
|
|
|
|
2022-12-18 19:36:37 +01:00
|
|
|
../cppcheck ../samples --enable=all --inconclusive --xml-version=2 2> "$GUI_TEST_XML"
|
2020-11-04 21:03:46 +01:00
|
|
|
xmllint --noout "$GUI_TEST_XML"
|
|
|
|
$PYTHON cppcheck-htmlreport --file "$GUI_TEST_XML" --title "xml2 + inconclusive test" --report-dir "$REPORT_DIR"
|
2013-10-12 15:49:42 +02:00
|
|
|
echo ""
|
2019-11-01 15:06:44 +01:00
|
|
|
# Check HTML syntax
|
2020-11-04 21:03:46 +01:00
|
|
|
validate_html "$INDEX_HTML"
|
|
|
|
validate_html "$STATS_HTML"
|
2019-11-01 15:06:44 +01:00
|
|
|
|
2013-10-12 15:49:42 +02:00
|
|
|
|
2022-12-18 19:36:37 +01:00
|
|
|
../cppcheck ../samples --enable=all --inconclusive --verbose --xml-version=2 2> "$GUI_TEST_XML"
|
2020-11-04 21:03:46 +01:00
|
|
|
xmllint --noout "$GUI_TEST_XML"
|
|
|
|
$PYTHON cppcheck-htmlreport --file "$GUI_TEST_XML" --title "xml2 + inconclusive + verbose test" --report-dir "$REPORT_DIR"
|
2013-10-12 15:49:42 +02:00
|
|
|
echo -e "\n"
|
2019-11-01 15:06:44 +01:00
|
|
|
# Check HTML syntax
|
2020-11-04 21:03:46 +01:00
|
|
|
validate_html "$INDEX_HTML"
|
|
|
|
validate_html "$STATS_HTML"
|
2013-10-12 15:49:42 +02:00
|
|
|
|
|
|
|
|
2020-11-04 21:03:46 +01:00
|
|
|
../cppcheck --errorlist --inconclusive --xml-version=2 > "$ERRORLIST_XML"
|
|
|
|
xmllint --noout "$ERRORLIST_XML"
|
|
|
|
$PYTHON cppcheck-htmlreport --file "$ERRORLIST_XML" --title "errorlist" --report-dir "$REPORT_DIR"
|
2019-11-01 15:06:44 +01:00
|
|
|
# Check HTML syntax
|
2020-11-04 21:03:46 +01:00
|
|
|
validate_html "$INDEX_HTML"
|
|
|
|
validate_html "$STATS_HTML"
|
2019-11-01 15:06:44 +01:00
|
|
|
|
2015-03-05 17:09:19 +01:00
|
|
|
|
2020-11-04 21:03:46 +01:00
|
|
|
../cppcheck ../samples/memleak/good.c ../samples/resourceLeak/good.c --xml-version=2 --enable=information --suppressions-list=test_suppressions.txt --xml 2> "$UNMATCHEDSUPPR_XML"
|
|
|
|
xmllint --noout "$UNMATCHEDSUPPR_XML"
|
|
|
|
$PYTHON cppcheck-htmlreport --file "$UNMATCHEDSUPPR_XML" --title "unmatched Suppressions" --report-dir="$REPORT_DIR"
|
|
|
|
grep "unmatchedSuppression<.*>information<.*>Unmatched suppression: variableScope*<" "$INDEX_HTML"
|
|
|
|
grep ">unmatchedSuppression</.*>information<.*>Unmatched suppression: uninitstring<" "$INDEX_HTML"
|
|
|
|
grep "notexisting" "$INDEX_HTML"
|
|
|
|
grep ">unmatchedSuppression<.*>information<.*>Unmatched suppression: \*<" "$INDEX_HTML"
|
2019-11-01 15:06:44 +01:00
|
|
|
# Check HTML syntax
|
2020-11-04 21:03:46 +01:00
|
|
|
validate_html "$INDEX_HTML"
|
|
|
|
validate_html "$STATS_HTML"
|
|
|
|
|
|
|
|
rm -rf "$REPORT_DIR"
|