Browse Source
Add a test for checking that the bolt-gens do the right thing for a fairly exhaustive test case set (and that it compiles). Note that this doesn't check that we've got the memory assignment pieces worked out. It's got a kind of exotic reliance on the update-mocks in that in order to depend on as little of the wire/ code as possible (we only import wire/wire.h), we include an AUTOGENERATE comment in the test_cases CSV file, and then run update-mocks as part of the build for that file.pull/2938/head
lisa neigut
6 years ago
committed by
Rusty Russell
5 changed files with 132 additions and 0 deletions
@ -0,0 +1,2 @@ |
|||||
|
#! /usr/bin/make
|
||||
|
include tools/test/Makefile |
@ -0,0 +1,40 @@ |
|||||
|
#! /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 |
||||
|
|
||||
|
TOOL_GEN_SRC := tools/test/gen_test.c |
||||
|
TOOL_GEN_HEADER := tools/test/gen_test.h |
||||
|
TOOL_TEST_SRC := $(wildcard tools/test/run-*.c) |
||||
|
TOOL_TEST_OBJS := $(TOOL_TEST_SRC:.c=.o) |
||||
|
TOOL_TEST_PROGRAMS := $(TOOL_TEST_OBJS:.o=) |
||||
|
|
||||
|
TOOL_TEST_COMMON_OBJS := \
|
||||
|
common/utils.o |
||||
|
|
||||
|
TOOLS_WIRE_DEPS := $(BOLT_DEPS) tools/test/test_cases $(wildcard tools/gen/*_template) |
||||
|
|
||||
|
$(TOOL_TEST_SRC): $(TOOL_GEN_HEADER) |
||||
|
$(TOOL_TEST_OBJS): $(TOOL_GEN_SRC) |
||||
|
$(TOOL_TEST_PROGRAMS): $(TOOL_TEST_COMMON_OBJS) |
||||
|
$(TOOL_GEN_SRC) $(TOOL_GEN_HEADER): $(TOOLS_WIRE_DEPS) |
||||
|
|
||||
|
tools/test/gen_test.h: |
||||
|
tools/generate-bolts.py --page header $@ test_type < tools/test/test_cases > $@ |
||||
|
|
||||
|
tools/test/gen_test.c: |
||||
|
tools/generate-bolts.py --page impl ${@:.c=.h} test_type < tools/test/test_cases > $@ |
||||
|
@tools/update-mocks.sh "$@" |
||||
|
|
||||
|
ALL_TEST_PROGRAMS += $(TOOL_TEST_PROGRAMS) |
||||
|
|
||||
|
check-tools: $(TOOL_TEST_PROGRAMS:%=unittest/%) |
||||
|
|
||||
|
clean: tools-test-clean |
||||
|
|
||||
|
tools-test-clean: |
||||
|
$(RM) $(TOOL_GEN_FILES) $(TOOL_TEST_OBJS) |
@ -0,0 +1,12 @@ |
|||||
|
#include "gen_test.c" |
||||
|
|
||||
|
#include <assert.h> |
||||
|
#include <stdio.h> |
||||
|
|
||||
|
#include <common/utils.h> |
||||
|
|
||||
|
int main(void) |
||||
|
{ |
||||
|
setup_locale(); |
||||
|
|
||||
|
} |
@ -0,0 +1,77 @@ |
|||||
|
#include <ccan/short_types/short_types.h> |
||||
|
# TODO: add enums! |
||||
|
# TODO: msgs expansions |
||||
|
# AUTOGENERATED MOCKS START |
||||
|
# AUTOGENERATED MOCKS END |
||||
|
|
||||
|
# omnibus method |
||||
|
msgtype,test_msg,16 |
||||
|
# test array u8 (helper) |
||||
|
msgdata,test_msg,test_arr_u8,u8,10 |
||||
|
# test array assignable |
||||
|
msgdata,test_msg,test_arr_assignable,u16,5 |
||||
|
# test var len u8 (helper) |
||||
|
msgdata,test_msg,len_var_u8,u16, |
||||
|
msgdata,test_msg,test_var_len_u8_arr,byte,len_var_u8 |
||||
|
# test variable length assignable |
||||
|
msgdata,test_msg,len_var_ass,u16, |
||||
|
msgdata,test_msg,test_var_len_ass_arr,u32,len_var_ass |
||||
|
# test array struct |
||||
|
msgdata,test_msg,test_struct_arr,test_short_id,10 |
||||
|
# test var-len struct |
||||
|
msgdata,test_msg,len_test_struct_varlen,u16, |
||||
|
msgdata,test_msg,test_struct_varlen,test_short_id,len_test_struct_varlen |
||||
|
# test var-len var-size struct |
||||
|
msgdata,test_msg,len_varsize_struct,u16, |
||||
|
msgdata,test_msg,test_varsize_struct_varlen,test_features,len_varsize_struct |
||||
|
# assignable |
||||
|
msgdata,test_msg,test_assignable,u16, |
||||
|
# test struct |
||||
|
msgdata,test_msg,test_struct,test_short_id, |
||||
|
# test var-size struct |
||||
|
msgdata,test_msg,test_varsize_struct,test_features, |
||||
|
# test optional struct |
||||
|
msgdata,test_msg,test_optional_struct,?test_short_id, |
||||
|
# test optional var-size struct |
||||
|
msgdata,test_msg,test_optional_varsize_struct,?test_features, |
||||
|
msgdata,test_msg,test_sbt_struct_nested,subtype_nested, |
||||
|
msgdata,test_msg,test_sbt_varsize_struct,subtype_varsize_struct, |
||||
|
msgdata,test_msg,test_sbt_varsize_var_assign,subtype_var_assign, |
||||
|
msgdata,test_msg,test_sbt_var_len,subtype_var_len, |
||||
|
msgdata,test_msg,test_sbt_varlen_varsize,subtype_varlen_varsize, |
||||
|
|
||||
|
# A subtype with a nested subtype |
||||
|
subtype,subtype_nested |
||||
|
subtypedata,subtype_nested,field_1,test_short_id, |
||||
|
|
||||
|
# subtype with a nested varsize size struct |
||||
|
subtype,subtype_varsize_struct |
||||
|
subtypedata,subtype_varsize_struct,field_0,test_features, |
||||
|
|
||||
|
# A subtype to test varsize things of |
||||
|
# - A two level subtype comment |
||||
|
subtype,subtype_var_assign |
||||
|
# variable length set of assignables |
||||
|
subtypedata,subtype_var_assign,len_1,u8, |
||||
|
subtypedata,subtype_var_assign,field_1,u16,len_1 |
||||
|
|
||||
|
# variable length set of structs |
||||
|
subtype,subtype_var_len |
||||
|
subtypedata,subtype_var_len,len_2,u8, |
||||
|
subtypedata,subtype_var_len,field_2,test_short_id,len_2 |
||||
|
|
||||
|
subtype,subtype_varlen_varsize |
||||
|
# variable length set of variable size structs |
||||
|
subtypedata,subtype_varlen_varsize,len,u8, |
||||
|
subtypedata,subtype_varlen_varsize,field_1,test_features,len |
||||
|
|
||||
|
# normal struct |
||||
|
subtype,test_short_id |
||||
|
subtypedata,test_short_id,u64,u64, |
||||
|
|
||||
|
# var-sized struct |
||||
|
subtype,test_features |
||||
|
subtypedata,test_features,len_lf,u16, |
||||
|
subtypedata,test_features,localfeatures,u8,len_lf |
||||
|
subtypedata,test_features,len_gf,u16, |
||||
|
subtypedata,test_features,globalfeatures,u8,len_gf |
Loading…
Reference in new issue