2019-07-19 12:01:41 -05: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.
|
2020-08-31 10:52:59 +09:30
|
|
|
|
|
|
|
# We don't run these at all unless mako is installed.
|
|
|
|
ifeq ($(HAVE_PYTHON3_MAKO),1)
|
2019-07-19 12:01:41 -05:00
|
|
|
check-units: check-tools
|
|
|
|
|
2019-07-23 15:53:44 -05:00
|
|
|
TOOL_TEST_INCL_SRC := tools/test/enum.c
|
2020-10-22 10:21:08 +10:30
|
|
|
TOOL_GEN_SRC := tools/test/test_gen.c tools/test/print_gen.c
|
2019-08-16 10:46:47 +09:30
|
|
|
TOOL_GEN_OBJS := $(TOOL_GEN_SRC:.c=.o)
|
2020-10-22 10:21:08 +10:30
|
|
|
TOOL_GEN_HEADER := tools/test/test_gen.h tools/test/print_gen.h
|
2020-10-22 11:27:07 +10:30
|
|
|
TOOL_TEST_SRC := $(wildcard tools/test/run-*.c)
|
|
|
|
TOOL_TEST_OBJS := $(TOOL_TEST_SRC:.c=.o)
|
|
|
|
TOOL_TEST_PROGRAMS := $(TOOL_TEST_OBJS:.o=)
|
2019-07-19 12:01:41 -05:00
|
|
|
|
2020-09-09 12:13:18 +09:30
|
|
|
# Get dependencies correct
|
|
|
|
ALL_C_SOURCES += $(TOOL_GEN_SRC) $(TOOL_TEST_SRC)
|
|
|
|
ALL_C_HEADERS += $(TOOL_GEN_HEADER)
|
|
|
|
|
2019-07-19 12:01:41 -05:00
|
|
|
TOOL_TEST_COMMON_OBJS := \
|
2023-05-05 15:10:53 -04:00
|
|
|
common/utils.o \
|
|
|
|
wire/fromwire.o \
|
|
|
|
wire/towire.o
|
2019-07-19 12:01:41 -05:00
|
|
|
|
|
|
|
TOOLS_WIRE_DEPS := $(BOLT_DEPS) tools/test/test_cases $(wildcard tools/gen/*_template)
|
|
|
|
|
2023-07-06 17:06:50 +09:30
|
|
|
tools/test/enum.o: ccan/config.h
|
2019-08-16 10:46:47 +09:30
|
|
|
$(TOOL_TEST_OBJS) $(TOOL_GEN_OBJS): $(TOOL_GEN_HEADER)
|
2022-09-08 10:26:31 +09:30
|
|
|
$(TOOL_TEST_PROGRAMS): $(TOOL_TEST_COMMON_OBJS) $(TOOL_GEN_OBJS) tools/test/enum.o
|
2019-07-19 12:01:41 -05:00
|
|
|
|
2020-10-22 10:21:08 +10:30
|
|
|
tools/test/test_gen.h: $(TOOLS_WIRE_DEPS) tools/test/Makefile
|
2019-07-23 18:54:21 -05:00
|
|
|
$(BOLT_GEN) --page header $@ test_type < tools/test/test_cases > $@
|
2019-07-19 12:01:41 -05:00
|
|
|
|
2022-09-08 10:26:31 +09:30
|
|
|
tools/test/test_gen.c: $(TOOLS_WIRE_DEPS) tools/test/Makefile
|
2020-10-22 10:21:08 +10:30
|
|
|
$(BOLT_GEN) --page impl tools/test/test_gen.h test_type < tools/test/test_cases > $@
|
2019-07-19 12:01:41 -05:00
|
|
|
|
2023-05-22 10:21:44 +09:30
|
|
|
tools/test/print_gen.h: wire/onion_wiregen.h $(TOOLS_WIRE_DEPS)
|
2019-07-23 18:54:21 -05:00
|
|
|
$(BOLT_GEN) -P --page header $@ test_type < tools/test/test_cases > $@
|
2019-07-20 22:04:59 -05:00
|
|
|
|
2020-10-22 10:21:08 +10:30
|
|
|
tools/test/print_gen.c: $(TOOLS_WIRE_DEPS)
|
|
|
|
echo '#include "test_gen.h"' > $@
|
2019-07-23 18:54:21 -05:00
|
|
|
$(BOLT_GEN) -P --page impl ${@:.c=.h} test_type < tools/test/test_cases >> $@
|
2019-07-20 22:04:59 -05:00
|
|
|
|
2019-07-19 12:01:41 -05:00
|
|
|
ALL_TEST_PROGRAMS += $(TOOL_TEST_PROGRAMS)
|
|
|
|
|
|
|
|
check-tools: $(TOOL_TEST_PROGRAMS:%=unittest/%)
|
2020-08-31 10:52:59 +09:30
|
|
|
endif # HAVE_PYTHON3_MAKO
|
2019-07-19 12:01:41 -05:00
|
|
|
|
|
|
|
clean: tools-test-clean
|
|
|
|
|
|
|
|
tools-test-clean:
|
2019-08-16 10:46:47 +09:30
|
|
|
$(RM) $(TOOL_GEN_HEADER) $(TOOL_GEN_SRC) $(TOOL_TEST_OBJS) $(TOOL_TEST_PROGRAMS)
|
|
|
|
$(RM) $(TOOL_GEN_SRC:.c=.o) tools/test/enum.o
|