mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
test: make generic driver for unit tests.
Not just in daemon. This fixes 'make check' when it tries to run 'make wire-tests' Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ca9fb0376a
commit
1f447688bc
12
Makefile
12
Makefile
@ -14,6 +14,11 @@ BOLTVERSION := master
|
||||
# If you don't have (working) valgrind.
|
||||
#NO_VALGRIND := 1
|
||||
|
||||
ifneq ($(NO_VALGRIND),1)
|
||||
VALGRIND=valgrind -q --error-exitcode=7
|
||||
VALGRIND_TEST_ARGS = --track-origins=yes --leak-check=full --show-reachable=yes
|
||||
endif
|
||||
|
||||
# This is where we add new features as bitcoin adds them.
|
||||
FEATURES :=
|
||||
|
||||
@ -192,14 +197,14 @@ $(CCAN_OBJS) $(CDUMP_OBJS) $(HELPER_OBJS) $(BITCOIN_OBJS) $(TEST_PROGRAMS:=.o) c
|
||||
$(HELPER_OBJS) $(CORE_OBJS) $(BITCOIN_OBJS) $(TEST_PROGRAMS:=.o): $(BITCOIN_HEADERS) $(CORE_HEADERS) $(CCAN_HEADERS) $(GEN_HEADERS)
|
||||
|
||||
test-protocol: test/test_protocol
|
||||
set -e; TMP=`mktemp`; [ -n "$(NO_VALGRIND)" ] || PREFIX="valgrind -q --error-exitcode=7"; for f in test/commits/*.script; do if ! $$PREFIX test/test_protocol < $$f > $$TMP; then echo "test/test_protocol < $$f FAILED" >&2; exit 1; fi; diff -u $$TMP $$f.expected; done; rm $$TMP
|
||||
set -e; TMP=`mktemp`; for f in test/commits/*.script; do if ! $(VALGRIND) test/test_protocol < $$f > $$TMP; then echo "test/test_protocol < $$f FAILED" >&2; exit 1; fi; diff -u $$TMP $$f.expected; done; rm $$TMP
|
||||
|
||||
doc/protocol-%.svg: test/test_protocol
|
||||
test/test_protocol --svg < test/commits/$*.script > $@
|
||||
|
||||
protocol-diagrams: $(patsubst %.script, doc/protocol-%.svg, $(notdir $(wildcard test/commits/*.script)))
|
||||
|
||||
check: test-protocol bitcoin-tests
|
||||
check: test-protocol
|
||||
|
||||
include bitcoin/Makefile
|
||||
include wire/Makefile
|
||||
@ -329,6 +334,9 @@ clean: daemon-clean wire-clean
|
||||
|
||||
include daemon/Makefile
|
||||
|
||||
unittest/%: %
|
||||
$(VALGRIND) $(VALGRIND_TEST_ARGS) $*
|
||||
|
||||
ccan-tal.o: $(CCANDIR)/ccan/tal/tal.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
ccan-tal-str.o: $(CCANDIR)/ccan/tal/str/str.c
|
||||
|
@ -11,8 +11,6 @@ $(BITCOIN_TEST_PROGRAMS): $(CCAN_OBJS)
|
||||
|
||||
$(BITCOIN_TEST_OBJS): $(CCAN_HEADERS) $(BITCOIN_HEADERS) $(BITCOIN_SRC)
|
||||
|
||||
VALGRIND=valgrind -q --error-exitcode=99
|
||||
VALGRIND_TEST_ARGS = --track-origins=yes --leak-check=full --show-reachable=yes
|
||||
check: bitcoin-tests
|
||||
|
||||
bitcoin-tests: $(BITCOIN_TEST_PROGRAMS)
|
||||
set -e; for f in $(BITCOIN_TEST_PROGRAMS); do $(VALGRIND) $(VALGRIND_TEST_ARGS) $$f; done
|
||||
bitcoin-tests: $(BITCOIN_TEST_PROGRAMS:%=unittest/%)
|
||||
|
@ -82,11 +82,7 @@ $(DAEMON_TEST_PROGRAMS): $(CCAN_OBJS) $(BITCOIN_OBJS) libsecp256k1.a utils.o
|
||||
|
||||
$(DAEMON_TEST_OBJS): $(DAEMON_HEADERS) $(DAEMON_JSMN_HEADERS) $(BITCOIN_HEADERS) $(CORE_HEADERS) $(GEN_HEADERS) $(DAEMON_GEN_HEADERS) $(CCAN_HEADERS)
|
||||
|
||||
VALGRIND=valgrind -q --error-exitcode=99
|
||||
VALGRIND_TEST_ARGS = --track-origins=yes --leak-check=full --show-reachable=yes
|
||||
|
||||
daemon-unit-tests: $(DAEMON_TEST_PROGRAMS)
|
||||
set -e; for f in $(DAEMON_TEST_PROGRAMS); do $(VALGRIND) $(VALGRIND_TEST_ARGS) $$f; done
|
||||
daemon-unit-tests: $(DAEMON_TEST_PROGRAMS:%=unittest/%)
|
||||
|
||||
daemon-tests: daemon-unit-tests daemon-all-test
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user