]> granicus.if.org Git - flex/commitdiff
Added test for multiple tables in one file.
authorJohn Millaway <john43@users.sourceforge.net>
Fri, 13 Sep 2002 07:12:40 +0000 (07:12 +0000)
committerJohn Millaway <john43@users.sourceforge.net>
Fri, 13 Sep 2002 07:12:40 +0000 (07:12 +0000)
flex.skl
tests/test-table-opts/Makefile.am
tests/test-table-opts/scanner.l

index f6eeacd4a10354049120de8640ffbfc42c9906a4..8a26f2cf4f40f02be485e089e23e8215c0399b6c 100644 (file)
--- a/flex.skl
+++ b/flex.skl
@@ -2406,11 +2406,11 @@ int yytbl_load YYFARGS2 (FILE *, fp, const char *, key)
     struct yytbl_reader rd;
 
     rd.fp = fp;
-    rd.bread = 0;
     th.th_version = NULL;
 
     /* Keep trying until we find the right set of tables or end of file. */
     while (!feof(rd.fp)) {
+        rd.bread = 0;
         if (yytbl_hdr_read (&th, &rd YY_CALL_LAST_ARG) != 0){
             rv = -1;
             goto return_rv;
index 2c6aa476303da9a1289b024440b36d180afd4368..b500c8513ff9fed902c936ae5e76f854c45176e0 100644 (file)
 # ------------------------------------------------
 # This test is really a set of tests, one for
 # each compression flag. -Ca, -Cem, etc..
-# The 'opt' tests execute non-serialized scanners with various table options.
-# The 'ver' verify that the serialized tables match the in-code tables.
-# The 'ser' deserialize the tables and scan using them.
+# 'test-opt' builds non-serialized scanners with various table options.
+# 'test-ver' verifies that the serialized tables match the in-code tables.
+# 'test-ser' deserializes the tables at runtime.
+# 'test-mul' checks that we can store multiple tables in a single file.
 # ------------------------------------------------
 
 BISON = @BISON@
@@ -32,38 +33,59 @@ FLEX = $(top_builddir)/flex
 
 testname  := test-table-opts
 allopts   := -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem
-variations := opt-nr opt-r ser-nr ser-r ver-nr ver-r
-alltests  := $(foreach opt,$(allopts), $(foreach vari,$(variations),test-$(vari)$(opt)))
-alltestexe := $(addsuffix $(EXEEXT),$(alltests))
-alltestsrc := $(addsuffix .c,$(alltests))
-alltestobj := $(addsuffix .o,$(alltests))
+
+# the test names themselves
+opttests :=  $(foreach opt,$(allopts), test-opt-nr$(opt) test-opt-r$(opt))
+sertests :=  $(foreach opt,$(allopts), test-ser-nr$(opt) test-ser-r$(opt))
+vertests :=  $(foreach opt,$(allopts), test-ver-nr$(opt) test-ver-r$(opt))
+alltests  := $(opttests) $(vertests) $(sertests) test-mul
+
+# the executables to build
+optexe := $(addsuffix $(EXEEXT),$(opttests))
+verexe := $(addsuffix $(EXEEXT),$(vertests))
+serexe := $(addsuffix $(EXEEXT),$(sertests))
+allexe := $(optexe) $(verexe) $(serexe)
+
+# the .c files
+optsrc := $(addsuffix .c,$(opttests))
+versrc := $(addsuffix .c,$(vertests))
+sersrc := $(addsuffix .c,$(sertests))
+allsrc := $(optsrc) $(versrc) $(sersrc)
+
+# the .o files
+optobj := $(addsuffix .o,$(opttests))
+verobj := $(addsuffix .o,$(vertests))
+serobj := $(addsuffix .o,$(sertests))
+allobj := $(optobj) $(verobj) $(serobj)
+
+# the .tables files
+sertables  := $(addsuffix .tables,$(sertests))
 alltables  := $(addsuffix .tables,$(alltests))
 
 EXTRA_DIST = scanner.l test.input
-CLEANFILES = scanner.c OUTPUT $(alltestobj) $(alltestsrc) $(alltestexe)\
-             $(alltables)
+CLEANFILES = scanner.c OUTPUT test-*.o test-*.c test-*.tables core $(alltests)
 INCLUDES = -I $(srcdir) -I $(top_srcdir) -I $(top_builddir) -I .
 
-
-test-table-opts: $(alltests) comparison_test
+test: test-table-opts
+test-table-opts: $(alltests)
 
 test-opt-r%.c: $(srcdir)/scanner.l
-       $(FLEX) -L --reentrant $*  -o $@ $<
+       $(FLEX) -L -P $(subst -,_,$(basename $(@F))) --reentrant $*  -o $@ $<
 
 test-opt-nr%.c: $(srcdir)/scanner.l
-       $(FLEX) -L $* -o $@ $<
+       $(FLEX) -L -P $(subst -,_,$(basename $(@F))) $* -o $@ $<
 
 test-ser-r%.c: $(srcdir)/scanner.l
-       $(FLEX) -L --reentrant --tables-file="test-ser-r$*.tables" $*  -o $@ $<
+       $(FLEX) -L -P $(subst -,_,$(basename $(@F))) -R --tables-file="test-ser-r$*.tables" $*  -o $@ $<
 
 test-ser-nr%.c: $(srcdir)/scanner.l
-       $(FLEX) -L --tables-file="test-ser-nr$*.tables"  $* -o $@ $<
+       $(FLEX) -L -P $(subst -,_,$(basename $(@F))) --tables-file="test-ser-nr$*.tables"  $* -o $@ $<
 
 test-ver-r%.c: $(srcdir)/scanner.l
-       $(FLEX) -L --reentrant --tables-file="test-ver-r$*.tables" --tables-verify $*  -o $@ $<
+       $(FLEX) -L -P $(subst -,_,$(basename $(@F))) -R --tables-file="test-ver-r$*.tables" --tables-verify $*  -o $@ $<
 
 test-ver-nr%.c: $(srcdir)/scanner.l
-       $(FLEX) -L --tables-file="test-ver-nr$*.tables" --tables-verify $* -o $@ $<
+       $(FLEX) -L -P $(subst -,_,$(basename $(@F))) --tables-file="test-ver-nr$*.tables" --tables-verify $* -o $@ $<
 
 test-opt%$(EXEEXT): test-opt%.o
        $(CC) -o $@ $(LDFLAGS) $< $(LOADLIBES)
@@ -74,13 +96,33 @@ test-ser%$(EXEEXT): test-ser%.o
 test-ver%$(EXEEXT): test-ver%.o
        $(CC) -o $@ $(LDFLAGS) $< $(LOADLIBES)
 
-test: $(alltestexe)
-       for t in $(alltestexe) ; do \
-               ./$$t `basename $$t $(EXEEXT)`.tables < $(srcdir)/test.input || exit 1 ; \
+test-opt: $(optexe)
+       for t in $(optexe) ; do \
+               ./$$t `basename $$t $(EXEEXT)`.tables < $(srcdir)/test.input \
+          || { echo $t FAILED ; exit 1 ; } ; \
+       done
+
+test-ver: $(verexe)
+       for t in $(verexe) ; do \
+               ./$$t `basename $$t $(EXEEXT)`.tables < $(srcdir)/test.input \
+          || { echo $t FAILED ; exit 1 ; } ; \
+       done
+
+test-ser: $(serexe)
+       for t in $(serexe) ; do \
+               ./$$t `basename $$t $(EXEEXT)`.tables < $(srcdir)/test.input \
+          || { echo $t FAILED ; exit 1 ; } ; \
+       done
+
+test-mul: $(serexe)
+       $(RM) all-ser.tables
+       cat $(sertables) > all-ser.tables
+       for t in $(serexe) ; do \
+               ./$$t all-ser.tables < $(srcdir)/test.input || { echo $$t FAILED; exit 1; } ;  \
        done
 
 .c.o:
        $(CC) -c -o $@ $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $<
 
-.PHONY: test-table-opts
-.SECONDARY: $(alltestobj) $(alltestsrc)
+.PHONY: test-table-opts test test-opt test-ser test-ver test-mul
+.SECONDARY: $(allobj) $(allsrc)
index 4a3bf9596542c36e76123ff136e3f2fb5df30d2b..2b1119e61de984dc4ca8aa6723713ba027414250 100644 (file)
@@ -28,7 +28,7 @@
 #include "config.h"
 %}
 
-%option 8bit prefix="vvv"
+%option 8bit
 %option nounput nomain noyywrap 
 %option warn yylineno