summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorJaakko Hannikainen <jaakko.hannikainen@intel.com>2016-08-31 14:17:03 +0300
committerAnas Nashif <nashif@linux.intel.com>2016-09-30 21:17:42 +0000
commit54c90bcbd57a529b544ba3eacd953ad36ddd9641 (patch)
tree543fbf528dd86481135cf627c138be3b96957f4d /tests/unit
parentbdfe417020ac813bcbb6ba34a5aa5e7d72188598 (diff)
tests: Add gcov support
If the -C flag is given to sanitycheck, generate gcov files for unit tests and render them with lcov. Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com> Change-Id: Ic25eae6a3cfc2c45595bd6aa235df2c483aaf6ec
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/Makefile.unittest8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/unit/Makefile.unittest b/tests/unit/Makefile.unittest
index c07d03cdc..8879b7648 100644
--- a/tests/unit/Makefile.unittest
+++ b/tests/unit/Makefile.unittest
@@ -8,6 +8,12 @@ O ?= outdir
INCLUDE += tests/ztest/include tests/include include
CFLAGS += -O0 -Wall -Werror
+ifdef COVERAGE
+ export GCOV_PREFIX=$(O)
+ CFLAGS += -fprofile-arcs -ftest-coverage \
+ -fno-default-inline -fno-inline
+endif
+
ifneq (, $(shell which valgrind 2> /dev/null))
VALGRIND = valgrind
VALGRIND_FLAGS = --leak-check=full --error-exitcode=1 \
@@ -31,7 +37,7 @@ VPATH = $(ZEPHYR_BASE)
$(O)/%.o : %.c
mkdir -p $(@D)
- $(CC) -I$(ZEPHYR_BASE) $(CFLAGS) $(INCLUDED) -c $< -o $@
+ $(CC) -I$(ZEPHYR_BASE) $(CFLAGS) $(INCLUDED) -c $(realpath $<) -o $@
$(TARGET): $(OBJS)
mkdir -p $(@D)