2012-12-14 06:17:40 +01:00
|
|
|
###############################################################################
|
|
|
|
# @file unittest.mk
|
|
|
|
# @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012
|
|
|
|
# @addtogroup
|
|
|
|
# @{
|
|
|
|
# @addtogroup
|
|
|
|
# @{
|
|
|
|
# @brief Makefile template for unit tests
|
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
# for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2012-12-18 07:51:07 +01:00
|
|
|
# Flags passed to the preprocessor.
|
|
|
|
CPPFLAGS += -I$(GTEST_DIR)/include
|
|
|
|
|
|
|
|
# Flags passed to the C++ compiler.
|
2012-12-18 07:51:07 +01:00
|
|
|
CXXFLAGS += -g -Wall -Wextra
|
2012-12-18 07:51:07 +01:00
|
|
|
|
|
|
|
# Google Test needs the pthread library
|
|
|
|
LDFLAGS += -lpthread
|
|
|
|
|
|
|
|
#################################
|
|
|
|
#
|
|
|
|
# Template to build the user test
|
|
|
|
#
|
|
|
|
#################################
|
|
|
|
|
2012-12-14 06:17:40 +01:00
|
|
|
# Need to disable THUMB mode for unit tests
|
|
|
|
override THUMB :=
|
|
|
|
|
|
|
|
EXTRAINCDIRS += .
|
|
|
|
ALLSRC := $(SRC) $(wildcard ./*.c)
|
2013-01-09 07:09:55 +01:00
|
|
|
ALLCPPSRC := $(wildcard ./*.cpp) $(GTEST_DIR)/src/gtest_main.cc
|
2012-12-18 07:51:07 +01:00
|
|
|
ALLSRCBASE := $(notdir $(basename $(ALLSRC) $(ALLCPPSRC)))
|
2012-12-14 06:17:40 +01:00
|
|
|
ALLOBJ := $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE)))
|
|
|
|
|
2013-01-09 07:09:55 +01:00
|
|
|
$(foreach src,$(ALLSRC),$(eval $(call COMPILE_C_TEMPLATE,$(src))))
|
|
|
|
$(foreach src,$(ALLCPPSRC),$(eval $(call COMPILE_CXX_TEMPLATE,$(src))))
|
|
|
|
|
|
|
|
|
|
|
|
# Specific extensions to CPPFLAGS only for the google test library
|
|
|
|
$(OUTDIR)/gtest-all.o : CPPFLAGS += -I$(GTEST_DIR)
|
|
|
|
$(eval $(call COMPILE_CXX_TEMPLATE, $(GTEST_DIR)/src/gtest-all.cc))
|
|
|
|
|
|
|
|
$(eval $(call LINK_CXX_TEMPLATE,$(OUTDIR)/$(TARGET).elf,$(ALLOBJ) $(OUTDIR)/gtest-all.o))
|
|
|
|
|
2012-12-20 08:02:35 +01:00
|
|
|
.PHONY: elf
|
|
|
|
elf: $(OUTDIR)/$(TARGET).elf
|
2012-12-14 06:17:40 +01:00
|
|
|
|
2013-01-09 07:09:55 +01:00
|
|
|
.PHONY: xml
|
2013-02-24 03:03:17 +01:00
|
|
|
xml: $(OUTDIR)/test-reports/$(TARGET).xml
|
2012-12-18 07:51:07 +01:00
|
|
|
|
2013-02-24 03:03:17 +01:00
|
|
|
$(OUTDIR)/test-reports/$(TARGET).xml: $(OUTDIR)/$(TARGET).elf
|
2013-01-09 07:09:55 +01:00
|
|
|
$(V0) @echo " TEST XML $(MSG_EXTRA) $(call toprel, $@)"
|
2013-02-24 03:03:17 +01:00
|
|
|
$(V1) $< --gtest_output=xml:$@ > /dev/null
|
2012-12-14 06:17:40 +01:00
|
|
|
|
2012-12-20 08:02:35 +01:00
|
|
|
.PHONY: run
|
|
|
|
run: $(OUTDIR)/$(TARGET).elf
|
2013-01-09 07:09:55 +01:00
|
|
|
$(V0) @echo " TEST RUN $(MSG_EXTRA) $(call toprel, $<)"
|
2012-12-20 08:02:35 +01:00
|
|
|
$(V1) $<
|