diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 39 | ||||
-rw-r--r-- | libcommon/Makefile | 23 | ||||
-rw-r--r-- | libcommon/tempfile.cpp | 27 | ||||
-rw-r--r-- | libcommon/tempfile.h | 16 | ||||
-rw-r--r-- | plugins/cgi/Makefile | 23 | ||||
-rw-r--r-- | plugins/fcgi/Makefile | 23 | ||||
-rw-r--r-- | plugins/redirect/Makefile | 27 | ||||
-rw-r--r-- | plugins/static-files/Makefile | 23 | ||||
-rw-r--r-- | plugins/statistics/Makefile | 27 | ||||
-rw-r--r-- | plugins/webbox/Makefile | 27 | ||||
-rw-r--r-- | plugins/weblog/Makefile | 20 | ||||
-rw-r--r-- | tests/Makefile | 112 | ||||
-rw-r--r-- | tests/test-webserver.cpp (renamed from test-webserver.cpp) | 0 |
14 files changed, 192 insertions, 197 deletions
@@ -1,5 +1,7 @@ +*.a *.o *.d +*.pem *.so *.swp default.profraw @@ -31,17 +31,15 @@ endif # -fprofile-instr-generate -fcoverage-mapping # gcc:--coverage -CXXFLAGS+= -Wall -I. -DVERSION=\"$(VERSION)\" -fPIE +CXXFLAGS+=-Wall -I. -DVERSION=\"$(VERSION)\" -fPIE -CXXFLAGS+= -pthread +CXXFLAGS+=-pthread ifeq ($(CXX),clang++-10) CXXFLAGS+=-std=c++20 #-stdlib=libc++ else CXXFLAGS+=-std=c++17 endif -CXXTESTFLAGS=-Igoogletest/include -Igooglemock/include/ -Igoogletest -Igooglemock - LIBS=\ -lcommon \ -lboost_context \ @@ -87,38 +85,25 @@ PROGSRC=\ statistics.cpp \ server.cpp -TESTSRC=\ - test-webserver.cpp \ - googlemock/src/gmock-all.cpp \ - googletest/src/gtest-all.cpp \ - $(PROGSRC) - SRC=$(PROGSRC) webserver.cpp -build: $(PROJECTNAME) test-$(PROJECTNAME) +build: $(PROJECTNAME) +set -e ; for i in $(PLUGINS) ; do make -C plugins/$$i ; done - ./test-$(PROJECTNAME) all: build ./webserver -c webserver.conf -# testsuite ---------------------------------------------- -test-$(PROJECTNAME): $(TESTSRC:.cpp=.o) - $(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@ - $(PROJECTNAME): libcommon/libcommon.a $(SRC:.cpp=.o) $(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@ libcommon/libcommon.a: $(MAKE) -C libcommon -dep: $(TESTSRC:.cpp=.d) - %.d: %.cpp - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -MM -MP -MF $@ -c $< + $(CXX) $(CXXFLAGS) -MM -MP -MF $@ -c $< %.o: %.cpp %.d - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ + $(CXX) $(CXXFLAGS) -c $< -o $@ googletest/src/%.o: googletest/src/%.cc $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ @@ -127,6 +112,9 @@ googletest/src/%.o: googletest/src/%.cc ADD_DEP=Makefile +test: + $(MAKE) -C tests + install: mkdir -p $(DESTDIR)/usr/bin cp webserver $(DESTDIR)/usr/bin @@ -156,11 +144,11 @@ $(DISTROS): deb-src debs: $(DISTROS) clean: - -rm -f test-$(PROJECTNAME) $(PROJECTNAME) + -rm -f $(PROJECTNAME) -rm -f plugins/*.so -find . -name '*.o' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm -f - for i in $(PLUGINS) ; do make -C plugins/$$i clean ; done - $(MAKE) -C libcommon clean + #for i in $(PLUGINS) ; do $(MAKE) -C plugins/$$i clean ; done + for i in libcommon tests ; do $(MAKE) -C $$i clean ; done DISTFILES= \ archive.h \ @@ -187,7 +175,8 @@ DISTFILES= \ server.h \ statistics.cpp \ statistics.h \ - test-webserver.cpp \ + tests/Makefile \ + tests/test-webserver.cpp \ webserver.cpp \ webserver.1 \ README.txt \ @@ -262,6 +251,6 @@ dist: clean rm -rf $(PROJECTNAME)-$(VERSION) ls -l ../$(PROJECTNAME)-$(VERSION).tar.xz -.PHONY: clean all zip install deb deb-src debs all $(DISTROS) +.PHONY: clean all zip test install deb deb-src debs all $(DISTROS) -include $(wildcard $(SRC:.cpp=.d)) diff --git a/libcommon/Makefile b/libcommon/Makefile index 932ee90..ab76ed1 100644 --- a/libcommon/Makefile +++ b/libcommon/Makefile @@ -30,8 +30,6 @@ else CXXFLAGS+=-std=c++17 endif -CXXTESTFLAGS=-Igoogletest/include -Igooglemock/include/ -Igoogletest -Igooglemock - LIBS=\ -lboost_context \ -lboost_coroutine \ @@ -64,33 +62,18 @@ PROGSRC=\ stringutil.cpp \ tempfile.cpp -TESTSRC=\ - test-webserver.cpp \ - googlemock/src/gmock-all.cpp \ - googletest/src/gtest-all.cpp \ - $(PROGSRC) - SRC=$(PROGSRC) all: $(PROJECTNAME).a -# testsuite ---------------------------------------------- -test-$(PROJECTNAME): $(TESTSRC:.cpp=.o) - $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@ - $(PROJECTNAME).a: $(SRC:.cpp=.o) ar rcs $@ $^ -dep: $(TESTSRC:.cpp=.d) - %.d: %.cpp - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -MM -MP -MF $@ -c $< + $(CXX) $(CXXFLAGS) -MM -MP -MF $@ -c $< %.o: %.cpp %.d - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ - -googletest/src/%.o: googletest/src/%.cc - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ + $(CXX) $(CXXFLAGS) -c $< -o $@ # dependencies @@ -111,8 +94,6 @@ $(DISTROS): deb-src debs: $(DISTROS) clean: - -rm -f test-$(PROJECTNAME) $(PROJECTNAME) - -find . -name '*.a' -o -name '*.o' -o -name '*.so' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm -f zip: clean -rm -f ../$(PROJECTNAME).zip diff --git a/libcommon/tempfile.cpp b/libcommon/tempfile.cpp new file mode 100644 index 0000000..5d3a086 --- /dev/null +++ b/libcommon/tempfile.cpp @@ -0,0 +1,27 @@ +#include "tempfile.h" + +#include <iostream> + +namespace fs = std::filesystem; +using namespace std::string_literals; + +fs::path Tempfile::GetPath() const +{ + return m_path; +} + +Tempfile::Tempfile() { + try { + m_path = std::string{tmpnam(NULL)} + ".zip"s; + } catch (const std::exception& ex) { + throw std::runtime_error("Tempfile error: "s + ex.what()); + } +} + +Tempfile::~Tempfile() { + try { + fs::remove_all(m_path); + } catch (const std::exception& ex) { + std::cerr << "Warning: Couldn't remove temporary file " << m_path << std::endl; + } +} diff --git a/libcommon/tempfile.h b/libcommon/tempfile.h new file mode 100644 index 0000000..5938fb9 --- /dev/null +++ b/libcommon/tempfile.h @@ -0,0 +1,16 @@ +#pragma once + +#include <filesystem> + +class Tempfile +{ + std::filesystem::path m_path; + + public: + std::filesystem::path GetPath() const; + + Tempfile(); + ~Tempfile(); + }; + + diff --git a/plugins/cgi/Makefile b/plugins/cgi/Makefile index a4fdb15..2d86c50 100644 --- a/plugins/cgi/Makefile +++ b/plugins/cgi/Makefile @@ -28,8 +28,6 @@ else CXXFLAGS+=-std=c++17 endif -CXXTESTFLAGS=-Igoogletest/include -Igooglemock/include/ -Igoogletest -Igooglemock - LIBS=\ -lcommon \ -lboost_context \ @@ -62,33 +60,18 @@ LDFLAGS=-L../../libcommon PROGSRC=\ cgi.cpp -TESTSRC=\ - test-webserver.cpp \ - googlemock/src/gmock-all.cpp \ - googletest/src/gtest-all.cpp \ - $(PROGSRC) - SRC=$(PROGSRC) all: $(PROJECTNAME).so -# testsuite ---------------------------------------------- -test-$(PROJECTNAME): $(TESTSRC:.cpp=.o) - $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@ - $(PROJECTNAME).so: ../../libcommon/libcommon.a $(SRC:.cpp=.o) $(CXX) $(LDFLAGS) $^ -shared $(LDLIBS) $(LIBS) -o $@ -dep: $(TESTSRC:.cpp=.d) - %.d: %.cpp - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -MM -MP -MF $@ -c $< + $(CXX) $(CXXFLAGS) -MM -MP -MF $@ -c $< %.o: %.cpp %.d - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ - -googletest/src/%.o: googletest/src/%.cc - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ + $(CXX) $(CXXFLAGS) -c $< -o $@ # dependencies @@ -112,8 +95,6 @@ $(DISTROS): deb-src debs: $(DISTROS) clean: - -rm -f test-$(PROJECTNAME) $(PROJECTNAME) - -find . -name '*.o' -o -name '*.so' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm -f zip: clean -rm -f ../$(PROJECTNAME).zip diff --git a/plugins/fcgi/Makefile b/plugins/fcgi/Makefile index 0cafe54..8937689 100644 --- a/plugins/fcgi/Makefile +++ b/plugins/fcgi/Makefile @@ -28,8 +28,6 @@ else CXXFLAGS+=-std=c++17 endif -CXXTESTFLAGS=-Igoogletest/include -Igooglemock/include/ -Igoogletest -Igooglemock - LIBS=\ -lboost_context \ -lboost_coroutine \ @@ -61,33 +59,18 @@ PROGSRC=\ fcgiid.cpp \ socket.cpp -TESTSRC=\ - test-webserver.cpp \ - googlemock/src/gmock-all.cpp \ - googletest/src/gtest-all.cpp \ - $(PROGSRC) - SRC=$(PROGSRC) all: $(PROJECTNAME).so -# testsuite ---------------------------------------------- -test-$(PROJECTNAME): $(TESTSRC:.cpp=.o) - $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@ - $(PROJECTNAME).so: $(SRC:.cpp=.o) $(CXX) $(CXXFLAGS) $^ -shared $(LIBS) -o $@ -dep: $(TESTSRC:.cpp=.d) - %.d: %.cpp - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -MM -MP -MF $@ -c $< + $(CXX) $(CXXFLAGS) -MM -MP -MF $@ -c $< %.o: %.cpp %.d - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ - -googletest/src/%.o: googletest/src/%.cc - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ + $(CXX) $(CXXFLAGS) -c $< -o $@ # dependencies @@ -111,8 +94,6 @@ $(DISTROS): deb-src debs: $(DISTROS) clean: - -rm -f test-$(PROJECTNAME) $(PROJECTNAME) - -find . -name '*.o' -o -name '*.so' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm -f zip: clean -rm -f ../$(PROJECTNAME).zip diff --git a/plugins/redirect/Makefile b/plugins/redirect/Makefile index 99aedb1..77b496b 100644 --- a/plugins/redirect/Makefile +++ b/plugins/redirect/Makefile @@ -28,8 +28,6 @@ else CXXFLAGS+=-std=c++17 endif -CXXTESTFLAGS=-Igoogletest/include -Igooglemock/include/ -Igoogletest -Igooglemock - LIBS=\ -lboost_context \ -lboost_coroutine \ @@ -59,37 +57,18 @@ endif PROGSRC=\ redirect.cpp -TESTSRC=\ - test-webserver.cpp \ - googlemock/src/gmock-all.cpp \ - googletest/src/gtest-all.cpp \ - $(PROGSRC) - SRC=$(PROGSRC) all: $(PROJECTNAME).so -# testsuite ---------------------------------------------- -test-$(PROJECTNAME): $(TESTSRC:.cpp=.o) - $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@ - $(PROJECTNAME).so: $(SRC:.cpp=.o) $(CXX) $(CXXFLAGS) $^ -shared $(LIBS) -o $@ -dep: $(TESTSRC:.cpp=.d) - %.d: %.cpp - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -MM -MP -MF $@ -c $< + $(CXX) $(CXXFLAGS) -MM -MP -MF $@ -c $< %.o: %.cpp %.d - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ - -googletest/src/%.o: googletest/src/%.cc - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ - -# dependencies - -ADD_DEP=Makefile + $(CXX) $(CXXFLAGS) -c $< -o $@ install: mkdir -p $(DESTDIR)/usr/lib/webserver/plugins @@ -109,7 +88,7 @@ $(DISTROS): deb-src debs: $(DISTROS) clean: - -rm -f test-$(PROJECTNAME) $(PROJECTNAME) + -rm -f $(PROJECTNAME) -find . -name '*.o' -o -name '*.so' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm -f zip: clean diff --git a/plugins/static-files/Makefile b/plugins/static-files/Makefile index 14c6c17..9834e96 100644 --- a/plugins/static-files/Makefile +++ b/plugins/static-files/Makefile @@ -28,8 +28,6 @@ else CXXFLAGS+=-std=c++17 endif -CXXTESTFLAGS=-Igoogletest/include -Igooglemock/include/ -Igoogletest -Igooglemock - LIBS=\ -lcommon \ -lboost_context \ @@ -62,33 +60,18 @@ LDFLAGS=-L../../libcommon PROGSRC=\ static-files.cpp -TESTSRC=\ - test-webserver.cpp \ - googlemock/src/gmock-all.cpp \ - googletest/src/gtest-all.cpp \ - $(PROGSRC) - SRC=$(PROGSRC) all: $(PROJECTNAME).so -# testsuite ---------------------------------------------- -test-$(PROJECTNAME): $(TESTSRC:.cpp=.o) - $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@ - $(PROJECTNAME).so: ../../libcommon/libcommon.a $(SRC:.cpp=.o) $(CXX) $(LDFLAGS) $^ -shared $(LDLIBS) $(LIBS) -o $@ -dep: $(TESTSRC:.cpp=.d) - %.d: %.cpp - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -MM -MP -MF $@ -c $< + $(CXX) $(CXXFLAGS) -MM -MP -MF $@ -c $< %.o: %.cpp %.d - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ - -googletest/src/%.o: googletest/src/%.cc - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ + $(CXX) $(CXXFLAGS) -c $< -o $@ # dependencies @@ -112,7 +95,7 @@ $(DISTROS): deb-src debs: $(DISTROS) clean: - -rm -f test-$(PROJECTNAME) $(PROJECTNAME) + -rm -f $(PROJECTNAME) -find . -name '*.o' -o -name '*.so' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm -f zip: clean diff --git a/plugins/statistics/Makefile b/plugins/statistics/Makefile index 3dee26e..2a0d246 100644 --- a/plugins/statistics/Makefile +++ b/plugins/statistics/Makefile @@ -28,8 +28,6 @@ else CXXFLAGS+=-std=c++17 endif -CXXTESTFLAGS=-Igoogletest/include -Igooglemock/include/ -Igoogletest -Igooglemock - LIBS=\ -lboost_context \ -lboost_coroutine \ @@ -59,37 +57,18 @@ endif PROGSRC=\ statistics.cpp -TESTSRC=\ - test-webserver.cpp \ - googlemock/src/gmock-all.cpp \ - googletest/src/gtest-all.cpp \ - $(PROGSRC) - SRC=$(PROGSRC) all: $(PROJECTNAME).so -# testsuite ---------------------------------------------- -test-$(PROJECTNAME): $(TESTSRC:.cpp=.o) - $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@ - $(PROJECTNAME).so: $(SRC:.cpp=.o) $(CXX) $(CXXFLAGS) $^ -shared $(LIBS) -o $@ -dep: $(TESTSRC:.cpp=.d) - %.d: %.cpp - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -MM -MP -MF $@ -c $< + $(CXX) $(CXXFLAGS) -MM -MP -MF $@ -c $< %.o: %.cpp %.d - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ - -googletest/src/%.o: googletest/src/%.cc - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ - -# dependencies - -ADD_DEP=Makefile + $(CXX) $(CXXFLAGS) -c $< -o $@ install: mkdir -p $(DESTDIR)/usr/lib/webserver/plugins @@ -109,7 +88,7 @@ $(DISTROS): deb-src debs: $(DISTROS) clean: - -rm -f test-$(PROJECTNAME) $(PROJECTNAME) + -rm -f $(PROJECTNAME) -find . -name '*.o' -o -name '*.so' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm -f zip: clean diff --git a/plugins/webbox/Makefile b/plugins/webbox/Makefile index 34f253b..861b5d4 100644 --- a/plugins/webbox/Makefile +++ b/plugins/webbox/Makefile @@ -28,8 +28,6 @@ else CXXFLAGS+=-std=c++17 endif -CXXTESTFLAGS=-Igoogletest/include -Igooglemock/include/ -Igoogletest -Igooglemock - LIBS=\ -lcommon \ -lboost_context \ @@ -62,37 +60,18 @@ LDFLAGS+=-L../../libcommon PROGSRC=\ webbox.cpp -TESTSRC=\ - test-webserver.cpp \ - googlemock/src/gmock-all.cpp \ - googletest/src/gtest-all.cpp \ - $(PROGSRC) - SRC=$(PROGSRC) all: $(PROJECTNAME).so -# testsuite ---------------------------------------------- -test-$(PROJECTNAME): $(TESTSRC:.cpp=.o) - $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@ - $(PROJECTNAME).so: ../../libcommon/libcommon.a $(SRC:.cpp=.o) $(CXX) $(LDFLAGS) $^ -shared $(LDLIBS) $(LIBS) -o $@ -dep: $(TESTSRC:.cpp=.d) - %.d: %.cpp - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -MM -MP -MF $@ -c $< + $(CXX) $(CXXFLAGS) -MM -MP -MF $@ -c $< %.o: %.cpp %.d - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ - -googletest/src/%.o: googletest/src/%.cc - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ - -# dependencies - -ADD_DEP=Makefile + $(CXX) $(CXXFLAGS) -c $< -o $@ install: mkdir -p $(DESTDIR)/usr/lib/webserver/plugins @@ -120,7 +99,7 @@ $(DISTROS): deb-src debs: $(DISTROS) clean: - -rm -f test-$(PROJECTNAME) $(PROJECTNAME) + -rm -f $(PROJECTNAME) -find . -name '*.o' -o -name '*.so' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm -f zip: clean diff --git a/plugins/weblog/Makefile b/plugins/weblog/Makefile index 466ddbd..a21b464 100644 --- a/plugins/weblog/Makefile +++ b/plugins/weblog/Makefile @@ -28,8 +28,6 @@ else CXXFLAGS+=-std=c++17 endif -CXXTESTFLAGS=-Igoogletest/include -Igooglemock/include/ -Igoogletest -Igooglemock - LIBS=\ -lcommon \ -lboost_context \ @@ -62,33 +60,21 @@ LDFLAGS=-L../../libcommon PROGSRC=\ weblog.cpp -TESTSRC=\ - test-webserver.cpp \ - googlemock/src/gmock-all.cpp \ - googletest/src/gtest-all.cpp \ - $(PROGSRC) - SRC=$(PROGSRC) all: $(PROJECTNAME).so -# testsuite ---------------------------------------------- -test-$(PROJECTNAME): $(TESTSRC:.cpp=.o) - $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@ - $(PROJECTNAME).so: ../../libcommon/libcommon.a $(SRC:.cpp=.o) $(CXX) $(LDFLAGS) $^ -shared $(LDLIBS) $(LIBS) -o $@ -dep: $(TESTSRC:.cpp=.d) - %.d: %.cpp - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -MM -MP -MF $@ -c $< + $(CXX) $(CXXFLAGS) -MM -MP -MF $@ -c $< %.o: %.cpp %.d - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ + $(CXX) $(CXXFLAGS) -c $< -o $@ googletest/src/%.o: googletest/src/%.cc - $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ + $(CXX) $(CXXFLAGS) -c $< -o $@ # dependencies diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..2bccae4 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,112 @@ +DISTROS=debian10 ubuntu1910 ubuntu2004 +PROJECTNAME=test-webserver + +CXX=clang++-10 + +ifeq ($(shell which $(CXX)),) +CXX=clang++ +endif + +ifeq ($(shell which $(CXX)),) +CXX=g++-9 +endif + +ifeq ($(shell which $(CXX)),) +CXX=g++ +endif + +ifeq ($(CXXFLAGS),) +#CXXFLAGS=-O2 -DNDEBUG +CXXFLAGS=-O0 -g -D_DEBUG +endif +# -fprofile-instr-generate -fcoverage-mapping +# gcc:--coverage + +CXXFLAGS+= -Wall -I. -fPIE + +CXXFLAGS+= -pthread +ifeq ($(CXX),clang++-10) +CXXFLAGS+=-std=c++20 #-stdlib=libc++ +else +CXXFLAGS+=-std=c++17 +endif + +CXXTESTFLAGS=-I../googletest/include -I../googlemock/include/ -I../googletest -I../googlemock + +LIBS=\ +-lcommon \ +-lboost_context \ +-lboost_filesystem \ +-lboost_timer \ +-lboost_system \ +-lcrypt \ +-lpthread \ +-lssl -lcrypto \ +-ldl + +#-lboost_coroutine \ +#-lboost_program_options \ +#-lboost_thread \ +#-lboost_regex \ + +ifeq ($(CXX),clang++-10) +LIBS+= \ +-fuse-ld=lld-10 \ +-lstdc++ +#-lc++ \ +#-lc++abi +#-lc++fs +#-lstdc++fs +else +LIBS+= \ +-lstdc++ \ +-lstdc++fs +endif + +LDFLAGS+=-pie -L../libcommon + +TESTSRC=\ + test-webserver.cpp \ + ../googlemock/src/gmock-all.cpp \ + ../googletest/src/gtest-all.cpp \ + $(PROGSRC) + +build: $(PROJECTNAME) + +set -e ; for i in $(PLUGINS) ; do make -C plugins/$$i ; done + ./$(PROJECTNAME) + +all: build + ./webserver -c webserver.conf + +$(PROJECTNAME): ../libcommon/libcommon.a $(TESTSRC:.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 $@ + +install: + mkdir -p $(DESTDIR)/usr/bin + cp webserver $(DESTDIR)/usr/bin + + mkdir -p $(DESTDIR)/usr/lib/webserver/plugins + set -e ; for i in $(PLUGINS) ; do make -C plugins/$$i install ; done + + mkdir -p $(DESTDIR)/usr/local/lib/webserver/plugins + + #mkdir -p $(DESTDIR)/etc + #cp webserver.conf $(DESTDIR)/etc/webserver.conf + +# misc --------------------------------------------------- + +clean: + -rm -f $(PROJECTNAME) + -find . -name '*.o' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm -f + +.PHONY: clean all install all $(DISTROS) + +-include $(wildcard $(TESTSRC:.cpp=.d)) diff --git a/test-webserver.cpp b/tests/test-webserver.cpp index f7020af..f7020af 100644 --- a/test-webserver.cpp +++ b/tests/test-webserver.cpp |