Add coverage to makefile

pull/216/head
Michael 5 years ago
parent c655600704
commit 77c662abdd
No known key found for this signature in database
GPG Key ID: 2D51757B47E2434C

3
.gitignore vendored

@ -47,4 +47,5 @@ rapidjson/
.idea .idea
.vscode .vscode
build64/ build64/
build2/ build2/
default.profraw

@ -61,7 +61,8 @@ CROSS ?= OFF
# build liblokinet-shared.so # build liblokinet-shared.so
SHARED_LIB ?= ON SHARED_LIB ?= ON
# enable generating coverage # enable generating coverage
COVERAGE =? OFF COVERAGE ?= OFF
COVERAGE_OUTDIR ?= "$(TMPDIR)/lokinet-coverage"
# cmake generator type # cmake generator type
CMAKE_GEN ?= Unix Makefiles CMAKE_GEN ?= Unix Makefiles
@ -69,10 +70,12 @@ BUILD_ROOT = $(REPO)/build
SCAN_BUILD ?= scan-build SCAN_BUILD ?= scan-build
CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DUSING_CLANG=$(CLANG) -DSTATIC_LINK=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DUSE_LIBABYSS=$(JSONRPC) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DWITH_COVERAGE=$(COVERAGE) '$(REPO)'") CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DUSING_CLANG=$(CLANG) -DSTATIC_LINK=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DUSE_LIBABYSS=$(JSONRPC) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) '$(REPO)'")
ANALYZE_CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "$(SCAN_BUILD) cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DUSING_CLANG=$(CLANG) -DSTATIC_LINK=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DUSE_LIBABYSS=$(JSONRPC) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) '$(REPO)'") ANALYZE_CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "$(SCAN_BUILD) cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DUSING_CLANG=$(CLANG) -DSTATIC_LINK=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DUSE_LIBABYSS=$(JSONRPC) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) '$(REPO)'")
COVERAGE_CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DUSING_CLANG=$(CLANG) -DSTATIC_LINK=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DUSE_LIBABYSS=$(JSONRPC) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DWITH_COVERAGE=yes '$(REPO)'")
TARGETS = $(REPO)/lokinet TARGETS = $(REPO)/lokinet
SIGS = $(TARGETS:=.sig) SIGS = $(TARGETS:=.sig)
EXE = $(BUILD_ROOT)/lokinet EXE = $(BUILD_ROOT)/lokinet
@ -194,6 +197,21 @@ analyze-config: clean
analyze: analyze-config analyze: analyze-config
cd '$(BUILD_ROOT)' && $(SCAN_BUILD) $(MAKE) cd '$(BUILD_ROOT)' && $(SCAN_BUILD) $(MAKE)
coverage-config: clean
mkdir -p '$(BUILD_ROOT)'
$(COVERAGE_CONFIG_CMD)
coverage: coverage-config
$(MAKE) -C $(BUILD_ROOT) -j 12
$(TEST_EXE) || true # continue even if tests fail
mkdir -p "$(COVERAGE_OUTDIR)"
ifeq ($(CLANG),OFF)
gcovr -r . --branches --html --html-details -o "$(COVERAGE_OUTDIR)/lokinet.html"
else
llvm-profdata merge default.profraw -output $(BUILD_ROOT)/profdata
llvm-cov show -format=html -output-dir="$(COVERAGE_OUTDIR)" -instr-profile "$(BUILD_ROOT)/profdata" "$(BUILD_ROOT)/testAll" $(shell find ./llarp -type f)
endif
lint: $(LINT_CHECK) lint: $(LINT_CHECK)
%.cpp-check: %.cpp %.cpp-check: %.cpp

@ -21,7 +21,7 @@
namespace llarp namespace llarp
{ {
int inline int
tcp_conn::read(byte_t* buf, size_t sz) tcp_conn::read(byte_t* buf, size_t sz)
{ {
if(sz == 0) if(sz == 0)
@ -53,14 +53,14 @@ namespace llarp
return 0; return 0;
} }
void inline void
tcp_conn::flush_write() tcp_conn::flush_write()
{ {
connected(); connected();
ev_io::flush_write(); ev_io::flush_write();
} }
ssize_t inline ssize_t
tcp_conn::do_write(void* buf, size_t sz) tcp_conn::do_write(void* buf, size_t sz)
{ {
if(_shouldClose) if(_shouldClose)
@ -74,7 +74,7 @@ namespace llarp
#endif #endif
} }
void inline void
tcp_conn::connect() tcp_conn::connect()
{ {
socklen_t slen = sizeof(sockaddr_in); socklen_t slen = sizeof(sockaddr_in);
@ -100,7 +100,7 @@ namespace llarp
} }
} }
int inline int
tcp_serv::read(byte_t*, size_t) tcp_serv::read(byte_t*, size_t)
{ {
int new_fd = ::accept(fd, nullptr, nullptr); int new_fd = ::accept(fd, nullptr, nullptr);

@ -16,6 +16,7 @@ Build requirements:
* CMake * CMake
* C++ 17 capable C++ compiler * C++ 17 capable C++ compiler
* rapidjson (if enabling jsonrpc server) * rapidjson (if enabling jsonrpc server)
* gcovr (if generating test coverage with gcc)
### Linux ### Linux
@ -27,22 +28,22 @@ build:
$ make -j8 $ make -j8
install: install:
$ sudo make install $ sudo make install
### FreeBSD ### FreeBSD
build: build:
$ pkg install wget cmake git $ pkg install wget cmake git
$ git clone https://github.com/loki-project/loki-network $ git clone https://github.com/loki-project/loki-network
$ cd loki-network $ cd loki-network
$ gmake -j8 $ gmake -j8
install (root): install (root):
# gmake install # gmake install
## Windows ## Windows
@ -55,10 +56,10 @@ build (where `$ARCH` is your platform - `i686` or `x86_64`):
$ cmake .. -DCMAKE_BUILD_TYPE=[Debug|Release] -DSTATIC_LINK=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DDNS_PORT=53 -G 'Unix Makefiles' $ cmake .. -DCMAKE_BUILD_TYPE=[Debug|Release] -DSTATIC_LINK=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DDNS_PORT=53 -G 'Unix Makefiles'
install (elevated) to `$PROGRAMFILES/lokinet` or `$ProgramFiles(x86)/lokinet`: install (elevated) to `$PROGRAMFILES/lokinet` or `$ProgramFiles(x86)/lokinet`:
$ make install $ make install
if cross-compiling, install mingw-w64 from your distro's package manager, or [build from source](https://sourceforge.net/p/mingw-w64/wiki2/Cross%20Win32%20and%20Win64%20compiler/), then: if cross-compiling, install mingw-w64 from your distro's package manager, or [build from source](https://sourceforge.net/p/mingw-w64/wiki2/Cross%20Win32%20and%20Win64%20compiler/), then:
$ mkdir -p build; cd build $ mkdir -p build; cd build
$ export COMPILER=clang # if using clang for windows $ export COMPILER=clang # if using clang for windows

Loading…
Cancel
Save