2019-07-10 20:56:03 -07:00
|
|
|
#!/bin/bash -e
|
2019-06-12 06:35:47 -07:00
|
|
|
|
2019-07-10 20:56:03 -07:00
|
|
|
mkdir /tmp/misra || true
|
2019-05-20 22:13:45 -07:00
|
|
|
git clone https://github.com/danmar/cppcheck.git || true
|
|
|
|
|
cd cppcheck
|
2019-06-17 18:54:05 -07:00
|
|
|
git fetch
|
2019-10-15 13:57:36 -07:00
|
|
|
git checkout 7d6d561c84cfc6dd84f51378d3123a17fe0a1aa5
|
2019-05-20 22:13:45 -07:00
|
|
|
make -j4
|
|
|
|
|
cd ../../../
|
2019-06-10 21:58:01 -07:00
|
|
|
|
2019-09-27 11:11:07 -07:00
|
|
|
# generate coverage matrix
|
|
|
|
|
python tests/misra/cppcheck/addons/misra.py -generate-table > tests/misra/coverage_table
|
2019-07-09 14:37:26 -07:00
|
|
|
|
|
|
|
|
printf "\nPANDA CODE\n"
|
2019-07-10 12:02:32 -07:00
|
|
|
tests/misra/cppcheck/cppcheck -DPANDA -UPEDAL -DCAN3 -DUID_BASE -DEON \
|
2019-07-09 16:18:44 -07:00
|
|
|
--suppressions-list=tests/misra/suppressions.txt \
|
|
|
|
|
--dump --enable=all --inline-suppr --force \
|
|
|
|
|
board/main.c 2>/tmp/misra/cppcheck_output.txt
|
2019-07-09 14:37:26 -07:00
|
|
|
|
2019-07-12 12:04:21 -07:00
|
|
|
python tests/misra/cppcheck/addons/misra.py board/main.c.dump 2> /tmp/misra/misra_output.txt || true
|
2019-06-10 21:58:01 -07:00
|
|
|
|
2019-07-09 14:37:26 -07:00
|
|
|
# strip (information) lines
|
2019-09-27 17:18:02 -07:00
|
|
|
cppcheck_output=$( cat /tmp/misra/cppcheck_output.txt | grep -v ": information: " ) || true
|
|
|
|
|
misra_output=$( cat /tmp/misra/misra_output.txt | grep -v ": information: " ) || true
|
2019-07-09 14:37:26 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
printf "\nPEDAL CODE\n"
|
|
|
|
|
tests/misra/cppcheck/cppcheck -UPANDA -DPEDAL -UCAN3 \
|
|
|
|
|
--suppressions-list=tests/misra/suppressions.txt \
|
|
|
|
|
-I board/ --dump --enable=all --inline-suppr --force \
|
|
|
|
|
board/pedal/main.c 2>/tmp/misra/cppcheck_pedal_output.txt
|
|
|
|
|
|
2019-07-10 20:56:03 -07:00
|
|
|
python tests/misra/cppcheck/addons/misra.py board/pedal/main.c.dump 2> /tmp/misra/misra_pedal_output.txt || true
|
2019-07-09 14:37:26 -07:00
|
|
|
|
|
|
|
|
# strip (information) lines
|
2019-09-27 17:18:02 -07:00
|
|
|
cppcheck_pedal_output=$( cat /tmp/misra/cppcheck_pedal_output.txt | grep -v ": information: " ) || true
|
|
|
|
|
misra_pedal_output=$( cat /tmp/misra/misra_pedal_output.txt | grep -v ": information: " ) || true
|
2019-06-17 19:50:03 -07:00
|
|
|
|
2019-07-09 14:37:26 -07:00
|
|
|
if [[ -n "$misra_output" ]] || [[ -n "$cppcheck_output" ]]
|
2019-06-17 19:50:03 -07:00
|
|
|
then
|
2019-07-10 20:56:03 -07:00
|
|
|
echo "Failed! found Misra violations in panda code:"
|
2019-07-09 14:37:26 -07:00
|
|
|
echo "$misra_output"
|
|
|
|
|
echo "$cppcheck_output"
|
2019-06-17 19:50:03 -07:00
|
|
|
exit 1
|
|
|
|
|
fi
|
2019-07-04 02:58:17 -07:00
|
|
|
|
2019-07-10 20:56:03 -07:00
|
|
|
if [[ -n "$misra_pedal_output" ]] || [[ -n "$cppcheck_pedal_output" ]]
|
|
|
|
|
then
|
|
|
|
|
echo "Failed! found Misra violations in pedal code:"
|
|
|
|
|
echo "$misra_pedal_output"
|
|
|
|
|
echo "$cppcheck_pedal_output"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "Success"
|