summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile63
1 files changed, 61 insertions, 2 deletions
diff --git a/tests/Makefile b/tests/Makefile
index d4c53cb..338800a 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,7 +1,18 @@
+CXXFLAGS=-g -O0
+
include ../common.mk
PROJECTNAME=test-webserver
+ifeq ($(CXXTYPE),clang++)
+CXXFLAGS+=-fprofile-instr-generate -fcoverage-mapping
+LDFLAGS+=-fprofile-instr-generate -fcoverage-mapping
+else
+# GCC
+CXXFLAGS+=--coverage
+LDFLAGS+=--coverage
+endif
+
CXXFLAGS+= -I. -fPIE
CXXTESTFLAGS=
@@ -19,15 +30,36 @@ LIBS=\
LDFLAGS+=-pie
+UNITS=\
+ auth.cpp \
+ base64.cpp \
+ config.cpp \
+ http.cpp \
+ https.cpp \
+ os.cpp \
+ plugin.cpp \
+ privileges.cpp \
+ response.cpp \
+ statistics.cpp \
+ server.cpp \
+ webserver.cpp
+
TESTSRC=\
test-environment.cpp \
test-webserver.cpp \
$(PROGSRC)
build: $(PROJECTNAME)
+ifeq ($(CXXTYPE),clang++)
+ LLVM_PROFILE_FILE="$(PROJECTNAME).profraw" ./$(PROJECTNAME)
+ $(LLVMPROFDATA) merge -sparse $(PROJECTNAME).profraw -o $(PROJECTNAME).profdata
+ $(LLVMCOV) report --ignore-filename-regex='google' --ignore-filename-regex='test-' --show-region-summary=0 -instr-profile $(PROJECTNAME).profdata $(PROJECTNAME)
+else
./$(PROJECTNAME)
+ gcovr -r ..
+endif
-$(PROJECTNAME): $(TESTSRC:.cpp=.o)
+$(PROJECTNAME): $(TESTSRC:.cpp=.o) $(UNITS:.cpp=.o)
$(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@
dep: $(TESTSRC:.cpp=.d)
@@ -38,10 +70,37 @@ dep: $(TESTSRC:.cpp=.d)
%.o: %.cpp %.d
$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
+auth.o: ../auth.cpp
+ $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
+base64.o: ../base64.cpp
+ $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
+config.o: ../config.cpp
+ $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
+http.o: ../http.cpp
+ $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
+https.o: ../https.cpp
+ $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
+os.o: ../os.cpp
+ $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
+plugin.o: ../plugin.cpp
+ $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
+privileges.o: ../privileges.cpp
+ $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
+response.o: ../response.cpp
+ $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
+statistics.o: ../statistics.cpp
+ $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
+server.o: ../server.cpp
+ $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
+webserver.o: ../webserver.cpp
+ $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
+
+ADD_DEP=Makefile
+
# misc ---------------------------------------------------
clean:
- -rm -f *.o *.a *.d $(PROJECTNAME)
+ -rm -f *.o *.a *.d $(PROJECTNAME) *.gcda *.gcno *.profraw *.profdata *.gcov
.PHONY: clean all install