*add unit test makefile.
This commit is contained in:
@@ -0,0 +1,75 @@
|
|||||||
|
|
||||||
|
PMD_HOME ?= /home/gatsby/Software/pmd-bin-6.0.1
|
||||||
|
OCLINT_HOME ?= /home/gatsby/Software/oclint-0.13.1
|
||||||
|
|
||||||
|
# Source files
|
||||||
|
DEBUG_LEVEL := 0
|
||||||
|
COMMON_SRC := ../src/system_monitor.h ../src/system_monitor.c
|
||||||
|
TEST_FRAME := unit_test_framework.h
|
||||||
|
UTIL_SRC := $(wildcard ../src/util/*.c ../src/util/*.h)
|
||||||
|
TMC_SRC := $(wildcard ../src/time_ctrl/*.c ../src/time_ctrl/*.h)
|
||||||
|
PHY_SRC := $(wildcard ../src/networking/phy_layer/*.c ../src/networking/phy_layer/*.h)
|
||||||
|
GEOMETRY_SRC := $(wildcard ../src/networking/link_layer/geometry/*.c ../src/networking/link_layer/geometry/*.h)
|
||||||
|
LINK_SRC := $(wildcard ../src/networking/link_layer/*.c ../src/networking/link_layer/*.h)
|
||||||
|
|
||||||
|
# Compiler
|
||||||
|
CC ?= gcc
|
||||||
|
|
||||||
|
# Compiler flags
|
||||||
|
CFLAGS ?= --std=c11 -O0 -I../src -I../src/include -Wall -Wformat=2 -Werror -pedantic -g -Wno-sign-compare -Wno-comment
|
||||||
|
|
||||||
|
# Add sanitizer flags for identifying undefined behavior. The flags are
|
||||||
|
# different on macOS (AKA Darwin) and Windows/WSL/Linux.
|
||||||
|
UNAME := $(shell uname -s)
|
||||||
|
ifeq "$(UNAME)" "Darwin"
|
||||||
|
CFLAGS += -fsanitize=address -fsanitize=undefined
|
||||||
|
else
|
||||||
|
CFLAGS += -m32 -fsanitize=address -fsanitize=undefined -D_GLIBCC_DEBUG
|
||||||
|
endif
|
||||||
|
|
||||||
|
test: linklayer_emulate_unit_test.exe
|
||||||
|
./linklayer_emulate_unit_test.exe > linklayer_emulate_unit_test.log
|
||||||
|
|
||||||
|
linklayer_emulate_unit_test.exe: linklayer_emulate_unit_test.c \
|
||||||
|
$(LINK_SRC) \
|
||||||
|
$(GEOMETRY_SRC) \
|
||||||
|
$(PHY_SRC) \
|
||||||
|
$(TMC_SRC) \
|
||||||
|
$(UTIL_SRC) \
|
||||||
|
$(COMMON_SRC) \
|
||||||
|
$(TEST_FRAME) \
|
||||||
|
Makefile
|
||||||
|
$(CC) $(CFLAGS) -lm -DEMULATION -D_DEBUG_LEVEL=$(DEBUG_LEVEL) $(filter %.c, $^) -o $@
|
||||||
|
clean:
|
||||||
|
rm -f *.exe *.log
|
||||||
|
|
||||||
|
# Style check
|
||||||
|
CPD ?= $(PMD_HOME)/bin/run.sh cpd
|
||||||
|
OCLINT ?= $(OCLINT_HOME)/bin/oclint
|
||||||
|
FILES := $(SRCS)
|
||||||
|
CPD_FILES := $(SRCS)
|
||||||
|
style :
|
||||||
|
$(OCLINT) \
|
||||||
|
-no-analytics \
|
||||||
|
-rule=LongLine \
|
||||||
|
-rule=HighNcssMethod \
|
||||||
|
-rule=DeepNestedBlock \
|
||||||
|
-rule=TooManyParameters \
|
||||||
|
-rc=LONG_LINE=80 \
|
||||||
|
-rc=NCSS_METHOD=1000 \
|
||||||
|
-rc=NESTED_BLOCK_DEPTH=4 \
|
||||||
|
-rc=TOO_MANY_PARAMETERS=4 \
|
||||||
|
-max-priority-1 0 \
|
||||||
|
-max-priority-2 0 \
|
||||||
|
-max-priority-3 0 \
|
||||||
|
$(FILES) \
|
||||||
|
-- -xc++ --std=c99
|
||||||
|
$(CPD) \
|
||||||
|
--minimum-tokens 100 \
|
||||||
|
--language c \
|
||||||
|
--failOnViolation true \
|
||||||
|
--files $(CPD_FILES)
|
||||||
|
@echo "########################################"
|
||||||
|
@echo "Style checks PASS"
|
||||||
|
|
||||||
|
.PHONY: clean test
|
||||||
Reference in New Issue
Block a user