1 # This file is part of flex.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions
7 # 1. Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # 2. Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
13 # Neither the name of the University nor the names of its contributors
14 # may be used to endorse or promote products derived from this software
15 # without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
18 # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
19 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 # ------------------------------------------------
23 # This test is really a set of tests, one for
24 # each compression flag. -Ca, -Cem, etc..
25 # 'test-opt' builds non-serialized scanners with various table options.
26 # 'test-ver' verifies that the serialized tables match the in-code tables.
27 # 'test-ser' deserializes the tables at runtime.
28 # 'test-mul' checks that we can store multiple tables in a single file.
29 # ------------------------------------------------
31 FLEX = $(top_builddir)/flex
33 testname := test-table-opts
34 allopts := -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem
36 # the test names themselves
37 opttests := $(foreach opt,$(allopts), test-opt-nr$(opt) test-opt-r$(opt))
38 sertests := $(foreach opt,$(allopts), test-ser-nr$(opt) test-ser-r$(opt))
39 vertests := $(foreach opt,$(allopts), test-ver-nr$(opt) test-ver-r$(opt))
40 alltests := $(opttests) $(vertests) $(sertests) test-mul
42 # the executables to build
43 optexe := $(addsuffix $(EXEEXT),$(opttests))
44 verexe := $(addsuffix $(EXEEXT),$(vertests))
45 serexe := $(addsuffix $(EXEEXT),$(sertests))
46 allexe := $(optexe) $(verexe) $(serexe)
49 optsrc := $(addsuffix .c,$(opttests))
50 versrc := $(addsuffix .c,$(vertests))
51 sersrc := $(addsuffix .c,$(sertests))
52 allsrc := $(optsrc) $(versrc) $(sersrc)
55 optobj := $(addsuffix .o,$(opttests))
56 verobj := $(addsuffix .o,$(vertests))
57 serobj := $(addsuffix .o,$(sertests))
58 allobj := $(optobj) $(verobj) $(serobj)
61 sertables := $(addsuffix .tables,$(sertests))
62 alltables := $(addsuffix .tables,$(alltests))
64 EXTRA_DIST = scanner.l test.input
65 CLEANFILES = scanner.c OUTPUT $(allobj) $(allsrc) $(alltables) \
66 all-ser.tables $(allexe)
67 AM_CPPFLAGS = -I$(srcdir) -I$(top_srcdir) -I$(top_builddir)
69 test: test-opt test-ser test-ver test-mul
71 test-opt-r%.c: $(srcdir)/scanner.l
72 $(FLEX) -L -P $(subst -,_,$(basename $(@F))) --reentrant $* -o $@ $<
74 test-opt-nr%.c: $(srcdir)/scanner.l
75 $(FLEX) -L -P $(subst -,_,$(basename $(@F))) $* -o $@ $<
77 test-ser-r%.c: $(srcdir)/scanner.l
78 $(FLEX) -L -P $(subst -,_,$(basename $(@F))) -R --tables-file="test-ser-r$*.tables" $* -o $@ $<
80 test-ser-nr%.c: $(srcdir)/scanner.l
81 $(FLEX) -L -P $(subst -,_,$(basename $(@F))) --tables-file="test-ser-nr$*.tables" $* -o $@ $<
83 test-ver-r%.c: $(srcdir)/scanner.l
84 $(FLEX) -L -P $(subst -,_,$(basename $(@F))) -R --tables-file="test-ver-r$*.tables" --tables-verify $* -o $@ $<
86 test-ver-nr%.c: $(srcdir)/scanner.l
87 $(FLEX) -L -P $(subst -,_,$(basename $(@F))) --tables-file="test-ver-nr$*.tables" --tables-verify $* -o $@ $<
89 test-opt%$(EXEEXT): test-opt%.o
90 $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $< $(LOADLIBES)
92 test-ser%$(EXEEXT): test-ser%.o
93 $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $< $(LOADLIBES)
95 test-ver%$(EXEEXT): test-ver%.o
96 $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $< $(LOADLIBES)
99 for t in $(optexe) ; do \
100 ./$$t `basename $$t $(EXEEXT)`.tables < $(srcdir)/test.input \
101 || { echo $t FAILED ; exit 1 ; } ; \
105 for t in $(verexe) ; do \
106 ./$$t `basename $$t $(EXEEXT)`.tables < $(srcdir)/test.input \
107 || { echo $t FAILED ; exit 1 ; } ; \
111 for t in $(serexe) ; do \
112 ./$$t `basename $$t $(EXEEXT)`.tables < $(srcdir)/test.input \
113 || { echo $t FAILED ; exit 1 ; } ; \
118 cat $(sertables) > all-ser.tables
119 for t in $(serexe) ; do \
120 ./$$t all-ser.tables < $(srcdir)/test.input || { echo $$t FAILED; exit 1; } ; \
123 test-opt-nr-%.o: test-opt-nr-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) $(CFLAGS) $<
124 test-ser-nr-%.o: test-ser-nr-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_HAS_TABLES_EXTERNAL $(CFLAGS) $<
125 test-ver-nr-%.o: test-ver-nr-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_HAS_TABLES_EXTERNAL $(CFLAGS) $<
127 test-opt-r-%.o: test-opt-r-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_IS_REENTRANT $(CFLAGS) $<
128 test-ser-r-%.o: test-ser-r-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT $(CFLAGS) $<
129 test-ver-r-%.o: test-ver-r-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT $(CFLAGS) $<
131 .PHONY: test test-opt test-ser test-ver test-mul
132 .SECONDARY: $(allobj) $(allsrc)