提交 cc0f58cf 编写于 作者: J jsalling

Create coverage target in Makefile to output statement coverage with gcov

上级 ce6f4737
CC = gcc CC = gcc
ifeq ($(shell uname -s), Darwin)
CC = clang
endif
#DEBUG = -O0 -g #DEBUG = -O0 -g
CFLAGS += -std=c99 CFLAGS += -std=c99
CFLAGS += -pedantic CFLAGS += -pedantic
...@@ -15,21 +18,22 @@ SRC = ../src/unity_fixture.c \ ...@@ -15,21 +18,22 @@ SRC = ../src/unity_fixture.c \
main/AllTests.c main/AllTests.c
INC_DIR = -I../src -I../../../src/ INC_DIR = -I../src -I../../../src/
BUILD_DIR = ../build
TARGET = ../build/fixture_tests.exe TARGET = ../build/fixture_tests.exe
all: default noStdlibMalloc 32bits all: default noStdlibMalloc 32bits
default: ../build/ default: $(BUILD_DIR)
$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) $(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_SUPPORT_64
@ echo "default build" @ echo "default build"
./$(TARGET) ./$(TARGET)
32bits: ../build/ 32bits: $(BUILD_DIR)
$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -m32 $(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -m32
@ echo "32bits build" @ echo "32bits build"
./$(TARGET) ./$(TARGET)
noStdlibMalloc: ../build/ noStdlibMalloc: $(BUILD_DIR)
$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_EXCLUDE_STDLIB_MALLOC $(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_EXCLUDE_STDLIB_MALLOC
@ echo "build with noStdlibMalloc" @ echo "build with noStdlibMalloc"
./$(TARGET) ./$(TARGET)
...@@ -40,13 +44,22 @@ clang89: ../build/ ...@@ -40,13 +44,22 @@ clang89: ../build/
-D UNITY_EXCLUDE_STDLIB_MALLOC -std=c89 -Wno-comment ; ./$(TARGET) -D UNITY_EXCLUDE_STDLIB_MALLOC -std=c89 -Wno-comment ; ./$(TARGET)
clangEverything: clangEverything:
clang $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -m64 -Weverything clang $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -Weverything
../build : $(BUILD_DIR):
mkdir -p ../build mkdir -p $(BUILD_DIR)
clean: clean:
rm -f $(TARGET) rm -f $(TARGET) $(BUILD_DIR)/*.gc*
coverage: $(BUILD_DIR)
cd $(BUILD_DIR) && \
$(CC) $(DEFINES) $(foreach i, $(SRC), ../test/$(i)) $(INC_DIR) -o $(TARGET) -fprofile-arcs -ftest-coverage
rm -f $(BUILD_DIR)/*.gcda
./$(TARGET) > /dev/null ; ./$(TARGET) -v > /dev/null
cd $(BUILD_DIR) && \
gcov unity_fixture.c | head -3
grep '###' $(BUILD_DIR)/unity_fixture.c.gcov -C2 || true # Show uncovered lines
# These extended flags DO get included before any target build runs # These extended flags DO get included before any target build runs
CFLAGS += -Wbad-function-cast CFLAGS += -Wbad-function-cast
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册