1
- #! /bin/bash -e
1
+ #! /bin/bash
2
2
3
3
git clone https://github.com/danmar/cppcheck.git || true
4
4
cd cppcheck
@@ -7,22 +7,50 @@ git checkout 862c4ef87b109ae86c2d5f12769b7c8d199f35c5
7
7
make -j4
8
8
cd ../../../
9
9
10
- # panda code
11
- tests/misra/cppcheck/cppcheck -DPANDA -UPEDAL -DCAN3 -DUID_BASE --suppressions-list=tests/misra/suppressions.txt --dump --enable=all --inline-suppr --force board/main.c 2> /tmp/misra/cppcheck_output.txt || true
12
- python tests/misra/cppcheck/addons/misra.py board/main.c.dump 2> /tmp/misra/misra_output.txt || true
10
+
11
+ printf " \nPANDA CODE\n"
12
+ # tests/misra/cppcheck/cppcheck -DPANDA -UPEDAL -DCAN3 -DUID_BASE \
13
+ # --suppressions-list=tests/misra/suppressions.txt \
14
+ # --dump --enable=all --inline-suppr --force \
15
+ # board/main.c 2>/tmp/misra/cppcheck_output.txt
16
+
17
+ python tests/misra/cppcheck/addons/misra.py board/main.c.dump 2> /tmp/misra/misra_output.txt
13
18
14
19
# violations in safety files
15
- (cat /tmp/misra/misra_output.txt | grep safety) > /tmp/misra/misra_safety_output.txt || true
16
- (cat /tmp/misra/cppcheck_output.txt | grep safety) > /tmp/misra/cppcheck_safety_output.txt || true
20
+ misra_output=$( cat /tmp/misra/misra_output.txt | grep safety) ;
21
+ cppcheck_output=$( cat /tmp/misra/cppcheck_output.txt | grep safety) ;
22
+ # TODO: remove safety only check when the whole panda code is MISRA compatible and replace with below
23
+ # strip (information) lines
24
+ # misra_output=$(cat /tmp/misra/misra_output.txt | grep -v "(information) " || true)
25
+ # cppcheck_output=$(cat /tmp/misra/cppcheck_output.txt | grep -v "(information) " || true)
26
+
27
+
28
+
29
+ printf " \nPEDAL CODE\n"
30
+ tests/misra/cppcheck/cppcheck -UPANDA -DPEDAL -UCAN3 \
31
+ --suppressions-list=tests/misra/suppressions.txt \
32
+ -I board/ --dump --enable=all --inline-suppr --force \
33
+ board/pedal/main.c 2> /tmp/misra/cppcheck_pedal_output.txt
34
+
35
+ python tests/misra/cppcheck/addons/misra.py board/pedal/main.c.dump 2> /tmp/misra/misra_pedal_output.txt
36
+
37
+ # strip (information) lines
38
+ misra_pedal_output=$( cat /tmp/misra/misra_pedal_output.txt | grep -v " (information) " )
39
+ cppcheck_pedal_output=$( cat /tmp/misra/cppcheck_pedal_output.txt | grep -v " (information) " )
17
40
18
- if [[ -s " /tmp/misra/misra_safety_output.txt " ]] || [[ -s " /tmp/misra/cppcheck_safety_output.txt " ]]
41
+ if [[ -n " $misra_output " ]] || [[ -n " $cppcheck_output " ]]
19
42
then
20
43
echo " Found Misra violations in the safety code:"
21
- cat /tmp/misra/misra_safety_output.txt
22
- cat /tmp/misra/cppcheck_safety_output.txt
44
+ echo " $misra_output "
45
+ echo " $cppcheck_output "
23
46
exit 1
24
47
fi
25
48
26
- # pedal code
27
- 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 || true
28
- python tests/misra/cppcheck/addons/misra.py board/pedal/main.c.dump 2> /tmp/misra/misra_pedal_output.txt || true
49
+ # TODO: enable pedal check when the whole pedal code is Misra compliant
50
+ # if [[ ! -z "$misra_pedal_output" ]] || [[ ! -z "$cppcheck_pedal_output" ]]
51
+ # then
52
+ # echo "Found Misra violations in the pedal code:"
53
+ # echo "$misra_pedal_output"
54
+ # echo "$cppcheck_pedal_output"
55
+ # exit 1
56
+ # fi
0 commit comments