1# This file is part of flex. 2 3# Redistribution and use in source and binary forms, with or without 4# modification, are permitted provided that the following conditions 5# are met: 6 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. 12 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. 16 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 20# PURPOSE. 21 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# ------------------------------------------------ 30 31FLEX = $(top_builddir)/flex 32 33testname := test-table-opts 34allopts := -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem 35 36# the test names themselves 37opttests := $(foreach opt,$(allopts), test-opt-nr$(opt) test-opt-r$(opt)) 38sertests := $(foreach opt,$(allopts), test-ser-nr$(opt) test-ser-r$(opt)) 39vertests := $(foreach opt,$(allopts), test-ver-nr$(opt) test-ver-r$(opt)) 40alltests := $(opttests) $(vertests) $(sertests) test-mul 41 42# the executables to build 43optexe := $(addsuffix $(EXEEXT),$(opttests)) 44verexe := $(addsuffix $(EXEEXT),$(vertests)) 45serexe := $(addsuffix $(EXEEXT),$(sertests)) 46allexe := $(optexe) $(verexe) $(serexe) 47 48# the .c files 49optsrc := $(addsuffix .c,$(opttests)) 50versrc := $(addsuffix .c,$(vertests)) 51sersrc := $(addsuffix .c,$(sertests)) 52allsrc := $(optsrc) $(versrc) $(sersrc) 53 54# the .o files 55optobj := $(addsuffix .o,$(opttests)) 56verobj := $(addsuffix .o,$(vertests)) 57serobj := $(addsuffix .o,$(sertests)) 58allobj := $(optobj) $(verobj) $(serobj) 59 60# the .tables files 61sertables := $(addsuffix .tables,$(sertests)) 62alltables := $(addsuffix .tables,$(alltests)) 63 64EXTRA_DIST = scanner.l test.input 65CLEANFILES = scanner.c OUTPUT $(allobj) $(allsrc) $(alltables) \ 66 all-ser.tables $(allexe) 67AM_CPPFLAGS = -I$(srcdir) -I$(top_srcdir) -I$(top_builddir) 68 69test: test-opt test-ser test-ver test-mul 70 71test-opt-r%.c: $(srcdir)/scanner.l 72 $(FLEX) -L -P $(subst -,_,$(basename $(@F))) --reentrant $* -o $@ $< 73 74test-opt-nr%.c: $(srcdir)/scanner.l 75 $(FLEX) -L -P $(subst -,_,$(basename $(@F))) $* -o $@ $< 76 77test-ser-r%.c: $(srcdir)/scanner.l 78 $(FLEX) -L -P $(subst -,_,$(basename $(@F))) -R --tables-file="test-ser-r$*.tables" $* -o $@ $< 79 80test-ser-nr%.c: $(srcdir)/scanner.l 81 $(FLEX) -L -P $(subst -,_,$(basename $(@F))) --tables-file="test-ser-nr$*.tables" $* -o $@ $< 82 83test-ver-r%.c: $(srcdir)/scanner.l 84 $(FLEX) -L -P $(subst -,_,$(basename $(@F))) -R --tables-file="test-ver-r$*.tables" --tables-verify $* -o $@ $< 85 86test-ver-nr%.c: $(srcdir)/scanner.l 87 $(FLEX) -L -P $(subst -,_,$(basename $(@F))) --tables-file="test-ver-nr$*.tables" --tables-verify $* -o $@ $< 88 89test-opt%$(EXEEXT): test-opt%.o 90 $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $< $(LOADLIBES) 91 92test-ser%$(EXEEXT): test-ser%.o 93 $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $< $(LOADLIBES) 94 95test-ver%$(EXEEXT): test-ver%.o 96 $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $< $(LOADLIBES) 97 98test-opt: $(optexe) 99 for t in $(optexe) ; do \ 100 ./$$t `basename $$t $(EXEEXT)`.tables < $(srcdir)/test.input \ 101 || { echo $t FAILED ; exit 1 ; } ; \ 102 done 103 104test-ver: $(verexe) 105 for t in $(verexe) ; do \ 106 ./$$t `basename $$t $(EXEEXT)`.tables < $(srcdir)/test.input \ 107 || { echo $t FAILED ; exit 1 ; } ; \ 108 done 109 110test-ser: $(serexe) 111 for t in $(serexe) ; do \ 112 ./$$t `basename $$t $(EXEEXT)`.tables < $(srcdir)/test.input \ 113 || { echo $t FAILED ; exit 1 ; } ; \ 114 done 115 116test-mul: $(serexe) 117 $(RM) all-ser.tables 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; } ; \ 121 done 122 123test-opt-nr-%.o: test-opt-nr-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) $(CFLAGS) $< 124test-ser-nr-%.o: test-ser-nr-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_HAS_TABLES_EXTERNAL $(CFLAGS) $< 125test-ver-nr-%.o: test-ver-nr-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_HAS_TABLES_EXTERNAL $(CFLAGS) $< 126 127test-opt-r-%.o: test-opt-r-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_IS_REENTRANT $(CFLAGS) $< 128test-ser-r-%.o: test-ser-r-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT $(CFLAGS) $< 129test-ver-r-%.o: test-ver-r-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT $(CFLAGS) $< 130 131.PHONY: test test-opt test-ser test-ver test-mul 132.SECONDARY: $(allobj) $(allsrc) 133