mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-05 22:24:25 +01:00
tests: use common_setup/common_shutdown to avoid leaks.
It also does more checks (like taken() checks). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -16,6 +16,7 @@ CLI_TEST_COMMON_OBJS := \
|
||||
common/pseudorand.o \
|
||||
common/memleak.o \
|
||||
common/msg_queue.o \
|
||||
common/setup.o \
|
||||
common/utils.o \
|
||||
common/type_to_string.o \
|
||||
common/permute_tx.o
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <common/channel_id.h>
|
||||
#include <common/json_stream.h>
|
||||
#include <common/node_id.h>
|
||||
#include <common/setup.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
@@ -162,7 +163,7 @@ ssize_t test_read(int fd UNUSED, void *buf, size_t len)
|
||||
|
||||
int main(int argc UNUSED, char *argv[])
|
||||
{
|
||||
setup_locale();
|
||||
common_setup(argv[0]);
|
||||
|
||||
char *fake_argv[] = { argv[0], "--lightning-dir=/tmp/", "-H", "listconfigs", "-N", "none", NULL };
|
||||
|
||||
@@ -170,7 +171,7 @@ int main(int argc UNUSED, char *argv[])
|
||||
max_read_return = -1;
|
||||
assert(test_main(6, fake_argv) == 0);
|
||||
assert(!taken_any());
|
||||
take_cleanup();
|
||||
common_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <common/channel_id.h>
|
||||
#include <common/json_stream.h>
|
||||
#include <common/node_id.h>
|
||||
#include <common/setup.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
@@ -171,7 +172,7 @@ ssize_t test_read(int fd UNUSED, void *buf, size_t len)
|
||||
|
||||
int main(int argc UNUSED, char *argv[])
|
||||
{
|
||||
setup_locale();
|
||||
common_setup(argv[0]);
|
||||
|
||||
char *fake_argv[] = { argv[0], "--lightning-dir=/tmp/", "test", "-N", "none", NULL };
|
||||
|
||||
@@ -200,7 +201,6 @@ int main(int argc UNUSED, char *argv[])
|
||||
max_read_return = -1;
|
||||
assert(test_main(5, fake_argv) == 0);
|
||||
tal_free(response);
|
||||
assert(!taken_any());
|
||||
take_cleanup();
|
||||
common_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <common/channel_id.h>
|
||||
#include <common/json_stream.h>
|
||||
#include <common/node_id.h>
|
||||
#include <common/setup.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -168,7 +169,7 @@ int test_chdir(const char *path)
|
||||
|
||||
int main(int argc UNUSED, char *argv[])
|
||||
{
|
||||
setup_locale();
|
||||
common_setup(argv[0]);
|
||||
|
||||
char *fake_argv[] = { argv[0], "--lightning-dir=/tmp/", "test", "-N", "none", NULL };
|
||||
|
||||
@@ -190,6 +191,6 @@ int main(int argc UNUSED, char *argv[])
|
||||
"num_connected=1\n"));
|
||||
tal_free(output);
|
||||
assert(!taken_any());
|
||||
take_cleanup();
|
||||
common_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user