1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
# $Source: /cvsroot/flexml/flexml/testbed/Makefile,v $
# regression testbed Makefile
#####################################################
# Fixed definitions -- do not modify for new tests
#####################################################
include ../Makefile.defs
MAKEUTILS_DIR = .
# If UNIT_TESTS is test_foo
# and test_foo_out is bar baz
# Then the created files (that need to be deleted by 'make clean'
# will be
# test_foo foo.std{err,out} foo.std{err,out}.diff bar baz bar.diff baz.diff
TEST_INTERMEDIATES = \
$(UNIT_TESTS) \
$(UNIT_TESTS:test_%=%.stdout) $(UNIT_TESTS:test_%=%.stdout.diff) \
$(UNIT_TESTS:test_%=.test_%.stdout.expected) \
$(UNIT_TESTS:test_%=%.stderr) $(UNIT_TESTS:test_%=%.stderr.diff) \
$(UNIT_TESTS:test_%=.test_%.stderr.expected) \
$(foreach var,$(UNIT_TESTS:%=%_out),$(foreach o,$($(var)),$o $(o).diff))
# Compares test.out.std[out,err] with expected values
COMPARE_OUT = $(MAKEUTILS_DIR)/CompareOut.pl
#CC = /usr/bin/gcc-3.3 -Wall
#CFLAGS = -O2 -g
#FLEXDEBUG = -d
FLEXML = ../flexml -s ../skel -T../flexml-act
.PHONY : test
.PHONY : clean
#####################################################
# test definitions -- add new tests here
#####################################################
EXES = \
biparser \
init_header \
missing-att \
multiple-att \
mixed-enumatt \
mixed-enumatt2 \
mixed-stratt \
mixed-stratt-def \
mixed1 \
multi-parser-run
INTERMEDIATES = $(EXES) $(EXES:%=%.c) $(EXES:%=%.l)
# leave this alphabetically sorted for easy scanning
UNIT_TESTS = \
test_biparser \
test_init_header \
test_missing-att \
test_multiple-att \
test_mixed-enumatt \
test_mixed-enumatt2 \
test_mixed-stratt \
test_mixed-stratt-def \
test_mixed1 \
test_multi-parser-run
test : $(UNIT_TESTS)
# Test init_header
test_init_header_cmd = ./init_header < init_header.in
test_init_header_deps = init_header init_header.in
# Test missing REQUIRED attribute
test_missing-att_cmd = ./missing-att < missing-att.in
test_missing-att_deps = missing-att missing-att.in
# Test multiply defined attribute
test_multiple-att_cmd = ./multiple-att < multiple-att.in
test_multiple-att_deps = multiple-att multiple-att.in
# Test mixed1
test_mixed1_cmd = ./mixed1 < mixed1.in
test_mixed1_deps = mixed1 mixed1.in
# Test mixed-enumatt (mixed content + enumerated attribute)
test_mixed-enumatt_cmd = ./mixed-enumatt < mixed-enumatt.in
test_mixed-enumatt_deps = mixed-enumatt mixed-enumatt.in
# Test mixed-enumatt2 (mixed content + enumerated attribute, eval'ed in end tag)
test_mixed-enumatt2_cmd = ./mixed-enumatt2 < mixed-enumatt2.in
test_mixed-enumatt2_deps = mixed-enumatt2 mixed-enumatt2.in
# Test mixed-stratt (mixed content + string attribute)
test_mixed-stratt_cmd = ./mixed-stratt < mixed-stratt.in
test_mixed-stratt_deps = mixed-stratt mixed-stratt.in
# Test mixed-stratt (mixed content + default string attribute)
test_mixed-stratt-def_cmd = ./mixed-stratt-def < mixed-stratt-def.in
test_mixed-stratt-def_deps = mixed-stratt-def mixed-stratt-def.in
# Test multi-parser-run (Run the parser several times on "different" files)
test_multi-parser-run_cmd = ./multi-parser-run multi-parser-run.in
test_multi-parser-run_deps = multi-parser-run multi-parser-run.in
# Test biparser (Have two parsers in the same code)
test_biparser_cmd = ./biparser biparser-one.in biparser-two.in
test_biparser_deps = biparser biparser-one.in biparser-two.in
biparser: biparser-one.dtd biparser-two.dtd biparser.precious.c
for n in one two ; do \
$(FLEXML) -P$$n -H biparser-$$n.h -L biparser-$$n.dtd; \
$(FLEXML) -P$$n -S biparser-$$n.l -L biparser-$$n.dtd; \
$(FLEX) -s -L -P$${n}_ -obiparser-$$n.c biparser-$$n.l; \
done
$(CC) $(CFLAGS) -o biparser \
biparser-one.c biparser-two.c \
biparser.precious.c
CLEANFILES+= biparser-one.h biparser-one.l biparser-one.c \
biparser-two.h biparser-two.l biparser-two.c
init_header : init_header.act init_header.dtd init_header.h
$(FLEXML) -b 1000 -A -i$@.h -a$@.act $@.dtd
$(FLEX) -s -L -o$@.c $@.l
$(CC) $(CFLAGS) -o $@ $@.c
% : %.dtd %.act
$(FLEXML) -b 1000 -A -a$@.act $@.dtd
$(FLEX) -s -L -o$@.c $@.l
$(CC) $(CFLAGS) -o $@ $@.c
##############################################################
# test build rules -- add override build rules here if needed
##############################################################
#mixed1: mixed1.dtd mixed1.act
# $(FLEXML) -b 500 -A -amixed1.act mixed1.dtd
# $(FLEX) -s -L -o mixed1.c mixed1.l > mixed1.c
# $(CC) $(CFLAGS) -o $@ mixed1.c
#####################################################
# test infrastructure -- do not modify for new tests
#####################################################
clean :
rm -f $(TEST_INTERMEDIATES) $(INTERMEDIATES) $(CLEANFILES)
# When we are building test_foo, the variable $(TEST_BASE) is "foo"
test_% : TEST_BASE = $(@:test_%=%)
ifndef distribute_deps
# This will take a target and dependency list, and evaluate each dependency
# individually. This only needs to be used on dependency lists that are to
# be in an $(eval ...) function. This is a work-around for a bug in GNU Make
# 3.80, which fails when $(eval)'ing dependency lists longer than about 160
# characters.
# 1. target
# 2. dependency list
define distribute_deps
$(foreach dep,$(2),$(eval $(1) : $(dep)))
endef
endif
define unit_test_deps_t
$(1) : .$(1).stdout.expected
$(1) : .$(1).stderr.expected
$$(call distribute_deps,$(1),$($(1)_deps))
endef
$(foreach test,$(UNIT_TESTS),$(eval $(call unit_test_deps_t,$(test))))
# To build .test_foo.std{err,out}.expected --
# If foo.std{err,out}.expected exists, symlink to it
# Else, .test_foo.std{err,out}.expected is a new empty file
# These rules are invoked from rules in the Extradeps section.
# They must be two separate rules (else 'make test' not idempotent
# -- see bug #105)
.test_%.stderr.expected:
@if [ -f $(@:.test_%=%) ]; \
then $(SYMLINK) $(@:.test_%=%) $@; \
else touch $@; \
fi
.test_%.stdout.expected:
@if [ -f $(@:.test_%=%) ]; \
then $(SYMLINK) $(@:.test_%=%) $@; \
else touch $@; \
fi
# Unit test rule. Expects:
# UNIT_TESTS = test_foo test_bar (test_ prefix is necessary)
# test_foo_cmd = command to run
# test_foo_deps = dependencies (i.e. inputs to the test, and the executable)
# test_foo_out = files and directories created by running the command
# with corresponding .expected files for comparison
$(UNIT_TESTS) :
@$(test_$(@:test_%=%)_cmd) > $(@:test_%=%).stdout \
2>$(@:test_%=%).stderr || true
@$(PERL) $(COMPARE_OUT) -p '$($(@)_diff_prog)' -- \
$($(@)_diff_opts) $(@:test_%=%) $($(@)_out) | tee $@
|