Skip to content

Commit

Permalink
Add misra tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ReFil committed Nov 17, 2023
1 parent cfb6b67 commit 6778eec
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions board/board_declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct board {
#define HW_TYPE_DOS 6U
#define HW_TYPE_CTRLS 7U
#define HW_TYPE_IBST 8U
#define HW_TYPE_KOMBI 9U

// LED colors
#define LED_RED 0U
Expand Down
2 changes: 1 addition & 1 deletion board/kombi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PROJ_NAME = panda
CFLAGS = -g -Wall -Wextra -Wstrict-prototypes -Werror

CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4
CFLAGS += -mhard-float -DSTM32F4 -DSTM32F413xx -mfpu=fpv4-sp-d16 -fsingle-precision-constant -DIBST
CFLAGS += -mhard-float -DSTM32F4 -DSTM32F413xx -mfpu=fpv4-sp-d16 -fsingle-precision-constant -DKOMBI
STARTUP_FILE = startup_stm32f413xx

CFLAGS += -I ../inc -I ../ -I ../../ -nostdlib -fno-builtin -std=gnu11 -Os
Expand Down
4 changes: 2 additions & 2 deletions board/kombi/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ uint16_t intermediary_rpm;
uint8_t scaled_rpm;



// ECU/SAM CANBUS
void CAN1_RX0_IRQ_Handler(void) {
while ((CAN1->RF0R & CAN_RF0R_FMP0) != 0) {
CAN_FIFOMailBox_TypeDef to_send;
Expand Down Expand Up @@ -246,7 +246,7 @@ void CAN1_RX0_IRQ_Handler(void) {
puth(scaled_rpm);
puts("\n");
#endif
//Forward message unmolested
//Forward message unmolested to cluster and abs

to_send.RDLR = dat[0] | (dat[1] << 8) | (dat[2] << 16) | (dat[3] << 24);
to_send.RDHR = dat[4] | (dat[5] << 8) | (dat[6] << 16) | (dat[7] << 24);
Expand Down
20 changes: 20 additions & 0 deletions tests/misra/test_misra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ python /usr/share/cppcheck/addons/misra.py $PANDA_DIR/board/ctrls/main.c.dump 2>
cppcheck_ctrls_output=$( cat /tmp/misra/cppcheck_ctrls_output.txt | grep -v ": information: " ) || true
misra_ctrls_output=$( cat /tmp/misra/misra_ctrls_output.txt | grep -v ": information: " ) || true

printf "\nKOMBI CODE\n"
cppcheck -UPANDA -DKOMBI -UCAN3 -UPEDAL -USTM32F4 -UIBST -UCTRKS\
--suppressions-list=suppressions.txt \
-I $PANDA_DIR/board/ --dump --enable=all --inline-suppr --force \
$PANDA_DIR/board/kombi/main.c 2>/tmp/misra/cppcheck_kombi_output.txt

python /usr/share/cppcheck/addons/misra.py $PANDA_DIR/board/kombi/main.c.dump 2> /tmp/misra/misra_kombi_output.txt || true

# strip (information) lines
cppcheck_kombi_output=$( cat /tmp/misra/cppcheck_kombi_output.txt | grep -v ": information: " ) || true
misra_kombi_output=$( cat /tmp/misra/misra_kombi_output.txt | grep -v ": information: " ) || true

if [[ -n "$misra_output" ]] || [[ -n "$cppcheck_output" ]]
then
echo "Failed! found Misra violations in panda code:"
Expand Down Expand Up @@ -107,4 +119,12 @@ then
echo "$cppcheck_ctrls_output"
exit 1
fi

if [[ -n "$misra_kombi_output" ]] || [[ -n "$cppcheck_kombi_output" ]]
then
echo "Failed! found Misra violations in kombi code:"
echo "$misra_kombi_output"
echo "$cppcheck_kombi_output"
exit 1
fi
echo "Success"

0 comments on commit 6778eec

Please sign in to comment.