1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

tests: fix valgrind warnings

This commit is contained in:
Steffen Vogel 2017-07-02 23:53:48 +02:00
parent fe2abf760d
commit 2b913d4d69
16 changed files with 66 additions and 42 deletions

View file

@ -29,9 +29,17 @@
.state = STATE_INITIALIZED \
}
#define LIST_INIT_STATIC(l) \
__attribute__((constructor(105))) static void UNIQUE(__ctor)() {\
list_init(l); \
} \
__attribute__((destructor(105))) static void UNIQUE(__dtor)() { \
list_destroy(l, NULL, false); \
}
#define list_length(list) ((list)->length)
#define list_at_safe(list, index) ((list)->length > index ? (list)->array[index] : NULL)
#define list_at(list, index) ((list)->array[index])
#define list_at(list, index) ((list)->array[index])
#define list_first(list) list_at(list, 0)
#define list_last(list) list_at(list, (list)->length-1)

View file

@ -33,10 +33,10 @@
#include "nodes/cbuilder.h"
#define REGISTER_PLUGIN(p) \
__attribute__((constructor)) static void UNIQUE(__ctor)() { \
__attribute__((constructor(110))) static void UNIQUE(__ctor)() {\
list_push(&plugins, p); \
} \
__attribute__((destructor)) static void UNIQUE(__dtor)() { \
__attribute__((destructor(110))) static void UNIQUE(__dtor)() { \
list_remove(&plugins, p); \
}

View file

@ -124,9 +124,9 @@ static struct plugin p = {
.start = cbuilder_start,
.stop = cbuilder_stop,
.read = cbuilder_read,
.write = cbuilder_write,
.instances = LIST_INIT()
.write = cbuilder_write
}
};
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)

View file

@ -397,9 +397,9 @@ static struct plugin p = {
.start = file_start,
.stop = file_stop,
.read = file_read,
.write = file_write,
.instances = LIST_INIT()
.write = file_write
}
};
REGISTER_PLUGIN(&p)
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)

View file

@ -285,9 +285,10 @@ static struct plugin p = {
.read = fpga_read,
.write = fpga_write,
.init = fpga_init,
.deinit = fpga_deinit,
.instances = LIST_INIT()
.deinit = fpga_deinit
}
};
REGISTER_PLUGIN(&p)
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)

View file

@ -243,9 +243,9 @@ static struct plugin p = {
.stop = nanomsg_stop,
.deinit = nanomsg_deinit,
.read = nanomsg_read,
.write = nanomsg_write,
.instances = LIST_INIT()
.write = nanomsg_write
}
};
REGISTER_PLUGIN(&p)
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)

View file

@ -595,9 +595,10 @@ static struct plugin p = {
.read = ngsi_read,
.write = ngsi_write,
.init = ngsi_init,
.deinit = ngsi_deinit,
.instances = LIST_INIT()
.deinit = ngsi_deinit
}
};
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)

View file

@ -306,9 +306,9 @@ static struct plugin p = {
.read = opal_read,
.write = opal_write,
.init = opal_init,
.deinit = opal_deinit,
.instances = LIST_INIT()
.deinit = opal_deinit
}
};
REGISTER_PLUGIN(&p)
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)

View file

@ -194,9 +194,9 @@ static struct plugin p = {
.start = shmem_open,
.stop = shmem_close,
.read = shmem_read,
.write = shmem_write,
.instances = LIST_INIT(),
.write = shmem_write
}
};
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)

View file

@ -850,9 +850,9 @@ static struct plugin p = {
.read = socket_read,
.write = socket_write,
.init = socket_init,
.deinit = socket_deinit,
.instances = LIST_INIT()
.deinit = socket_deinit
}
};
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)

View file

@ -600,9 +600,9 @@ static struct plugin p = {
.read = websocket_read,
.write = websocket_write,
.print = websocket_print,
.parse = websocket_parse,
.instances = LIST_INIT()
.parse = websocket_parse
}
};
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)

View file

@ -484,9 +484,9 @@ static struct plugin p = {
.init = zeromq_init,
.deinit = zeromq_deinit,
.read = zeromq_read,
.write = zeromq_write,
.instances = LIST_INIT()
.write = zeromq_write
}
};
REGISTER_PLUGIN(&p)
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)

View file

@ -25,12 +25,9 @@
#include "plugin.h"
/** Global list of all known plugins */
struct list plugins = LIST_INIT();
struct list plugins;
__attribute__((destructor(999))) static void __dtor_plugins()
{
list_destroy(&plugins, NULL, false);
}
LIST_INIT_STATIC(&plugins)
int plugin_init(struct plugin *p)
{

View file

@ -73,13 +73,8 @@ static void quit(int signal, siginfo_t *sinfo, void *ctx)
pool_destroy(&sendd.pool);
}
node_stop(node);
node_destroy(node);
if (node->_vt->start == websocket_start) {
web_stop(&sn.web);
api_stop(&sn.api);
}
super_node_stop(&sn);
super_node_destroy(&sn);
info(GRN("Goodbye!"));
exit(EXIT_SUCCESS);

View file

@ -27,8 +27,10 @@ tests: unit-tests integration-tests
run-tests: run-unit-tests run-integration-tests run-valgrind
VALGRIND = valgrind --leak-check=full --show-leak-kinds=all --suppressions=$(SRCDIR)/tests/valgrind.supp
run-valgrind: src
valgrind --leak-check=full --show-leak-kinds=all --suppressions=$(SRCDIR)/tests/valgrind.supp $(BUILDDIR)/villas-node & sleep 2; kill $$!; sleep 1; kill $$!
valgrind --leak-check=full --show-leak-kinds=all --suppressions=$(SRCDIR)/tests/valgrind.supp $(BUILDDIR)/villas-pipe $(SRCDIR)/etc/websocket-loopback.conf ws1 & sleep 2; kill $$!; sleep 1; kill $$!
$(VALGRIND) $(BUILDDIR)/villas-node & sleep 1; kill %1
$(VALGRIND) $(BUILDDIR)/villas-pipe -t 1 $(SRCDIR)/etc/websocket-loopback.conf ws1
.PHONY: tests run-tests run-valgrind

View file

@ -5,4 +5,24 @@
...
fun:SSL_library_init
...
}
{
libcurl-libnspr4
Memcheck:Leak
match-leak-kinds: reachable
...
obj:*/libnspr4.so*
...
obj:*/libcurl.so*
...
}
{
libcurl-crypto
Memcheck:Leak
match-leak-kinds: reachable
...
obj:*/libcrypto.so*
...
obj:*/libcurl.so*
...
}