2019-07-19 19:01:41 +02:00
|
|
|
#! /usr/bin/make
|
|
|
|
#
|
|
|
|
# Rudimentary tests for the wire parsers, using a set of test
|
|
|
|
# definitions. (Covers more of the test definitions)
|
|
|
|
#
|
|
|
|
# We generate the files, and then we attempt to compile
|
|
|
|
# and run a test case.
|
|
|
|
check-units: check-tools
|
|
|
|
|
2019-07-23 22:53:44 +02:00
|
|
|
TOOL_TEST_INCL_SRC := tools/test/enum.c
|
2019-07-21 05:04:59 +02:00
|
|
|
TOOL_GEN_SRC := tools/test/gen_test.c tools/test/gen_print.c
|
2019-08-16 03:16:47 +02:00
|
|
|
TOOL_GEN_OBJS := $(TOOL_GEN_SRC:.c=.o)
|
2019-07-21 05:04:59 +02:00
|
|
|
TOOL_GEN_HEADER := tools/test/gen_test.h tools/test/gen_print.h
|
2019-07-19 19:01:41 +02:00
|
|
|
TOOL_TEST_SRC := $(wildcard tools/test/run-*.c)
|
|
|
|
TOOL_TEST_OBJS := $(TOOL_TEST_SRC:.c=.o)
|
2019-08-21 05:00:25 +02:00
|
|
|
# Don't require update-mocks hack unless developer mode.
|
|
|
|
ifeq ($(DEVELOPER),1)
|
2019-07-19 19:01:41 +02:00
|
|
|
TOOL_TEST_PROGRAMS := $(TOOL_TEST_OBJS:.o=)
|
2019-08-21 05:00:25 +02:00
|
|
|
else
|
|
|
|
TOOL_TEST_PROGRAMS :=
|
|
|
|
endif
|
2019-07-19 19:01:41 +02:00
|
|
|
|
|
|
|
TOOL_TEST_COMMON_OBJS := \
|
2019-08-16 03:16:47 +02:00
|
|
|
common/utils.o
|
2019-07-19 19:01:41 +02:00
|
|
|
|
|
|
|
TOOLS_WIRE_DEPS := $(BOLT_DEPS) tools/test/test_cases $(wildcard tools/gen/*_template)
|
|
|
|
|
2019-08-16 03:16:47 +02:00
|
|
|
$(TOOL_TEST_OBJS) $(TOOL_GEN_OBJS): $(TOOL_GEN_HEADER)
|
|
|
|
$(TOOL_TEST_PROGRAMS): $(TOOL_TEST_COMMON_OBJS) $(TOOL_GEN_SRC:.c=.o) tools/test/enum.o
|
2019-07-19 19:01:41 +02:00
|
|
|
|
2020-05-16 03:29:05 +02:00
|
|
|
tools/test/gen_test.h: $(TOOLS_WIRE_DEPS) tools/test/Makefile
|
2019-07-24 01:54:21 +02:00
|
|
|
$(BOLT_GEN) --page header $@ test_type < tools/test/test_cases > $@
|
2019-07-19 19:01:41 +02:00
|
|
|
|
2019-08-21 02:53:36 +02:00
|
|
|
.INTERMEDIATE: tools/test/gen_test.c.tmp.c
|
2019-08-16 03:16:47 +02:00
|
|
|
# Parallel make sometimes tries to use file before update-mocks, so split.
|
|
|
|
tools/test/gen_test.c.tmp.c: $(TOOLS_WIRE_DEPS)
|
|
|
|
$(BOLT_GEN) --page impl tools/test/gen_test.h test_type < tools/test/test_cases > $@
|
2019-07-19 19:01:41 +02:00
|
|
|
|
2019-08-19 04:12:57 +02:00
|
|
|
tools/test/gen_test.c: tools/test/gen_test.c.tmp.c $(EXTERNAL_HEADERS) tools/test/gen_test.h
|
2020-05-29 22:48:55 +02:00
|
|
|
@MAKE=$(MAKE) tools/update-mocks.sh "$<" $(SUPPRESS_OUTPUT) && mv "$<" "$@"
|
2019-08-16 03:16:47 +02:00
|
|
|
|
2020-08-31 03:13:25 +02:00
|
|
|
tools/test/gen_print.h: wire/onion_wiregen.h $(TOOLS_WIRE_DEPS)
|
2019-07-24 01:54:21 +02:00
|
|
|
$(BOLT_GEN) -P --page header $@ test_type < tools/test/test_cases > $@
|
2019-07-21 05:04:59 +02:00
|
|
|
|
2019-08-16 03:16:47 +02:00
|
|
|
tools/test/gen_print.c: $(TOOLS_WIRE_DEPS)
|
2019-07-21 05:04:59 +02:00
|
|
|
echo '#include "gen_test.h"' > $@
|
2019-07-24 01:54:21 +02:00
|
|
|
$(BOLT_GEN) -P --page impl ${@:.c=.h} test_type < tools/test/test_cases >> $@
|
2019-07-21 05:04:59 +02:00
|
|
|
|
2019-07-19 19:01:41 +02:00
|
|
|
ALL_TEST_PROGRAMS += $(TOOL_TEST_PROGRAMS)
|
|
|
|
|
|
|
|
check-tools: $(TOOL_TEST_PROGRAMS:%=unittest/%)
|
|
|
|
|
2019-07-21 05:04:59 +02:00
|
|
|
update-mocks: tools-update-mocks
|
|
|
|
|
|
|
|
tools-update-mocks: $(TOOL_TEST_SRC:%=update-mocks/%)
|
|
|
|
|
2019-07-19 19:01:41 +02:00
|
|
|
clean: tools-test-clean
|
|
|
|
|
|
|
|
tools-test-clean:
|
2019-08-16 03:16:47 +02:00
|
|
|
$(RM) $(TOOL_GEN_HEADER) $(TOOL_GEN_SRC) $(TOOL_TEST_OBJS) $(TOOL_TEST_PROGRAMS)
|
|
|
|
$(RM) $(TOOL_GEN_SRC:.c=.o) tools/test/enum.o
|