coverage gen

master
Tony Olagbaiye 3 years ago
parent 5011ae9fa2
commit 43f3a3ffe4
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

3
.gitignore vendored

@ -5,6 +5,9 @@ compile_commands.json
cscope* cscope*
.depend .depend
*.d *.d
*.gcno
*.gcda
*.json.gz
# Object files # Object files
*.o *.o

@ -21,7 +21,9 @@
#include "omemo.hh" #include "omemo.hh"
#include "pgp.hh" #include "pgp.hh"
#include "util.hh" #include "util.hh"
extern "C" {
#include "diff/diff.h" #include "diff/diff.h"
}
void connection__init() void connection__init()
{ {

@ -73,8 +73,10 @@ SRCS=plugin.cpp \
xmpp/iq.cpp \ xmpp/iq.cpp \
DEPS=deps/diff/libdiff.a \ DEPS=deps/diff/libdiff.a \
deps/fmt/libfmt.a \
OBJS=$(patsubst %.cpp,.%.o,$(patsubst %.c,.%.o,$(patsubst xmpp/%.cpp,xmpp/.%.o,$(patsubst xmpp/%.c,xmpp/.%.o,$(SRCS))))) OBJS=$(patsubst %.cpp,.%.o,$(patsubst %.c,.%.o,$(patsubst xmpp/%.cpp,xmpp/.%.o,$(SRCS))))
COVS=$(patsubst %.cpp,.%.cov.o,$(patsubst xmpp/%.cpp,xmpp/.%.cov.o,$(SRCS)))
all: all:
make depend make depend
@ -83,34 +85,50 @@ all:
weechat-xmpp: $(DEPS) xmpp.so weechat-xmpp: $(DEPS) xmpp.so
xmpp.so: $(OBJS) $(DEPS) $(HDRS) xmpp.so: $(OBJS) $(DEPS) $(HDRS)
$(CXX) $(LDFLAGS) -o .$@ $(OBJS) $(DEPS) $(LDLIBS) $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(DEPS) $(LDLIBS)
which patchelf >/dev/null && \ which patchelf >/dev/null && \
patchelf --set-rpath $(LIBRARY_PATH):$(shell realpath $(shell dirname $(shell gcc --print-libgcc-file-name))/../../../) xmpp.so && \ patchelf --set-rpath $(LIBRARY_PATH):$(shell realpath $(shell dirname $(shell gcc --print-libgcc-file-name))/../../../) xmpp.so && \
patchelf --shrink-rpath xmpp.so || true patchelf --shrink-rpath xmpp.so || true
.%.o: %.c .%.o: %.c
@$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
.%.o: %.cpp .%.o: %.cpp
@$(CXX) $(CPPFLAGS) -c $< -o $@ $(CXX) $(CPPFLAGS) -c $< -o $@
.%.cov.o: %.cpp
@$(CXX) --coverage -O0 $(CPPFLAGS) -c $< -o $@
xmpp/.%.o: xmpp/%.cpp xmpp/.%.o: xmpp/%.cpp
@$(CXX) $(CPPFLAGS) -c $< -o $@ $(CXX) $(CPPFLAGS) -c $< -o $@
xmpp/.%.cov.o: xmpp/%.cpp
@$(CXX) --coverage -O0 $(CPPFLAGS) -c $< -o $@
deps/diff/libdiff.a: deps/diff/libdiff.a:
git submodule update --init --recursive git submodule update --init --recursive
cd deps/diff && env -u MAKEFLAGS ./configure cd deps/diff && env -u MAKEFLAGS ./configure
$(MAKE) -C deps/diff CFLAGS=-fPIC $(MAKE) -C deps/diff CFLAGS=-fPIC
diff: deps/diff/libdiff.a diff: deps/diff/libdiff.a
deps/fmt/libfmt.a:
tests/run: xmpp.so tests/main.cpp git submodule update --init --recursive
$(CXX) $(CPPFLAGS) -o tests/run xmpp.so tests/main.cpp $(LDLIBS) env -u MAKEFLAGS cmake -S deps/fmt -B deps/fmt \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
$(MAKE) -C deps/fmt fmt
fmt: deps/fmt/libfmt.a
tests/run: $(COVS) $(DEPS) $(HDRS) tests/main.cc
$(CXX) --coverage -O0 $(LDFLAGS) -o tests/xmpp.cov.so $(COVS) $(DEPS) $(LDLIBS)
env --chdir tests $(CXX) $(CPPFLAGS) -o run xmpp.cov.so main.cc $(LDLIBS)
which patchelf >/dev/null && \ which patchelf >/dev/null && \
patchelf --set-rpath $(PWD):$(LIBRARY_PATH):$(shell realpath $(shell dirname $(shell gcc --print-libgcc-file-name))/../../../) tests/run && \ patchelf --set-rpath $(PWD)/tests:$(LIBRARY_PATH):$(shell realpath $(shell dirname $(shell gcc --print-libgcc-file-name))/../../../) tests/xmpp.cov.so tests/run && \
patchelf --shrink-rpath tests/run || true patchelf --shrink-rpath tests/run tests/xmpp.cov.so || true
test: tests/run test: tests/run
tests/run env --chdir tests ./run
coverage: tests/run
gcov -m -abcfu -rqk -i .*.gcda xmpp/.*.gcda
debug: xmpp.so debug: xmpp.so
env LD_PRELOAD=$(DEBUG) gdb -ex "handle SIGPIPE nostop noprint pass" --args \ env LD_PRELOAD=$(DEBUG) gdb -ex "handle SIGPIPE nostop noprint pass" --args \
@ -132,10 +150,13 @@ depend: $(SRCS) $(HDRS)
tidy: tidy:
$(FIND) . -name "*.o" -delete $(FIND) . -name "*.o" -delete
$(FIND) . -name "*.gcno" -delete
$(FIND) . -name "*.gcda" -delete
clean: clean:
$(RM) -f $(OBJS) $(RM) -f $(OBJS)
$(MAKE) -C deps/diff clean || true $(MAKE) -C deps/diff clean || true
$(MAKE) -C deps/fmt clean || true
git submodule foreach --recursive git clean -xfd || true git submodule foreach --recursive git clean -xfd || true
git submodule foreach --recursive git reset --hard || true git submodule foreach --recursive git reset --hard || true

@ -11,7 +11,6 @@
#include "plugin.hh" #include "plugin.hh"
#include "config.hh" #include "config.hh"
extern "C" {
#include "account.hh" #include "account.hh"
#include "connection.hh" #include "connection.hh"
#include "command.hh" #include "command.hh"
@ -19,6 +18,7 @@ extern "C" {
#include "buffer.hh" #include "buffer.hh"
#include "completion.hh" #include "completion.hh"
extern "C" {
WEECHAT_PLUGIN_NAME(WEECHAT_XMPP_PLUGIN_NAME); WEECHAT_PLUGIN_NAME(WEECHAT_XMPP_PLUGIN_NAME);
WEECHAT_PLUGIN_DESCRIPTION(N_("XMPP client protocol")); WEECHAT_PLUGIN_DESCRIPTION(N_("XMPP client protocol"));
WEECHAT_PLUGIN_AUTHOR("bqv <weechat@fron.io>"); WEECHAT_PLUGIN_AUTHOR("bqv <weechat@fron.io>");

@ -5,6 +5,8 @@
#include <cstdlib> #include <cstdlib>
#include <strophe.h> #include <strophe.h>
#include "stanza.hh"
xmpp_stanza_t *stanza__presence(xmpp_ctx_t *context, xmpp_stanza_t *base, xmpp_stanza_t *stanza__presence(xmpp_ctx_t *context, xmpp_stanza_t *base,
xmpp_stanza_t **children, char *ns, xmpp_stanza_t **children, char *ns,
char *from, char *to, char *type) char *from, char *to, char *type)

@ -70,8 +70,8 @@ static inline void stanza__set_text(xmpp_ctx_t *context, xmpp_stanza_t *parent,
} }
xmpp_stanza_t *stanza__presence(xmpp_ctx_t *context, xmpp_stanza_t *base, xmpp_stanza_t *stanza__presence(xmpp_ctx_t *context, xmpp_stanza_t *base,
xmpp_stanza_t **children, const char *ns, xmpp_stanza_t **children, char *ns,
char *from, char *to, const char *type); char *from, char *to, char *type);
xmpp_stanza_t *stanza__iq(xmpp_ctx_t *context, xmpp_stanza_t *base, xmpp_stanza_t *stanza__iq(xmpp_ctx_t *context, xmpp_stanza_t *base,
xmpp_stanza_t **children, char *ns, char *id, xmpp_stanza_t **children, char *ns, char *id,

Loading…
Cancel
Save