Skip to content

Commit

Permalink
Misra test now fails if the safety files have any Misra violation in …
Browse files Browse the repository at this point in the history
…them (commaai#221)
  • Loading branch information
rbiasini authored Jun 18, 2019
2 parents 6cd5a4f + c6ec11e commit 6f672d4
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions tests/misra/test_misra.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
#!/bin/bash -e

INPUT1=$1

echo $INPUT1

git clone https://github.com/danmar/cppcheck.git || true
cd cppcheck
#git checkout 1584e6236758d54b0d246d41771d67338e0bd41b
git fetch
git checkout 44d6066c6fad32e2b0332b3f2b24bd340febaef8
make -j4
cd ../../../

if [ "$INPUT1" != "safety-only" ]; then
# whole panda code
tests/misra/cppcheck/cppcheck --dump --enable=all --inline-suppr board/main.c 2>/tmp/misra/cppcheck_output.txt || true
python tests/misra/cppcheck/addons/misra.py board/main.c.dump 2>/tmp/misra/misra_output.txt || true
fi
# whole panda code
tests/misra/cppcheck/cppcheck --dump --enable=all --inline-suppr board/main.c 2>/tmp/misra/cppcheck_output.txt || true
python tests/misra/cppcheck/addons/misra.py board/main.c.dump 2>/tmp/misra/misra_output.txt || true

# violations in safety files
(cat /tmp/misra/misra_output.txt | grep safety) > /tmp/misra/misra_safety_output.txt
(cat /tmp/misra/cppcheck_output.txt | grep safety) > /tmp/misra/cppcheck_safety_output.txt
(cat /tmp/misra/misra_output.txt | grep safety) > /tmp/misra/misra_safety_output.txt || true
(cat /tmp/misra/cppcheck_output.txt | grep safety) > /tmp/misra/cppcheck_safety_output.txt || true

if [[ -s "/tmp/misra/misra_safety_output.txt" ]] || [[ -s "/tmp/misra/cppcheck_safety_output.txt" ]]
then
echo "Found Misra violations in the safety code:"
cat /tmp/misra/misra_safety_output.txt
cat /tmp/misra/cppcheck_safety_output.txt
exit 1
fi

0 comments on commit 6f672d4

Please sign in to comment.