summaryrefslogtreecommitdiffhomepage
path: root/tests/Makefile
blob: 00c50a11022acaa981ece1f0bb34e2446f2960e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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. -I.. -fPIE

CXXTESTFLAGS=

LIBS=\
-lreichwein \
-lboost_context \
-lboost_filesystem \
-lboost_timer \
-lboost_system \
-lcrypt \
-lpthread \
-lssl -lcrypto \
-ldl \
$(shell pkg-config --libs fmt)

LDFLAGS+=-pie

UNITS=\
    auth.cpp \
    config.cpp \
    http.cpp \
    https.cpp \
    plugin.cpp \
    privileges.cpp \
    response.cpp \
    statistics.cpp \
    server.cpp \
    webserver.cpp

TESTSRC=\
    test-archive.cpp \
    test-auth.cpp \
    test-config.cpp \
    test-environment.cpp \
    test-http.cpp \
    test-https.cpp \
    test-plugin.cpp \
    test-privileges.cpp \
    test-response.cpp \
    test-server.cpp \
    test-statistics.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) $(UNITS:.cpp=.o)
	$(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@

dep: $(TESTSRC:.cpp=.d)

%.d: %.cpp
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -MM -MP -MF $@ -c $<

%.o: %.cpp %.d
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@

auth.o: ../auth.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 $@
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) *.gcda *.gcno *.profraw *.profdata *.gcov

.PHONY: clean all install

-include $(wildcard $(TESTSRC:.cpp=.d))