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