You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					54 lines
				
				1.9 KiB
			
		
		
			
		
	
	
					54 lines
				
				1.9 KiB
			| 
								 
											6 years ago
										 
									 | 
							
								#!/bin/bash -e
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								mkdir /tmp/misra || true
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								git clone https://github.com/danmar/cppcheck.git || true
							 | 
						||
| 
								 | 
							
								cd cppcheck
							 | 
						||
| 
								 | 
							
								git fetch
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								git checkout 862c4ef87b109ae86c2d5f12769b7c8d199f35c5
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								make -j4
							 | 
						||
| 
								 | 
							
								cd ../../../
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								printf "\nPANDA CODE\n"
							 | 
						||
| 
								 | 
							
								tests/misra/cppcheck/cppcheck -DPANDA -UPEDAL -DCAN3 -DUID_BASE -DEON \
							 | 
						||
| 
								 | 
							
								                              --suppressions-list=tests/misra/suppressions.txt \
							 | 
						||
| 
								 | 
							
								                              --dump --enable=all --inline-suppr --force \
							 | 
						||
| 
								 | 
							
								                              board/main.c 2>/tmp/misra/cppcheck_output.txt
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								python tests/misra/cppcheck/addons/misra.py board/main.c.dump 2> /tmp/misra/misra_output.txt || true
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# strip (information) lines
							 | 
						||
| 
								 | 
							
								cppcheck_output=$( cat /tmp/misra/cppcheck_output.txt | grep -v "(information) " ) || true
							 | 
						||
| 
								 | 
							
								misra_output=$( cat /tmp/misra/misra_output.txt | grep -v "(information) " ) || true
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								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
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								python tests/misra/cppcheck/addons/misra.py board/pedal/main.c.dump 2> /tmp/misra/misra_pedal_output.txt || true
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# strip (information) lines
							 | 
						||
| 
								 | 
							
								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
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								if [[ -n "$misra_output" ]] || [[ -n "$cppcheck_output" ]]
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								then
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								  echo "Failed! found Misra violations in panda code:"
							 | 
						||
| 
								 | 
							
								  echo "$misra_output"
							 | 
						||
| 
								 | 
							
								  echo "$cppcheck_output"
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								  exit 1
							 | 
						||
| 
								 | 
							
								fi
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								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"
							 |