asn1: Make templating less fragile: test it more
`lib/asn1/check-gen.c` almost works with templates, and is a pretty extensive test. The only thing that fails is everything to do with IMPLICIT tags (so, `test_implicit()`). So now we compile `lib/asn1/test.asn1` both, w/ and w/o templating, and we build two programs from `lib/asn1/check-gen.c`: `check-gen` and `check-gen-template`, respectively linking with the non-templated and the templated compilation of `lib/asn1/test.asn1`. Because the template compiler still doesn't support IMPLICIT tagging well, we disable testing of IMPLICIT tags in `check-gen-template`. This will make it much harder to break the template compiler in the future.
This commit is contained in:
@@ -63,7 +63,7 @@ noinst_PROGRAMS = asn1_gen
|
||||
|
||||
libexec_heimdal_PROGRAMS = asn1_compile asn1_print
|
||||
|
||||
TESTS = check-der check-gen check-timegm check-ber check-template
|
||||
TESTS = check-der check-gen check-gen-template check-timegm check-ber check-template
|
||||
check_PROGRAMS = $(TESTS)
|
||||
|
||||
asn1_gen_SOURCES = asn1_gen.c
|
||||
@@ -73,6 +73,9 @@ check_der_SOURCES = check-der.c check-common.c check-common.h
|
||||
check_template_SOURCES = check-template.c check-common.c check-common.h
|
||||
nodist_check_template_SOURCES = $(gen_files_test_template:.x=.c)
|
||||
|
||||
dist_check_gen_template_SOURCES = check-gen.c check-common.c check-common.h
|
||||
nodist_check_gen_template_SOURCES = $(gen_files_test_template:.x=.c)
|
||||
|
||||
dist_check_gen_SOURCES = check-gen.c check-common.c check-common.h
|
||||
nodist_check_gen_SOURCES = $(gen_files_test:.x=.c)
|
||||
|
||||
@@ -138,6 +141,11 @@ asn1_print_LDADD = libasn1.la $(LIB_roken) $(LIB_com_err)
|
||||
asn1_gen_LDADD = $(check_der_LDADD)
|
||||
check_timegm_LDADD = $(check_der_LDADD)
|
||||
|
||||
check_gen_template_LDADD = \
|
||||
libasn1.la \
|
||||
$(LIB_roken)
|
||||
|
||||
check_gen_CFLAGS = -DIMPLICIT_TAGGING_WORKS
|
||||
check_gen_LDADD = \
|
||||
libasn1.la \
|
||||
$(LIB_roken)
|
||||
|
@@ -1016,6 +1016,7 @@ test_choice (void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef IMPLICIT_TAGGING_WORKS
|
||||
static int
|
||||
cmp_TESTImplicit (void *a, void *b)
|
||||
{
|
||||
@@ -1104,6 +1105,7 @@ test_implicit (void)
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
cmp_TESTAlloc (void *a, void *b)
|
||||
@@ -1881,7 +1883,9 @@ main(int argc, char **argv)
|
||||
DO_ONE(test_large_tag);
|
||||
DO_ONE(test_choice);
|
||||
|
||||
#ifdef IMPLICIT_TAGGING_WORKS
|
||||
DO_ONE(test_implicit);
|
||||
#endif
|
||||
|
||||
DO_ONE(test_taglessalloc);
|
||||
DO_ONE(test_optional);
|
||||
|
@@ -35,6 +35,14 @@
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
static FILE *
|
||||
get_code_file(void)
|
||||
{
|
||||
if (!one_code_file && templatefile)
|
||||
return templatefile;
|
||||
return codefile;
|
||||
}
|
||||
|
||||
void
|
||||
generate_type_seq (const Symbol *s)
|
||||
{
|
||||
@@ -72,12 +80,12 @@ generate_type_seq (const Symbol *s)
|
||||
s->gen_name, s->gen_name, subname,
|
||||
s->gen_name, s->gen_name);
|
||||
|
||||
fprintf (codefile, "int ASN1CALL\n"
|
||||
fprintf (get_code_file(), "int ASN1CALL\n"
|
||||
"add_%s(%s *data, const %s *element)\n"
|
||||
"{\n",
|
||||
s->gen_name, s->gen_name, subname);
|
||||
|
||||
fprintf (codefile,
|
||||
fprintf (get_code_file(),
|
||||
"int ret;\n"
|
||||
"void *ptr;\n"
|
||||
"\n"
|
||||
@@ -91,14 +99,14 @@ generate_type_seq (const Symbol *s)
|
||||
"return 0;\n",
|
||||
subname);
|
||||
|
||||
fprintf (codefile, "}\n\n");
|
||||
fprintf (get_code_file(), "}\n\n");
|
||||
|
||||
fprintf (codefile, "int ASN1CALL\n"
|
||||
fprintf (get_code_file(), "int ASN1CALL\n"
|
||||
"remove_%s(%s *data, unsigned int element)\n"
|
||||
"{\n",
|
||||
s->gen_name, s->gen_name);
|
||||
|
||||
fprintf (codefile,
|
||||
fprintf (get_code_file(),
|
||||
"void *ptr;\n"
|
||||
"\n"
|
||||
"if (data->len == 0 || element >= data->len)\n"
|
||||
@@ -115,5 +123,5 @@ generate_type_seq (const Symbol *s)
|
||||
"return 0;\n",
|
||||
subname);
|
||||
|
||||
fprintf (codefile, "}\n\n");
|
||||
fprintf (get_code_file(), "}\n\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user