wallet: move tests into test/ dir like other unit tests.

Trivial move, but makes it easy to add new ones.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-12-12 14:12:37 +10:30 committed by Christian Decker
parent 757d45c8a3
commit 2931760b5b
6 changed files with 36 additions and 28 deletions

View File

@ -4,8 +4,6 @@
wallet-wrongdir:
$(MAKE) -C .. lightningd-all
check: wallet/tests
WALLET_LIB_SRC := \
wallet/db.c \
wallet/wallet.c \
@ -14,30 +12,11 @@ WALLET_LIB_SRC := \
WALLET_LIB_OBJS := $(WALLET_LIB_SRC:.c=.o)
WALLET_LIB_HEADERS := $(WALLET_LIB_SRC:.c=.h)
WALLET_TEST_COMMON_OBJS := \
common/htlc_state.o \
common/type_to_string.o \
common/pseudorand.o \
common/utils.o \
lightningd/htlc_end.o \
lightningd/log.o
WALLET_TEST_SRC := $(wildcard wallet/*_tests.c)
WALLET_TEST_OBJS := $(WALLET_TEST_SRC:.c=.o)
WALLET_TEST_PROGRAMS := $(WALLET_TEST_OBJS:.o=)
# Make sure these depend on everything.
ALL_TEST_PROGRAMS += $(WALLET_TEST_PROGRAMS)
ALL_OBJS += $(WALLET_LIB_OBJS) $(WALLET_TEST_OBJS)
$(WALLET_TEST_PROGRAMS): $(BITCOIN_OBJS) $(WALLET_TEST_COMMON_OBJS)
$(WALLET_TEST_OBJS): $(WALLET_LIB_HEADERS)
wallet/tests: $(WALLET_TEST_PROGRAMS:%=unittest/%)
check-whitespace: $(WALLET_LIB_SRC:%=check-whitespace/%) $(WALLET_LIB_HEADERS:%=check-whitespace/%)
clean: wallet-clean
wallet-clean:
$(RM) $(WALLET_LIB_OBJS)
include wallet/test/Makefile

2
wallet/test/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
run-db
run-wallet

27
wallet/test/Makefile Normal file
View File

@ -0,0 +1,27 @@
WALLET_TEST_SRC := $(wildcard wallet/test/run-*.c)
WALLET_TEST_OBJS := $(WALLET_TEST_SRC:.c=.o)
WALLET_TEST_PROGRAMS := $(WALLET_TEST_OBJS:.o=)
WALLET_TEST_COMMON_OBJS := \
common/htlc_state.o \
common/type_to_string.o \
common/pseudorand.o \
common/utils.o \
lightningd/htlc_end.o \
lightningd/log.o
# Make sure these depend on everything.
ALL_TEST_PROGRAMS += $(WALLET_TEST_PROGRAMS)
ALL_OBJS += $(WALLET_LIB_OBJS) $(WALLET_TEST_OBJS)
$(WALLET_TEST_PROGRAMS): $(BITCOIN_OBJS) $(WALLET_TEST_COMMON_OBJS)
$(WALLET_TEST_OBJS): $(WALLET_LIB_HEADERS)
wallet/tests: $(WALLET_TEST_PROGRAMS:%=unittest/%)
$(WALLET_TEST_PROGRAMS): $(WALLET_TEST_COMMON_OBJS) $(BITCOIN_OBJS)
$(WALLET_TEST_OBJS): $(WALLET_SRC)
update-mocks: $(WALLET_TEST_SRC:%=update-mocks/%)
check: $(WALLET_TEST_PROGRAMS:%=unittest/%)

View File

@ -3,9 +3,9 @@
static void db_fatal(const char *fmt, ...);
#define fatal db_fatal
#include "db.c"
#include "wallet/db.c"
#include "wallet/test_utils.h"
#include "test_utils.h"
#include <stdio.h>
#include <unistd.h>

View File

@ -2,17 +2,17 @@
static void wallet_fatal(const char *fmt, ...);
#define fatal wallet_fatal
#include "test_utils.h"
#include "wallet.c"
#include "wallet/wallet.c"
#include "db.c"
#include "wallet/db.c"
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <stdarg.h>
#include <stdio.h>
#include <unistd.h>
#include <wallet/test_utils.h>
static char *wallet_err;
static void wallet_fatal(const char *fmt, ...)