diff options
Diffstat (limited to 'tests')
53 files changed, 606 insertions, 451 deletions
diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..e5c42b3 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,105 @@ +*.log +*.trs +*.o +*.tables +alloc_extra +alloc_extra.c +array_nr +array_nr.c +array_r +array_r.c +basic_nr +basic_nr.c +basic_r +basic_r.c +bison_nr +bison_nr_scanner.[ch] +bison_nr_parser.[ch] +bison_yylloc +bison_yylloc_parser.[ch] +bison_yylloc_scanner.[ch] +bison_yylval +bison_yylval_parser.[ch] +bison_yylval_scanner.[ch] +c_cxx_nr +c_cxx_nr.cc +c_cxx_r +c_cxx_r.cc +ccl +ccl.c +cxx_basic +cxx_basic.cc +cxx_multiple_scanners +cxx_multiple_scanners_[12].cc +cxx_restart +cxx_restart.cc +cxx_yywrap.i3 +cxx_yywrap.cc +debug_nr +debug_nr.c +debug_r +debug_r.c +extended +extended.c +header_nr +header_nr_scanner.[ch] +header_r +header_r_scanner.[ch] +include_by_buffer.direct +include_by_buffer.direct.c +include_by_push.direct +include_by_push.direct.c +include_by_reentrant.direct +include_by_reentrant.direct.c +lineno_nr.one +lineno_nr.c +lineno_r.one +lineno_r.c +lineno_trailing.one +lineno_trailing.c +mem_nr +mem_nr.c +mem_r +mem_r.c +multiple_scanners_nr +multiple_scanners_nr_[12].[ch] +multiple_scanners_r +multiple_scanners_r_[12].[ch] +posix +posix.c +posixly_correct +posixly_correct.c +prefix_nr +prefix_nr.c +prefix_r +prefix_r.c +pthread.pthread +pthread.c +reject_nr.reject +reject_nr.reject.c +reject_r.reject +reject_r.reject.c +reject_ver.table +reject_ver.table.c +reject_ser.table +reject_ser.table.c +rescan_nr.direct +rescan_nr.direct.c +rescan_r.direct +rescan_r.direct.c +quote_in_comment +quote_in_comment.c +quotes +quotes.c +string_nr +string_nr.c +string_r +string_r.c +top +top.[ch] +yyextra +yyextra.c +tableopts_*.c +*.opt +*.ser +*.ver diff --git a/tests/Makefile.am b/tests/Makefile.am index 428e4b2..2cb51df 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -19,6 +19,8 @@ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE. +AM_CFLAGS = $(WARNINGFLAGS) + TESTS = $(check_PROGRAMS) options.cn # The script testwrapper.sh will run most tests as is. A couple tests @@ -29,28 +31,28 @@ TESTS = $(check_PROGRAMS) options.cn TEST_EXTENSIONS = .reject .table .direct .cn .i3 .pthread .one .opt .ser .ver -LOG_COMPILER = $(srcdir)/testwrapper.sh +LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_LOG_FLAGS = -d $(srcdir) -r -REJECT_LOG_COMPILER = $(srcdir)/testwrapper.sh +REJECT_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_REJECT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/reject.txt -r -TABLE_LOG_COMPILER = $(srcdir)/testwrapper.sh +TABLE_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_TABLE_LOG_FLAGS = -d $(builddir) -i $(srcdir)/reject.txt -t -DIRECT_LOG_COMPILER=$(srcdir)/testwrapper.sh -AM_DIRECT_LOG_FLAGS = -d $(srcdir) +DIRECT_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper-direct.sh +AM_DIRECT_LOG_FLAGS = -b $(abs_builddir) -s $(srcdir) -CN_LOG_COMPILER=$(srcdir)/options.cn -AM_CN_LOG_FLAGS=$(FLEX) +CN_LOG_COMPILER = $(SHELL) $(srcdir)/options.cn +AM_CN_LOG_FLAGS = $(FLEX) -I3_LOG_COMPILER=$(srcdir)/testwrapper.sh -AM_I3_LOG_FLAGS=-i $(srcdir)/cxx_yywrap.txt -i $(srcdir)/cxx_yywrap.txt -i $(srcdir)/cxx_yywrap.txt +I3_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh +AM_I3_LOG_FLAGS = -i $(srcdir)/cxx_yywrap.txt -i $(srcdir)/cxx_yywrap.txt -i $(srcdir)/cxx_yywrap.txt -PTHREAD_LOG_COMPILER=$(srcdir)/testwrapper.sh -AM_PTHREAD_LOG_FLAGS=-i $(srcdir)/pthread_1.txt -i $(srcdir)/pthread_2.txt -i $(srcdir)/pthread_3.txt -i $(srcdir)/pthread_4.txt -i $(srcdir)/pthread_5.txt +PTHREAD_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh +AM_PTHREAD_LOG_FLAGS = -i $(srcdir)/pthread_1.txt -i $(srcdir)/pthread_2.txt -i $(srcdir)/pthread_3.txt -i $(srcdir)/pthread_4.txt -i $(srcdir)/pthread_5.txt -ONE_LOG_COMPILER = $(srcdir)/testwrapper.sh +ONE_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_ONE_LOG_FLAGS = -1 -d $(srcdir) AM_YFLAGS = -d -p test @@ -72,6 +74,7 @@ simple_tests = \ ccl \ cxx_basic \ cxx_multiple_scanners \ + cxx_restart \ debug_nr \ debug_r \ extended \ @@ -81,12 +84,11 @@ simple_tests = \ mem_r \ multiple_scanners_nr \ multiple_scanners_r \ - noansi_nr \ - noansi_r \ posix \ posixly_correct \ prefix_nr \ prefix_r \ + quote_in_comment \ quotes \ string_nr \ string_r \ @@ -111,35 +113,46 @@ DIRECT_TESTS = \ I3_TESTS = \ cxx_yywrap.i3 -if want_pthread PTHREAD_TESTS = \ pthread.pthread -endif ONE_TESTS = \ lineno_nr.one \ lineno_r.one \ lineno_trailing.one +quote_in_comment_SOURCES = quote_in_comment.l alloc_extra_SOURCES = alloc_extra.l array_nr_SOURCES = array_nr.l array_r_SOURCES = array_r.l basic_nr_SOURCES = basic_nr.l basic_r_SOURCES = basic_r.l +if HAVE_BISON bison_nr_SOURCES = bison_nr_scanner.l bison_nr_parser.y bison_nr_main.c +nodist_bison_nr_SOURCES = bison_nr_parser.h bison_nr_scanner.h bison_yylloc_SOURCES = bison_yylloc_scanner.l bison_yylloc_parser.y bison_yylloc_main.c +nodist_bison_yylloc_SOURCES = bison_yylloc_parser.h bison_yylloc_scanner.h bison_yylval_SOURCES = bison_yylval_scanner.l bison_yylval_parser.y bison_yylval_main.c +nodist_bison_yylval_SOURCES = bison_yylval_parser.h bison_yylval_scanner.h +else +bison_nr_SOURCES = no_bison_stub.c +bison_yylloc_SOURCES = no_bison_stub.c +bison_yylval_SOURCES = no_bison_stub.c +endif c_cxx_nr_SOURCES = c_cxx_nr.lll c_cxx_r_SOURCES = c_cxx_r.lll ccl_SOURCES = ccl.l cxx_basic_SOURCES = cxx_basic.ll +cxx_restart_SOURCES = cxx_restart.ll cxx_multiple_scanners_SOURCES = cxx_multiple_scanners_main.cc cxx_multiple_scanners_1.ll cxx_multiple_scanners_2.ll cxx_yywrap_i3_SOURCES = cxx_yywrap.ll debug_nr_SOURCES = debug_nr.l debug_r_SOURCES = debug_r.l extended_SOURCES = extended.l header_nr_SOURCES = header_nr_scanner.l header_nr_main.c +nodist_header_nr_SOURCES = header_nr_scanner.h header_r_SOURCES = header_r_scanner.l header_r_main.c +nodist_header_r_SOURCES = header_r_scanner.h include_by_buffer_direct_SOURCES = include_by_buffer.direct.l include_by_push_direct_SOURCES = include_by_push.direct.l include_by_reentrant_direct_SOURCES = include_by_reentrant.direct.l @@ -149,9 +162,9 @@ lineno_trailing_one_SOURCES = lineno_trailing.l mem_nr_SOURCES = mem_nr.l mem_r_SOURCES = mem_r.l multiple_scanners_nr_SOURCES = multiple_scanners_nr_main.c multiple_scanners_nr_1.l multiple_scanners_nr_2.l +nodist_multiple_scanners_nr_SOURCES = multiple_scanners_nr_1.h multiple_scanners_nr_2.h multiple_scanners_r_SOURCES = multiple_scanners_r_main.c multiple_scanners_r_1.l multiple_scanners_r_2.l -noansi_nr_SOURCES = noansi_nr.l -noansi_r_SOURCES = noansi_r.l +nodist_multiple_scanners_r_SOURCES = multiple_scanners_nr_1.h multiple_scanners_nr_2.h posix_SOURCES = posix.l posixly_correct_SOURCES = posixly_correct.l prefix_nr_SOURCES = prefix_nr.l @@ -167,23 +180,9 @@ rescan_r_direct_SOURCES = rescan_r.direct.l string_nr_SOURCES = string_nr.l string_r_SOURCES = string_r.l top_SOURCES = top.l top_main.c +nodist_top_SOURCES = top.h yyextra_SOURCES = yyextra.l -BUILT_SOURCES = \ - bison_nr_parser.h \ - bison_nr_scanner.h \ - bison_yylloc_parser.h \ - bison_yylloc_scanner.h \ - bison_yylval_parser.h \ - bison_yylval_scanner.h \ - header_nr_scanner.h \ - header_r_scanner.h \ - multiple_scanners_nr_1.h \ - multiple_scanners_nr_2.h \ - multiple_scanners_r_1.h \ - multiple_scanners_r_2.h \ - top.h - # Normally, automake would distribute files built by flex. Since the # point of the test suite is to test the files that flex builds, and # since anyone who has the flex distribution can build a flex binary @@ -194,6 +193,7 @@ BUILT_SOURCES = \ # it. CLEANFILES = \ + alloc_extra.c \ array_nr.c \ array_r.c \ basic_nr.c \ @@ -216,6 +216,7 @@ CLEANFILES = \ cxx_basic.cc \ cxx_multiple_scanners_1.cc \ cxx_multiple_scanners_2.cc \ + cxx_restart.cc \ cxx_yywrap.cc \ debug_nr.c \ debug_r.c \ @@ -240,13 +241,12 @@ CLEANFILES = \ multiple_scanners_r_1.h \ multiple_scanners_r_2.c \ multiple_scanners_r_2.h \ - noansi_nr.c \ - noansi_r.c \ posix.c \ posixly_correct.c \ prefix_nr.c \ prefix_r.c \ pthread.c \ + quote_in_comment.c \ quotes.c \ reject_nr.reject.c \ reject_r.reject.c \ @@ -261,7 +261,6 @@ CLEANFILES = \ top.c \ top.h \ yyextra.c \ -alloc_extra.c \ $(tableopts_c) \ $(tableopts_tables) @@ -285,6 +284,7 @@ EXTRA_DIST = \ ccl.txt \ cxx_basic.txt \ cxx_multiple_scanners.txt \ + cxx_restart.txt \ cxx_yywrap.txt \ debug_nr.txt \ debug_r.txt \ @@ -305,8 +305,6 @@ EXTRA_DIST = \ lineno_trailing.one.txt \ mem_nr.txt \ mem_r.txt \ - noansi_nr.txt \ - noansi_r.txt \ prefix_nr.txt \ prefix_r.txt \ pthread_1.txt \ @@ -317,6 +315,7 @@ EXTRA_DIST = \ reject.txt \ rescan_nr.direct.txt \ rescan_r.direct.txt \ + quote_in_comment.txt \ quotes.txt \ top.txt \ yyextra.txt \ @@ -327,90 +326,115 @@ dist_noinst_SCRIPTS = \ dist_check_SCRIPTS = \ options.cn \ + testwrapper-direct.sh \ testwrapper.sh -pthread_pthread_LDADD = -lpthread +pthread_pthread_LDADD = @LIBPTHREAD@ # specify how to process .l files in order to test the flex built by make all FLEX = $(top_builddir)/src/flex .l.c: $(FLEX) - $(FLEX) -o $@ $< + $(AM_V_LEX)$(FLEX) -o $@ $< .ll.cc: $(FLEX) - $(FLEX) -+ -o $@ $< + $(AM_V_LEX)$(FLEX) -+ -o $@ $< + +bison_nr_main.$(OBJEXT): bison_nr_parser.h bison_nr_scanner.h +bison_nr_scanner.$(OBJEXT): bison_nr_parser.h -bison_nr_main.($OBJEXT): bison_nr_parser.h bison_nr_scanner.h bison_nr_scanner.h: bison_nr_scanner.c + @if test ! -f $@; then rm -f $<; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi bison_yylloc_main.$(OBJEXT): bison_yylloc_parser.h bison_yylloc_scanner.h +bison_yylloc_scanner.$(OBJEXT): bison_yylloc_parser.h + bison_yylloc_scanner.h: bison_yylloc_scanner.c + @if test ! -f $@; then rm -f $<; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi bison_yylval_main.$(OBJEXT): bison_yylval_parser.h bison_yylval_scanner.h +bison_yylval_scanner.$(OBJEXT): bison_yylval_parser.h + bison_yylval_scanner.h: bison_yylval_scanner.c + @if test ! -f $@; then rm -f $<; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi # automake does not support compiling flex scanners output in C as C++ # so we explicitly sayhow, using the .lll suffix for the lex input file .lll.cc: $(FLEX) - $(FLEX) -o $@ $< + $(AM_V_LEX)$(FLEX) -o $@ $< header_nr_main.$(OBJEXT): header_nr_scanner.h + header_nr_scanner.h: header_nr_scanner.c + @if test ! -f $@; then rm -f $<; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi header_r_main.$(OBJEXT): header_r_scanner.h -header_r_scanner.h: header_r_scanner.c -include_by_buffer.direct$(EXE): include_by_buffer.direct.txt include_by_buffer.direct_2.txt include_by_buffer.direct_3.txt - -include_by_push.direct$(EXE): include_by_push.direct.txt include_by_push.direct_2.txt include_by_push.direct_3.txt - -include_by_reentrant.direct$(EXE): include_by_reentrant.direct.txt include_by_reentrant.direct_2.txt include_by_reentrant.direct_3.txt +header_r_scanner.h: header_r_scanner.c + @if test ! -f $@; then rm -f $<; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi multiple_scanners_nr_main.$(OBJEXT): multiple_scanners_nr_1.h multiple_scanners_nr_2.h + multiple_scanners_nr_1.h: multiple_scanners_nr_1.c + @if test ! -f $@; then rm -f $<; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi + multiple_scanners_nr_2.h: multiple_scanners_nr_2.c + @if test ! -f $@; then rm -f $<; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi multiple_scanners_r_main.$(OBJEXT): multiple_scanners_r_1.h multiple_scanners_r_2.h + multiple_scanners_r_1.h: multiple_scanners_r_1.c + @if test ! -f $@; then rm -f $<; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi + multiple_scanners_r_2.h: multiple_scanners_r_2.c + @if test ! -f $@; then rm -f $<; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi posixly_correct.c: posixly_correct.l $(FLEX) - POSIXLY_CORRECT=1 $(FLEX) -o $@ $< + $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) -o $@ $< reject_nr.reject.c: reject.l4 $(FLEX) - $(FLEX) -o $@ $< + $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -o $@ $< reject_nr.reject$(EXEEXT): reject_nr.reject.$(OBJEXT) - $(LINK) $^ + $(AM_V_CCLD)$(LINK) $^ reject_r.reject.c: reject.l4 $(FLEX) - $(FLEX) --reentrant -o $@ $< + $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape --reentrant -o $@ $< reject_r.reject.$(OBJEXT): reject_r.reject.c - $(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $< + $(AM_V_CC)$(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $< reject_r.reject$(EXEEXT): reject_r.reject.$(OBJEXT) - $(LINK) $^ + $(AM_V_CCLD)$(LINK) $^ reject_ver.table.c: reject.l4 $(FLEX) - $(FLEX) -o $@ --tables-verify --tables-file=$(basename $@).tables $< + $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -o $@ --tables-verify --tables-file=$(basename $@).tables $< reject_ver.table.$(OBJEXT): reject_ver.table.c - $(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< + $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< reject_ver.table$(EXEEXT): reject_ver.table.$(OBJEXT) - $(LINK) $^ + $(AM_V_CCLD)$(LINK) $^ reject_ser.table.c: reject.l4 $(FLEX) - $(FLEX) -o $@ --tables-file=$(basename $@).tables $< + $(AM_V_LEX)$(FLEX) -o $@ --unsafe-no-m4-sect3-escape --tables-file=$(basename $@).tables $< reject_ser.table.$(OBJEXT): reject_ser.table.c - $(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< + $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< reject_ser.table$(EXEEXT): reject_ser.table.$(OBJEXT) - $(LINK) $^ + $(AM_V_CCLD)$(LINK) $^ top_main.$(OBJEXT): top.h top.h: top.c @@ -422,7 +446,7 @@ top.h: top.c # it can be / is generated by a shell script, tableopts.sh. tableopts.am: tableopts.sh - $(srcdir)/tableopts.sh > $(srcdir)/tableopts.am + $(SHELL) $(srcdir)/tableopts.sh > $(srcdir)/tableopts.am include $(srcdir)/tableopts.am @@ -434,50 +458,50 @@ tableopts_tests := $(tableopts_opttests) $(tableopts_vertests) $(tableopts_sert tableopts_c := $(addsuffix .c,$(tableopts_tests)) -OPT_LOG_COMPILER = $(srcdir)/testwrapper.sh +OPT_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_OPT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/tableopts.txt -r tableopts_opt_nr%.c: tableopts.l4 $(FLEX) - $(FLEX) -P $(subst -,_,$(basename $(*F))) $* -o $@ $< + $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) $* -o $@ $< tableopts_opt_nr%.$(OBJEXT): tableopts_opt_nr%.c - $(COMPILE) -c -o $@ $< + $(AM_V_CC)$(COMPILE) -c -o $@ $< tableopts_opt_r%.c: tableopts.l4 $(FLEX) - $(FLEX) -P $(subst -,_,$(basename $(*F))) --reentrant $* -o $@ $< + $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --reentrant $* -o $@ $< tableopts_opt_r%.$(OBJEXT): tableopts_opt_r%.c - $(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $< + $(AM_V_CC)$(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $< -SER_LOG_COMPILER = $(srcdir)/testwrapper.sh +SER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_SER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r -t tableopts_ser_nr%.c: tableopts.l4 $(FLEX) - $(FLEX) -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ser_nr$*.ser.tables" $* -o $@ $< + $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ser_nr$*.ser.tables" $* -o $@ $< tableopts_ser_nr%.$(OBJEXT): tableopts_ser_nr%.c - $(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< + $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< tableopts_ser_r%.c: tableopts.l4 $(FLEX) - $(FLEX) -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ser_r$*.ser.tables" $* -o $@ $< + $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ser_r$*.ser.tables" $* -o $@ $< tableopts_ser_r%.$(OBJEXT): tableopts_ser_r%.c - $(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $< + $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $< -VER_LOG_COMPILER = $(srcdir)/testwrapper.sh +VER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_VER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r -t tableopts_ver_nr%.c: tableopts.l4 $(FLEX) - $(FLEX) -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ver_nr$*.ver.tables" --tables-verify $* -o $@ $< + $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ver_nr$*.ver.tables" --tables-verify $* -o $@ $< tableopts_ver_nr%.$(OBJEXT): tableopts_ver_nr%.c - $(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< + $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< tableopts_ver_nr%.ver$(EXEEXT): tableopts_ver_nr%.$(OBJEXT) - $(LINK) -o $@ $^ + $(AM_V_CCLD)$(LINK) -o $@ $^ tableopts_ver_r%.c: tableopts.l4 $(FLEX) - $(FLEX) -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ver_r$*.ver.tables" --tables-verify $* -o $@ $< + $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ver_r$*.ver.tables" --tables-verify $* -o $@ $< tableopts_ver_r%.$(OBJEXT): tableopts_ver_r%.c - $(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $< + $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $< diff --git a/tests/README b/tests/README index 43387f4..f1b9ba0 100644 --- a/tests/README +++ b/tests/README @@ -50,7 +50,8 @@ stderr, which will have been redirected to the log file created by the automake test suite harness. ** If your test is skipped (e.g., because bison was not found), then - the test should return 2 (two). + the test should return 77 (seventy-seven). This is the exit status that + would be recognized by automake's "test-driver" as _skipped_. ** Once your work is done, submit a patch via the flex development mailing list, the github pull request mechanism or some other diff --git a/tests/alloc_extra.l b/tests/alloc_extra.l index 2c582a8..c974777 100644 --- a/tests/alloc_extra.l +++ b/tests/alloc_extra.l @@ -43,9 +43,6 @@ struct Check { /* Save char into junk array at next position. */ static void check_extra ( yyscan_t scanner ); -/* Special yyalloc */ -void *yyalloc ( size_t size, yyscan_t scanner ); - %} %option 8bit prefix="test" @@ -65,7 +62,7 @@ void *yyalloc ( size_t size, yyscan_t scanner ); int main(void); int -main () +main (void) { yyscan_t scanner; struct Check check; @@ -78,8 +75,8 @@ main () testset_in(stdin, scanner); testset_out(stdout, scanner); - /* Test to confirm that yyalloc was called from - * yylex_init_extra with the yyextra argument. + /* Test to confirm that testalloc was called from + * testlex_init_extra with the testextra argument. */ check_extra(scanner); @@ -89,7 +86,7 @@ main () return 0; } -void *yyalloc(size_t size, yyscan_t scanner) +void *testalloc(size_t size, yyscan_t scanner) { struct Check *check; check = testget_extra(scanner); diff --git a/tests/array_nr.l b/tests/array_nr.l index 52e0753..f4f0f1b 100644 --- a/tests/array_nr.l +++ b/tests/array_nr.l @@ -45,7 +45,7 @@ int main (void); int -main () +main (void) { yyin = stdin; yyout = stdout; diff --git a/tests/array_r.l b/tests/array_r.l index 556d26f..68a6299 100644 --- a/tests/array_r.l +++ b/tests/array_r.l @@ -45,7 +45,7 @@ int main(void); int -main () +main (void) { yyscan_t lexer; diff --git a/tests/basic_nr.l b/tests/basic_nr.l index 3c29757..bbe87c4 100644 --- a/tests/basic_nr.l +++ b/tests/basic_nr.l @@ -52,7 +52,7 @@ WS [[:blank:]] int main(void); -int main () +int main (void) { yyin = stdin; yyout = stdout; diff --git a/tests/basic_r.l b/tests/basic_r.l index e9ff59f..43d3a88 100644 --- a/tests/basic_r.l +++ b/tests/basic_r.l @@ -52,16 +52,16 @@ WS [[:blank:]] int main(void); -int main () +int main (void) { yyscan_t lexer; - yylex_init( &lexer ); - yyset_out ( stdout,lexer); - yyset_in ( stdin, lexer); - while( yylex(lexer) ) + testlex_init( &lexer ); + testset_out ( stdout,lexer); + testset_in ( stdin, lexer); + while( testlex(lexer) ) { } - yylex_destroy( lexer ); + testlex_destroy( lexer ); printf("TEST RETURNING OK.\n"); return 0; } diff --git a/tests/bison_nr_main.c b/tests/bison_nr_main.c index f5dd98a..dfd6749 100644 --- a/tests/bison_nr_main.c +++ b/tests/bison_nr_main.c @@ -24,7 +24,6 @@ #include "bison_nr_parser.h" #include "bison_nr_scanner.h" -extern int testparse(void); int main ( int argc, char** argv ) { diff --git a/tests/bison_nr_parser.y b/tests/bison_nr_parser.y index cbb4f2c..b981f7e 100644 --- a/tests/bison_nr_parser.y +++ b/tests/bison_nr_parser.y @@ -38,11 +38,10 @@ /* #define YYLEX_PARAM scanner */ int yyerror(const char* msg); -extern int testget_lineno(void); /* A dummy function. A check against seg-faults in yylval->str. */ -int process_text(char* s) { +static int process_text(char* s) { int total =0; while(*s) { total += (int) *s; diff --git a/tests/bison_yylloc_parser.y b/tests/bison_yylloc_parser.y index 8737291..93c63c0 100644 --- a/tests/bison_yylloc_parser.y +++ b/tests/bison_yylloc_parser.y @@ -40,11 +40,9 @@ int yyerror(YYLTYPE *location, void* scanner, const char* msg); #define YYERROR_VERBOSE 1 -extern int testget_lineno(void*); - /* A dummy function. A check against seg-faults in yylval->str. */ -int process_text(char* s) { +static int process_text(char* s) { int total =0; while(*s) { total += (int) *s; diff --git a/tests/bison_yylval_parser.y b/tests/bison_yylval_parser.y index 4159d7b..3fc9c58 100644 --- a/tests/bison_yylval_parser.y +++ b/tests/bison_yylval_parser.y @@ -40,7 +40,7 @@ int yyerror(void* scanner, const char* msg); /* A dummy function. A check against seg-faults in yylval->str. */ -int process_text(char* s) { +static int process_text(char* s) { int total =0; while(*s) { total += (int) *s; diff --git a/tests/bison_yylval_scanner.l b/tests/bison_yylval_scanner.l index 1e93fc1..3aa7ea9 100644 --- a/tests/bison_yylval_scanner.l +++ b/tests/bison_yylval_scanner.l @@ -52,7 +52,7 @@ enum yesno_t { no=0, yes=1 }; "</" { NEED_TAG_NAME= yes; yy_push_state( IN_TAG, yyscanner); return LTSLASH;} "<"[^[:alpha:]] { yy_push_state(DISCARD_THRU_GT,yyscanner); } "<" { NEED_TAG_NAME= yes; yy_push_state( IN_TAG, yyscanner); return LT; } -[^<]{1,512} { yyget_lval(yyscanner)->str = STRDUP(yytext); return TEXT;} +[^<]{1,512} { testget_lval(yyscanner)->str = STRDUP(yytext); return TEXT;} } <IN_TAG>{ ">" { yy_pop_state( yyscanner ); return GT; } diff --git a/tests/c_cxx_nr.lll b/tests/c_cxx_nr.lll index c9e0fb6..24a73d7 100644 --- a/tests/c_cxx_nr.lll +++ b/tests/c_cxx_nr.lll @@ -48,10 +48,10 @@ int main(void); int main () { - yyin = stdin; - yyout = stdout; - yylex(); - yylex_destroy(); + testin = stdin; + testout = stdout; + testlex(); + testlex_destroy(); printf("TEST RETURNING OK.\n"); return 0; } diff --git a/tests/c_cxx_r.lll b/tests/c_cxx_r.lll index 83a39d7..e1fe9da 100644 --- a/tests/c_cxx_r.lll +++ b/tests/c_cxx_r.lll @@ -49,13 +49,13 @@ int main () { yyscan_t lexer; - yylex_init( &lexer ); - yyset_out ( stdout,lexer); - yyset_in ( stdin, lexer); - while( yylex(lexer) ) + testlex_init( &lexer ); + testset_out ( stdout,lexer); + testset_in ( stdin, lexer); + while( testlex(lexer) ) { } - yylex_destroy( lexer ); + testlex_destroy( lexer ); printf("TEST RETURNING OK.\n"); return 0; } diff --git a/tests/ccl.l b/tests/ccl.l index c244892..9511604 100644 --- a/tests/ccl.l +++ b/tests/ccl.l @@ -84,7 +84,7 @@ int main(void); int -main () +main (void) { yyin = stdin; yyout = stdout; diff --git a/tests/noansi_nr.l b/tests/cxx_restart.ll index db075a4..0ba6be1 100644 --- a/tests/noansi_nr.l +++ b/tests/cxx_restart.ll @@ -21,47 +21,31 @@ * PURPOSE. */ -/* TEST scanner. - Basic non-reentrant scanner, but with non-ansi function defs. - Compile with: flex scanner.l - - Sample Input: - # this is a comment - foo = true - bar = "string value" - integer = 43 -*/ %{ + #include "config.h" + %} -%option prefix="test" -%option nounput noyywrap noyylineno warn nodefault noinput -%option noansi-prototypes noansi-definitions +%option 8bit prefix="test" +%option warn c++ +%option nounput nomain noinput noyywrap -IDENT [[:alnum:]_-] -WS [[:blank:]] %% -^{IDENT}+{WS}*={WS}*(true|false){WS}*\r?\n { return 100;} -^{IDENT}+{WS}*={WS}*\"[^\"\n\r]*\"{WS}*\r?\n { return 101;} -^{IDENT}+{WS}*={WS}*[[:digit:]]+{WS}*\r?\n { return 102;} -^{WS}*#.*\r?\n { } -^{WS}*\r?\n { } -.|\n { fprintf(stderr,"Invalid line.\n"); exit(-1);} +. { } %% int main(void); -int main () +int +main (void) { - yyin = stdin; - yyout = stdout; - while( yylex() ) - { - } - printf("TEST RETURNING OK.\n"); + yyFlexLexer f; + f.switch_streams(&std::cin, &std::cout); + f.yylex(); + f.yyrestart(NULL); + std::cout << "TEST RETURNING OK." << std::endl; return 0; } - diff --git a/tests/cxx_restart.txt b/tests/cxx_restart.txt new file mode 100644 index 0000000..7288a40 --- /dev/null +++ b/tests/cxx_restart.txt @@ -0,0 +1,2 @@ +0000 foo 1111 foo 0000 bar +0000 foo 1111 foo 0000 bar diff --git a/tests/debug_nr.l b/tests/debug_nr.l index 0596dce..8110ab4 100644 --- a/tests/debug_nr.l +++ b/tests/debug_nr.l @@ -41,7 +41,7 @@ int main(void); int -main () +main (void) { yyin = stdin; yyout = stdout; diff --git a/tests/debug_r.l b/tests/debug_r.l index 0d40e0e..8c2d7a5 100644 --- a/tests/debug_r.l +++ b/tests/debug_r.l @@ -40,20 +40,20 @@ int main(void); -int main () +int main (void) { yyscan_t lexer; - yylex_init( &lexer ); - yyset_out ( stdout,lexer); - yyset_in ( stdin, lexer); + testlex_init( &lexer ); + testset_out ( stdout,lexer); + testset_in ( stdin, lexer); /* Just see if the next line compiles. */ testset_debug (testget_debug(lexer), lexer); - while( yylex(lexer) ) + while( testlex(lexer) ) { } - yylex_destroy( lexer ); + testlex_destroy( lexer ); printf("TEST RETURNING OK.\n"); return 0; } diff --git a/tests/extended.l b/tests/extended.l index a113fac..9691307 100644 --- a/tests/extended.l +++ b/tests/extended.l @@ -63,7 +63,7 @@ A(?x: B int main(void); int -main () +main (void) { yyin = stdin; yyout = stdout; diff --git a/tests/include_by_buffer.direct.l b/tests/include_by_buffer.direct.l index f3b2d2a..79ff01c 100644 --- a/tests/include_by_buffer.direct.l +++ b/tests/include_by_buffer.direct.l @@ -29,6 +29,8 @@ f * are met: #include <stdio.h> #include <stdlib.h> #include "config.h" + +int error = 0; %} %option 8bit prefix="test" @@ -56,6 +58,7 @@ int include_stack_ptr = 0; include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; if((yyin=fopen(yytext,"r"))==NULL) { fprintf(stderr,"*** Error: Could not open include file \"%s\".\n",yytext); + error = 1; yyterminate(); } yy_switch_to_buffer( yy_create_buffer( yyin, YY_BUF_SIZE )); @@ -63,6 +66,7 @@ int include_stack_ptr = 0; } .|\n { fprintf(stderr,"Invalid input \"%s\".\n", yytext); + error = 1; yyterminate(); } } @@ -97,6 +101,9 @@ main ( int argc, char** argv ) yyin = fp; yyout = stdout; yylex(); - printf("TEST RETURNING OK.\n"); + if (!error) + printf("TEST RETURNING OK.\n"); + else + exit(-1); return 0; } diff --git a/tests/include_by_push.direct.l b/tests/include_by_push.direct.l index 6b7a5fa..8aaea69 100644 --- a/tests/include_by_push.direct.l +++ b/tests/include_by_push.direct.l @@ -29,6 +29,8 @@ #include <stdio.h> #include <stdlib.h> #include "config.h" + +int error = 0; %} %option 8bit prefix="test" @@ -50,20 +52,22 @@ yytext[yyleng-1]='\0'; if((yyin=fopen(yytext,"r"))==NULL) { fprintf(stderr,"*** Error: Could not open include file \"%s\".\n",yytext); + error = 1; yyterminate(); } - yypush_buffer_state( yy_create_buffer( yyin, YY_BUF_SIZE )); + testpush_buffer_state( yy_create_buffer( yyin, YY_BUF_SIZE )); BEGIN(0); } .|\n { fprintf(stderr,"Invalid input \"%s\".\n", yytext); + error = 1; yyterminate(); } } <<EOF>> { fclose(yyin); - yypop_buffer_state(); + testpop_buffer_state(); if(!YY_CURRENT_BUFFER) yyterminate(); } @@ -87,6 +91,9 @@ main ( int argc, char** argv ) yyin = fp; yyout = stdout; yylex(); - printf("TEST RETURNING OK.\n"); + if (!error) + printf("TEST RETURNING OK.\n"); + else + exit(-1); return 0; } diff --git a/tests/include_by_reentrant.direct.l b/tests/include_by_reentrant.direct.l index 8cd4900..7dbad72 100644 --- a/tests/include_by_reentrant.direct.l +++ b/tests/include_by_reentrant.direct.l @@ -29,6 +29,8 @@ #include <stdio.h> #include <stdlib.h> #include "config.h" + +int error = 0; %} %option 8bit prefix="test" @@ -54,18 +56,20 @@ if((fp=fopen(yytext,"r"))==NULL) { fprintf(stderr,"*** Error: Could not open include file \"%s\".\n", yytext); + error = 1; yyterminate(); } - yylex_init(&scanner); - yyset_in( fp, scanner); - yyset_out( stdout, scanner); - yylex(scanner); - yylex_destroy(scanner); + testlex_init(&scanner); + testset_in( fp, scanner); + testset_out( stdout, scanner); + testlex(scanner); + testlex_destroy(scanner); BEGIN(0); } .|\n { fprintf(stderr,"Invalid input \"%s\".\n", yytext); + error = 1; yyterminate(); } } @@ -77,9 +81,7 @@ int main (int argc, char** argv); int -main ( argc, argv ) - int argc; - char ** argv; +main ( int argc, char **argv ) { FILE * fp; yyscan_t scanner; @@ -91,11 +93,14 @@ main ( argc, argv ) fprintf(stderr,"*** Error: fopen(%s) failed.\n",argv[1]); exit(-1); } - yylex_init(&scanner); - yyset_in( fp, scanner); - yyset_out( stdout, scanner); - yylex(scanner); - yylex_destroy(scanner); - printf("TEST RETURNING OK.\n"); + testlex_init(&scanner); + testset_in( fp, scanner); + testset_out( stdout, scanner); + testlex(scanner); + testlex_destroy(scanner); + if (!error) + printf("TEST RETURNING OK.\n"); + else + exit(-1); return 0; } diff --git a/tests/lineno_nr.l b/tests/lineno_nr.l index 8e35fc1..dbe6b2d 100644 --- a/tests/lineno_nr.l +++ b/tests/lineno_nr.l @@ -78,9 +78,7 @@ count_newlines (FILE* in) int main ( int, char**); int -main ( argc, argv ) - int argc; - char** argv; +main ( int argc, char **argv ) { (void)argv; diff --git a/tests/lineno_r.l b/tests/lineno_r.l index e6207c6..d7230d7 100644 --- a/tests/lineno_r.l +++ b/tests/lineno_r.l @@ -78,9 +78,7 @@ count_newlines (FILE* in) int main ( int argc, char** argv ); int -main (argc, argv) - int argc; - char ** argv; +main (int argc, char **argv) { (void)argv; @@ -89,11 +87,11 @@ main (argc, argv) else{ yyscan_t s; - yylex_init(&s); - yyset_in(stdin,s); - yyset_out(stdout,s); - yylex(s); - yylex_destroy(s); + testlex_init(&s); + testset_in(stdin,s); + testset_out(stdout,s); + testlex(s); + testlex_destroy(s); } return 0; } diff --git a/tests/lineno_trailing.l b/tests/lineno_trailing.l index 3a8a683..cceaa23 100644 --- a/tests/lineno_trailing.l +++ b/tests/lineno_trailing.l @@ -71,9 +71,7 @@ count_newlines (FILE* in) int main ( int, char**); int -main ( argc, argv ) - int argc; - char** argv; +main ( int argc, char **argv ) { (void)argv; diff --git a/tests/mem_nr.l b/tests/mem_nr.l index f25848f..b7cf343 100644 --- a/tests/mem_nr.l +++ b/tests/mem_nr.l @@ -96,7 +96,7 @@ void * yyalloc(yy_size_t n) if( nptrs >= arrsz){ /* increase array size by 1 */ arrsz++; - ptrs = realloc(ptrs, arrsz * sizeof(struct memsz)); + ptrs = realloc(ptrs, (size_t) arrsz * sizeof(struct memsz)); ptrs[nptrs].p = 0; ptrs[nptrs].sz = 0; } @@ -158,7 +158,7 @@ void yyfree(void* p) int main(void); int -main () +main (void) { arrsz = 1; ptrs = calloc(1, sizeof(struct memsz)); @@ -166,8 +166,8 @@ main () yyin = stdin; yyout = stdout; - yylex(); - yylex_destroy(); + testlex(); + testlex_destroy(); free(ptrs); if ( nptrs > 0 || total_mem > 0){ diff --git a/tests/mem_r.l b/tests/mem_r.l index 33b9888..06ae2e7 100644 --- a/tests/mem_r.l +++ b/tests/mem_r.l @@ -85,7 +85,7 @@ static void dump_mem(FILE* fp){ fprintf(fp,"}\n"); } -void * yyalloc(yy_size_t n , void* yyscanner) +void * testalloc(yy_size_t n , void* yyscanner) { (void)yyscanner; @@ -98,7 +98,7 @@ void * yyalloc(yy_size_t n , void* yyscanner) if( nptrs >= arrsz){ /* increase array size by 1 */ arrsz++; - ptrs = realloc(ptrs, arrsz * sizeof(struct memsz)); + ptrs = realloc(ptrs, (size_t) arrsz * sizeof(struct memsz)); ptrs[nptrs].p = 0; ptrs[nptrs].sz = 0; } @@ -116,7 +116,7 @@ void * yyalloc(yy_size_t n , void* yyscanner) return p; } -void * yyrealloc(void* p, yy_size_t n , void* yyscanner) +void * testrealloc(void* p, yy_size_t n , void* yyscanner) { (void)yyscanner; @@ -139,7 +139,7 @@ void * yyrealloc(void* p, yy_size_t n , void* yyscanner) exit(1); } -void yyfree(void* p , void* yyscanner) +void testfree(void* p , void* yyscanner) { (void)yyscanner; @@ -164,18 +164,18 @@ void yyfree(void* p , void* yyscanner) int main(void); int -main () +main (void) { yyscan_t scanner; arrsz = 1; ptrs = calloc(1, sizeof(struct memsz)); nptrs = 0; - yylex_init(&scanner); - yyset_in(stdin,scanner); - yyset_out(stdout,scanner); - yylex(scanner); - yylex_destroy(scanner); + testlex_init(&scanner); + testset_in(stdin,scanner); + testset_out(stdout,scanner); + testlex(scanner); + testlex_destroy(scanner); free(ptrs); if ( nptrs > 0 || total_mem > 0){ diff --git a/tests/multiple_scanners_r_main.c b/tests/multiple_scanners_r_main.c index ea73806..9c3fa8d 100644 --- a/tests/multiple_scanners_r_main.c +++ b/tests/multiple_scanners_r_main.c @@ -31,7 +31,6 @@ main ( int argc, char** argv ) (void)argv; int S1_ok=1, S2_ok=1; - FILE * fp; YY_BUFFER_STATE buff1, buff2; yyscan_t scan1, scan2; diff --git a/tests/no_bison_stub.c b/tests/no_bison_stub.c new file mode 100644 index 0000000..5fb3a9d --- /dev/null +++ b/tests/no_bison_stub.c @@ -0,0 +1,39 @@ +/* This stub will be used when Bison is not available on the user's host. */ + +/* This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ +#include <stdio.h> + +int main (int argc, char *argv[]) +{ + (void)argc; + (void)argv; + puts( + "This test requires Bison. Install Bison and re-run \"configure && make check\"\n" + "to perform this test. (This file is stub code.)" + ); + + /* Exit status for a skipped test */ + return 77; +} + +/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */ diff --git a/tests/noansi_nr.txt b/tests/noansi_nr.txt deleted file mode 100644 index 642e0fb..0000000 --- a/tests/noansi_nr.txt +++ /dev/null @@ -1,5 +0,0 @@ -# this is a comment -foo = "bar" -num = 43 -setting = false - diff --git a/tests/noansi_r.l b/tests/noansi_r.l deleted file mode 100644 index 5a3b778..0000000 --- a/tests/noansi_r.l +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -/* A reentrant scanner. - This file will not compile under flex version <= 2.5.4. - Sample Input: - # this is a comment - foo = true - bar = "string value" - integer = 43 -*/ -%{ -#include "config.h" -%} - -%option prefix="test" -%option nounput noyywrap noyylineno warn nodefault noinput -%option reentrant -%option noansi-definitions noansi-prototypes - -IDENT [[:alnum:]_-] -WS [[:blank:]] -%% - -^{IDENT}+{WS}*={WS}*(true|false){WS}*\r?\n { return 100;} -^{IDENT}+{WS}*={WS}*\"[^\"\n\r]*\"{WS}*\r?\n { return 101;} -^{IDENT}+{WS}*={WS}*[[:digit:]]+{WS}*\r?\n { return 102;} -^{WS}*#.*\r?\n { } -^{WS}*\r?\n { } -.|\n { fprintf(stderr,"Invalid line.\n"); exit(-1);} - -%% - -int main(void); - -int main () -{ - yyscan_t lexer; - yylex_init( &lexer ); - yyset_out ( stdout,lexer); - yyset_in ( stdin, lexer); - while( yylex(lexer) ) - { - } - yylex_destroy( lexer ); - printf("TEST RETURNING OK.\n"); - return 0; -} - diff --git a/tests/noansi_r.txt b/tests/noansi_r.txt deleted file mode 100644 index 2160628..0000000 --- a/tests/noansi_r.txt +++ /dev/null @@ -1,4 +0,0 @@ -# this is a comment -foo = "bar" -num = 43 -setting = false diff --git a/tests/options.cn b/tests/options.cn index 2f592e9..5af60ea 100755 --- a/tests/options.cn +++ b/tests/options.cn @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Test that flex handles the grouped noop options -c and -n properly. diff --git a/tests/posix.l b/tests/posix.l index 38e8d3b..f1851d8 100644 --- a/tests/posix.l +++ b/tests/posix.l @@ -53,7 +53,7 @@ ab{3} tests_ok[0] = 1; return 0; %% -int main () +int main (void) { YY_BUFFER_STATE state; int i; @@ -63,9 +63,9 @@ int main () /* Run the tests */ for (i=0; i < NUM_TESTS; i++){ - printf("Testing: yy_scan_string(%s): ", tests[i]); - state = yy_scan_string(tests[i]); - yylex(); + printf("Testing: test_scan_string(%s): ", tests[i]); + state = test_scan_string(tests[i]); + testlex(); yy_delete_buffer(state); printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); } diff --git a/tests/posixly_correct.l b/tests/posixly_correct.l index aff9cbd..715bb27 100644 --- a/tests/posixly_correct.l +++ b/tests/posixly_correct.l @@ -53,7 +53,7 @@ ab{3} tests_ok[0] = 1; return 0; %% -int main () +int main (void) { YY_BUFFER_STATE state; int i; @@ -63,9 +63,9 @@ int main () /* Run the tests */ for (i=0; i < NUM_TESTS; i++){ - printf("Testing: yy_scan_string(%s): ", tests[i]); - state = yy_scan_string(tests[i]); - yylex(); + printf("Testing: test_scan_string(%s): ", tests[i]); + state = test_scan_string(tests[i]); + testlex(); yy_delete_buffer(state); printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); } diff --git a/tests/prefix_nr.l b/tests/prefix_nr.l index c1665df..2208ae0 100644 --- a/tests/prefix_nr.l +++ b/tests/prefix_nr.l @@ -64,7 +64,7 @@ int main(void); int -main () +main (void) { yyin = stdin; yyout = stdout; diff --git a/tests/prefix_r.l b/tests/prefix_r.l index a2d4c1a..210a4de 100644 --- a/tests/prefix_r.l +++ b/tests/prefix_r.l @@ -71,7 +71,7 @@ int main(void); int -main () +main (void) { yyscan_t scanner; FOOlex_init( &scanner); diff --git a/tests/pthread.l b/tests/pthread.l index c40c024..eb99778 100644 --- a/tests/pthread.l +++ b/tests/pthread.l @@ -27,7 +27,7 @@ We create N_THREADS number of threads. Each thread has it's own scanner. Each thread selects one of the files specified in ARGV, scans it, then - closes it. This is repeated N_SCANS numebr of times for each thread. + closes it. This is repeated N_SCANS number of times for each thread. The idea is to press the scanner to break under threads. If we see "Scanner Jammed", then we know @@ -78,30 +78,30 @@ static int process_text(char* s, yyscan_t scanner); <INITIAL,STATE_1,STATE_2>[[:space:]\r\n]+ { } %% -int yywrap( yyscan_t scanner) { +int testwrap( yyscan_t scanner) { (void)scanner; return 1; } static int process_text(char* s, yyscan_t scanner) { (void)scanner; - return (int)(*s) + (int) *(s + yyget_leng(scanner)-1); + return (int)(*s) + (int) *(s + testget_leng(scanner)-1); } int main(int ARGC, char *ARGV[]); -#ifndef HAVE_LIBPTHREAD - int main (int ARGC, char *ARGV[]) { - printf( +#ifndef HAVE_PTHREAD_H +int main (int ARGC, char *ARGV[]) { + puts( "TEST ABORTED because pthread library not available \n" - "-- This is expected on some systems. It is not a flex error.\n" ); - return 0; - } + "-- This is expected on some systems. It is not a flex error."); + /* Exit status for a skipped test */ + return 77; +} #else #define N_THREADS 4 #define N_SCANS 20 -#define INPUT_FILE "test.input" /* Each thread selects the next file to scan in round-robin fashion. If there are less files than threads, some threads may block. */ @@ -114,7 +114,7 @@ static pthread_mutex_t *file_locks; static char **filenames; -void * thread_func ( void* arg ) +static void * thread_func ( void* arg ) { int i; @@ -126,8 +126,6 @@ void * thread_func ( void* arg ) for( i =0 ; i < N_SCANS ; i++ ) { - int main(int ARGC, char *ARGV[]); - int next; yyscan_t scanner; FILE * fp; @@ -138,19 +136,19 @@ void * thread_func ( void* arg ) pthread_mutex_lock ( &file_locks[ next ] ); - yylex_init( &scanner ); + testlex_init( &scanner ); /*printf("Scanning file %s #%d\n",filenames[next],i); fflush(stdout); */ if((fp = fopen(filenames[next],"r"))==NULL) { perror("fopen"); return NULL; } - yyset_in(fp,scanner); + testset_in(fp,scanner); - while( yylex( scanner) != 0) + while( testlex( scanner) != 0) { } fclose(fp); - yylex_destroy(scanner); + testlex_destroy(scanner); pthread_mutex_unlock ( &file_locks[ next ] ); } return NULL; @@ -167,7 +165,7 @@ int main (int ARGC, char *ARGV[]) } /* Allocate and initialize the locks. One for each filename in ARGV. */ - file_locks = malloc((ARGC-1) * sizeof(pthread_mutex_t)); + file_locks = malloc((size_t) (ARGC-1) * sizeof(pthread_mutex_t)); for( i = 0; i < ARGC-1; i++) pthread_mutex_init( &file_locks[i], NULL ); @@ -206,5 +204,5 @@ int main (int ARGC, char *ARGV[]) return 0; } -#endif /* HAVE_LIBPTHREAD */ +#endif /* HAVE_PTHREAD_H */ diff --git a/tests/quote_in_comment.l b/tests/quote_in_comment.l new file mode 100644 index 0000000..a5743c2 --- /dev/null +++ b/tests/quote_in_comment.l @@ -0,0 +1,16 @@ +%option 8bit noyywrap +%% +.|\n { ECHO; + //' " + } +%% +int +main (void) +{ + yyin = stdin; + yyout = stdout; + while (yylex()) + ; + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/quote_in_comment.txt b/tests/quote_in_comment.txt new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/tests/quote_in_comment.txt @@ -0,0 +1 @@ +test diff --git a/tests/quotes.l b/tests/quotes.l index c1386c3..d1b97eb 100644 --- a/tests/quotes.l +++ b/tests/quotes.l @@ -38,6 +38,7 @@ #include <stdio.h> #include <stdlib.h> #include "config.h" +#include <assert.h> /*#include "parser.h" */ /* sect 1 block [ 1 ] TEST_XXX */ @@ -61,6 +62,17 @@ static int foo (int i){ %% + /* indented code [ 1 ] */ + /* indented code [[ 2 ]] */ + /* indented code [[[ 3 ]]] */ + /* indented code [[[[ 4 ]]]] */ + /* indented code ]] unmatched [[ */ +%{ +// non-indented code [ 1 ] +// non-indented code [[ 2 ]] +// non-indented code [[[ 3 ]]] +// non-indented code [[[[ 4 ]]]] +%} a /* action comment [ 1 ] */ ; b /* action comment [[ 2 ]] */ ; @@ -68,13 +80,27 @@ c /* action comment [[[ 3 ]]] */ ; d /* action comment [[[[ 4 ]]]] */ ; e /* action comment ]] unmatched [[ */ ; f return 1+foo(a[b[c[0]]]); -.|\n { +.|\n { + +#if 0 + action code [ 1 ] TEST_XXX + action code [[ 2 ]] TEST_XXX + action code [[[ 3 ]]] TEST_XXX + action code [[[[ 4 ]]]] TEST_XXX + action code ]] unmatched [[ TEST_XXX +#endif /* action block [ 1 ] TEST_XXX */ /* action block [[ 2 ]] TEST_XXX */ /* action block [[[ 3 ]]] TEST_XXX */ /* action block [[[[ 4 ]]]] TEST_XXX */ /* action block ]] unmatched [[ TEST_XXX */ - return 1+foo(a[b[c[0]]]); // TEST_XXX + assert(!strcmp("[[ 2 ]]", "[""[ 2 ]""]")); + assert(!strcmp("[[[ 3 ]]]", "[""[""[ 3 ]""]""]")); + assert(!strcmp("[[[[ 4 ]]]]", "[""[""[""[ 4 ]""]""]""]")); + assert(!strcmp("]] unmatched [[", "]""] unmatched [""[")); + assert(!strcmp("]]m4_define(alpha, beta)[[", + "]""]m4_""define(alpha, beta)[""[")); + return 1+foo(a[b[c[0]]]); /* TEST_XXX */ } %% @@ -88,13 +114,17 @@ static int bar (int i){ } int main(void); +#define CONCAT_IDENTS(a, b) a##b int -main () +main (void) { - yyin = stdin; + /* m4_m4exit(100) */ + FILE *M4_YY_NOT_IN_HEADER = stdin; + yyin = CONCAT_IDENTS(M4_, YY_NOT_IN_HEADER); yyout = stdout; while (yylex()) ; + assert(!strcmp("YY_G( alpha)", "Y""Y_G( alpha)")); printf("TEST RETURNING OK.\n"); return bar(0); } diff --git a/tests/reject.l4 b/tests/reject.l4 index 7eda4a5..9bcde22 100644 --- a/tests/reject.l4 +++ b/tests/reject.l4 @@ -47,7 +47,7 @@ int main ( int argc, char** argv ) M4_YY_DECL_GUTS_VAR(); #ifdef TEST_IS_REENTRANT - yylex_init(&yyscanner); + testlex_init(&yyscanner); #else (void)yyscanner; #endif @@ -67,13 +67,13 @@ int main ( int argc, char** argv ) YY_FATAL_ERROR("could not open input file for reading"); yyin = fp; } - while(yylex(M4_YY_CALL_ONLY_ARG) != 0) + while(testlex(M4_YY_CALL_ONLY_ARG) != 0) ; #ifdef TEST_HAS_TABLES_EXTERNAL - yytables_destroy(M4_YY_CALL_ONLY_ARG); + testtables_destroy(M4_YY_CALL_ONLY_ARG); #endif - yylex_destroy(M4_YY_CALL_ONLY_ARG); + testlex_destroy(M4_YY_CALL_ONLY_ARG); if(argc < 0) /* silence the compiler */ yyscanner = (void*)fp; diff --git a/tests/rescan_nr.direct.l b/tests/rescan_nr.direct.l index 86103aa..536ba78 100644 --- a/tests/rescan_nr.direct.l +++ b/tests/rescan_nr.direct.l @@ -58,14 +58,14 @@ main (int argc, char* const argv[]) return 1; } - yyset_out ( stdout); + testset_out ( stdout); for (i=0; i < 4; ++i){ rewind(fp); - yyset_in ( fp); - while( yylex() ) + testset_in ( fp); + while( testlex() ) ; - yylex_destroy(); + testlex_destroy(); } printf("TEST RETURNING OK.\n"); return 0; diff --git a/tests/rescan_r.direct.l b/tests/rescan_r.direct.l index 2255ee2..ceebc40 100644 --- a/tests/rescan_r.direct.l +++ b/tests/rescan_r.direct.l @@ -60,18 +60,18 @@ main (int argc, char* const argv[]) } printf("Test 1: Reusing same scanner.\n"); - yylex_init( &yyscanner ); - yyset_out ( stdout, yyscanner); + testlex_init( &yyscanner ); + testset_out ( stdout, yyscanner); for (i=0; i < 4; ++i){ rewind(fp); - yyset_in ( fp, yyscanner); + testset_in ( fp, yyscanner); - while( yylex(yyscanner) ) + while( testlex(yyscanner) ) ; } - yylex_destroy( yyscanner ); + testlex_destroy( yyscanner ); printf("Test 1 OK\n\n"); printf("Test 2: Rescanning with new scanner each time.\n"); @@ -80,14 +80,14 @@ main (int argc, char* const argv[]) for (i=0; i < 4; ++i){ yyscan_t s; - yylex_init( &s ); - yyset_out ( stdout, s); + testlex_init( &s ); + testset_out ( stdout, s); rewind(fp); - yyset_in ( fp, s); + testset_in ( fp, s); - while( yylex(s) ) + while( testlex(s) ) ; - yylex_destroy( s ); + testlex_destroy( s ); } printf("Test 2 OK\n\n"); diff --git a/tests/string_nr.l b/tests/string_nr.l index e909b2d..8352b09 100644 --- a/tests/string_nr.l +++ b/tests/string_nr.l @@ -59,37 +59,37 @@ int main(void); int -main () +main (void) { char * buf; - int len; + size_t len; YY_BUFFER_STATE state; /* Scan a good string. */ - printf("Testing: yy_scan_string(%s): ",INPUT_STRING_1); fflush(stdout); - state = yy_scan_string ( INPUT_STRING_1 ); - yylex(); + printf("Testing: test_scan_string(%s): ",INPUT_STRING_1); fflush(stdout); + state = test_scan_string ( INPUT_STRING_1 ); + testlex(); yy_delete_buffer(state); /* Scan only the first 12 chars of a string. */ - printf("Testing: yy_scan_bytes(%s): ",INPUT_STRING_2); fflush(stdout); - state = yy_scan_bytes ( INPUT_STRING_2, 12 ); - yylex(); - yy_delete_buffer(state); + printf("Testing: test_scan_bytes(%s): ",INPUT_STRING_2); fflush(stdout); + state = test_scan_bytes ( INPUT_STRING_2, 12 ); + testlex(); + test_delete_buffer(state); /* Scan directly from a buffer. We make a copy, since the buffer will be modified by flex.*/ - printf("Testing: yy_scan_buffer(%s): ",INPUT_STRING_1); fflush(stdout); + printf("Testing: test_scan_buffer(%s): ",INPUT_STRING_1); fflush(stdout); len = strlen(INPUT_STRING_1) + 2; buf = malloc(len); strcpy( buf, INPUT_STRING_1); buf[ len -2 ] = 0; /* Flex requires two NUL bytes at end of buffer. */ buf[ len -1 ] =0; - state = yy_scan_buffer( buf, len ); - yylex(); - yy_delete_buffer(state); + state = test_scan_buffer( buf, len ); + testlex(); + test_delete_buffer(state); printf("TEST RETURNING OK.\n"); return 0; diff --git a/tests/string_r.l b/tests/string_r.l index 633004a..174eb6c 100644 --- a/tests/string_r.l +++ b/tests/string_r.l @@ -59,44 +59,44 @@ int main(void); int -main () +main (void) { char * buf; - int len; + size_t len; YY_BUFFER_STATE state; yyscan_t scanner=NULL; /* Scan a good string. */ - printf("Testing: yy_scan_string(%s): ",INPUT_STRING_1); fflush(stdout); - yylex_init(&scanner); - state = yy_scan_string ( INPUT_STRING_1 ,scanner); - yylex(scanner); - yy_delete_buffer(state, scanner); - yylex_destroy(scanner); + printf("Testing: test_scan_string(%s): ",INPUT_STRING_1); fflush(stdout); + testlex_init(&scanner); + state = test_scan_string ( INPUT_STRING_1 ,scanner); + testlex(scanner); + test_delete_buffer(state, scanner); + testlex_destroy(scanner); /* Scan only the first 12 chars of a string. */ - printf("Testing: yy_scan_bytes(%s): ",INPUT_STRING_2); fflush(stdout); - yylex_init(&scanner); - state = yy_scan_bytes ( INPUT_STRING_2, 12 ,scanner); - yylex(scanner); - yy_delete_buffer(state,scanner); - yylex_destroy(scanner); + printf("Testing: test_scan_bytes(%s): ",INPUT_STRING_2); fflush(stdout); + testlex_init(&scanner); + state = test_scan_bytes ( INPUT_STRING_2, 12 ,scanner); + testlex(scanner); + test_delete_buffer(state,scanner); + testlex_destroy(scanner); /* Scan directly from a buffer. We make a copy, since the buffer will be modified by flex.*/ - printf("Testing: yy_scan_buffer(%s): ",INPUT_STRING_1); fflush(stdout); + printf("Testing: test_scan_buffer(%s): ",INPUT_STRING_1); fflush(stdout); len = strlen(INPUT_STRING_1) + 2; buf = malloc(len); strcpy( buf, INPUT_STRING_1); buf[ len -2 ] = 0; /* Flex requires two NUL bytes at end of buffer. */ buf[ len -1 ] =0; - yylex_init(&scanner); - state = yy_scan_buffer( buf, len ,scanner); - yylex(scanner); - yy_delete_buffer(state,scanner); - yylex_destroy(scanner); + testlex_init(&scanner); + state = test_scan_buffer( buf, len ,scanner); + testlex(scanner); + test_delete_buffer(state,scanner); + testlex_destroy(scanner); printf("TEST RETURNING OK.\n"); return 0; diff --git a/tests/tableopts.am b/tests/tableopts.am index bbb20d0..099870b 100644 --- a/tests/tableopts.am +++ b/tests/tableopts.am @@ -1,332 +1,332 @@ tableopts_opt_nr_Ca_opt_SOURCES = tableopts.l4 tableopts_opt_nr-Ca.opt$(EXEEXT): tableopts_opt_nr-Ca.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_nr_Ce_opt_SOURCES = tableopts.l4 tableopts_opt_nr-Ce.opt$(EXEEXT): tableopts_opt_nr-Ce.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_nr_Cf_opt_SOURCES = tableopts.l4 tableopts_opt_nr-Cf.opt$(EXEEXT): tableopts_opt_nr-Cf.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_nr_CF_opt_SOURCES = tableopts.l4 tableopts_opt_nr-CF.opt$(EXEEXT): tableopts_opt_nr-CF.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_nr_Cm_opt_SOURCES = tableopts.l4 tableopts_opt_nr-Cm.opt$(EXEEXT): tableopts_opt_nr-Cm.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_nr_Cem_opt_SOURCES = tableopts.l4 tableopts_opt_nr-Cem.opt$(EXEEXT): tableopts_opt_nr-Cem.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_nr_Cae_opt_SOURCES = tableopts.l4 tableopts_opt_nr-Cae.opt$(EXEEXT): tableopts_opt_nr-Cae.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_nr_Caef_opt_SOURCES = tableopts.l4 tableopts_opt_nr-Caef.opt$(EXEEXT): tableopts_opt_nr-Caef.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_nr_CaeF_opt_SOURCES = tableopts.l4 tableopts_opt_nr-CaeF.opt$(EXEEXT): tableopts_opt_nr-CaeF.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_nr_Cam_opt_SOURCES = tableopts.l4 tableopts_opt_nr-Cam.opt$(EXEEXT): tableopts_opt_nr-Cam.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_nr_Caem_opt_SOURCES = tableopts.l4 tableopts_opt_nr-Caem.opt$(EXEEXT): tableopts_opt_nr-Caem.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_r_Ca_opt_SOURCES = tableopts.l4 tableopts_opt_r-Ca.opt$(EXEEXT): tableopts_opt_r-Ca.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_r_Ce_opt_SOURCES = tableopts.l4 tableopts_opt_r-Ce.opt$(EXEEXT): tableopts_opt_r-Ce.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_r_Cf_opt_SOURCES = tableopts.l4 tableopts_opt_r-Cf.opt$(EXEEXT): tableopts_opt_r-Cf.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_r_CF_opt_SOURCES = tableopts.l4 tableopts_opt_r-CF.opt$(EXEEXT): tableopts_opt_r-CF.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_r_Cm_opt_SOURCES = tableopts.l4 tableopts_opt_r-Cm.opt$(EXEEXT): tableopts_opt_r-Cm.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_r_Cem_opt_SOURCES = tableopts.l4 tableopts_opt_r-Cem.opt$(EXEEXT): tableopts_opt_r-Cem.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_r_Cae_opt_SOURCES = tableopts.l4 tableopts_opt_r-Cae.opt$(EXEEXT): tableopts_opt_r-Cae.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_r_Caef_opt_SOURCES = tableopts.l4 tableopts_opt_r-Caef.opt$(EXEEXT): tableopts_opt_r-Caef.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_r_CaeF_opt_SOURCES = tableopts.l4 tableopts_opt_r-CaeF.opt$(EXEEXT): tableopts_opt_r-CaeF.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_r_Cam_opt_SOURCES = tableopts.l4 tableopts_opt_r-Cam.opt$(EXEEXT): tableopts_opt_r-Cam.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_opt_r_Caem_opt_SOURCES = tableopts.l4 tableopts_opt_r-Caem.opt$(EXEEXT): tableopts_opt_r-Caem.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_nr_Ca_ser_SOURCES = tableopts.l4 tableopts_ser_nr-Ca.ser$(EXEEXT): tableopts_ser_nr-Ca.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_nr_Ce_ser_SOURCES = tableopts.l4 tableopts_ser_nr-Ce.ser$(EXEEXT): tableopts_ser_nr-Ce.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_nr_Cf_ser_SOURCES = tableopts.l4 tableopts_ser_nr-Cf.ser$(EXEEXT): tableopts_ser_nr-Cf.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_nr_CF_ser_SOURCES = tableopts.l4 tableopts_ser_nr-CF.ser$(EXEEXT): tableopts_ser_nr-CF.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_nr_Cm_ser_SOURCES = tableopts.l4 tableopts_ser_nr-Cm.ser$(EXEEXT): tableopts_ser_nr-Cm.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_nr_Cem_ser_SOURCES = tableopts.l4 tableopts_ser_nr-Cem.ser$(EXEEXT): tableopts_ser_nr-Cem.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_nr_Cae_ser_SOURCES = tableopts.l4 tableopts_ser_nr-Cae.ser$(EXEEXT): tableopts_ser_nr-Cae.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_nr_Caef_ser_SOURCES = tableopts.l4 tableopts_ser_nr-Caef.ser$(EXEEXT): tableopts_ser_nr-Caef.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_nr_CaeF_ser_SOURCES = tableopts.l4 tableopts_ser_nr-CaeF.ser$(EXEEXT): tableopts_ser_nr-CaeF.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_nr_Cam_ser_SOURCES = tableopts.l4 tableopts_ser_nr-Cam.ser$(EXEEXT): tableopts_ser_nr-Cam.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_nr_Caem_ser_SOURCES = tableopts.l4 tableopts_ser_nr-Caem.ser$(EXEEXT): tableopts_ser_nr-Caem.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_r_Ca_ser_SOURCES = tableopts.l4 tableopts_ser_r-Ca.ser$(EXEEXT): tableopts_ser_r-Ca.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_r_Ce_ser_SOURCES = tableopts.l4 tableopts_ser_r-Ce.ser$(EXEEXT): tableopts_ser_r-Ce.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_r_Cf_ser_SOURCES = tableopts.l4 tableopts_ser_r-Cf.ser$(EXEEXT): tableopts_ser_r-Cf.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_r_CF_ser_SOURCES = tableopts.l4 tableopts_ser_r-CF.ser$(EXEEXT): tableopts_ser_r-CF.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_r_Cm_ser_SOURCES = tableopts.l4 tableopts_ser_r-Cm.ser$(EXEEXT): tableopts_ser_r-Cm.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_r_Cem_ser_SOURCES = tableopts.l4 tableopts_ser_r-Cem.ser$(EXEEXT): tableopts_ser_r-Cem.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_r_Cae_ser_SOURCES = tableopts.l4 tableopts_ser_r-Cae.ser$(EXEEXT): tableopts_ser_r-Cae.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_r_Caef_ser_SOURCES = tableopts.l4 tableopts_ser_r-Caef.ser$(EXEEXT): tableopts_ser_r-Caef.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_r_CaeF_ser_SOURCES = tableopts.l4 tableopts_ser_r-CaeF.ser$(EXEEXT): tableopts_ser_r-CaeF.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_r_Cam_ser_SOURCES = tableopts.l4 tableopts_ser_r-Cam.ser$(EXEEXT): tableopts_ser_r-Cam.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ser_r_Caem_ser_SOURCES = tableopts.l4 tableopts_ser_r-Caem.ser$(EXEEXT): tableopts_ser_r-Caem.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_nr_Ca_ver_SOURCES = tableopts.l4 tableopts_ver_nr-Ca.ver$(EXEEXT): tableopts_ver_nr-Ca.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_nr_Ce_ver_SOURCES = tableopts.l4 tableopts_ver_nr-Ce.ver$(EXEEXT): tableopts_ver_nr-Ce.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_nr_Cf_ver_SOURCES = tableopts.l4 tableopts_ver_nr-Cf.ver$(EXEEXT): tableopts_ver_nr-Cf.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_nr_CF_ver_SOURCES = tableopts.l4 tableopts_ver_nr-CF.ver$(EXEEXT): tableopts_ver_nr-CF.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_nr_Cm_ver_SOURCES = tableopts.l4 tableopts_ver_nr-Cm.ver$(EXEEXT): tableopts_ver_nr-Cm.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_nr_Cem_ver_SOURCES = tableopts.l4 tableopts_ver_nr-Cem.ver$(EXEEXT): tableopts_ver_nr-Cem.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_nr_Cae_ver_SOURCES = tableopts.l4 tableopts_ver_nr-Cae.ver$(EXEEXT): tableopts_ver_nr-Cae.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_nr_Caef_ver_SOURCES = tableopts.l4 tableopts_ver_nr-Caef.ver$(EXEEXT): tableopts_ver_nr-Caef.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_nr_CaeF_ver_SOURCES = tableopts.l4 tableopts_ver_nr-CaeF.ver$(EXEEXT): tableopts_ver_nr-CaeF.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_nr_Cam_ver_SOURCES = tableopts.l4 tableopts_ver_nr-Cam.ver$(EXEEXT): tableopts_ver_nr-Cam.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_nr_Caem_ver_SOURCES = tableopts.l4 tableopts_ver_nr-Caem.ver$(EXEEXT): tableopts_ver_nr-Caem.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_r_Ca_ver_SOURCES = tableopts.l4 tableopts_ver_r-Ca.ver$(EXEEXT): tableopts_ver_r-Ca.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_r_Ce_ver_SOURCES = tableopts.l4 tableopts_ver_r-Ce.ver$(EXEEXT): tableopts_ver_r-Ce.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_r_Cf_ver_SOURCES = tableopts.l4 tableopts_ver_r-Cf.ver$(EXEEXT): tableopts_ver_r-Cf.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_r_CF_ver_SOURCES = tableopts.l4 tableopts_ver_r-CF.ver$(EXEEXT): tableopts_ver_r-CF.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_r_Cm_ver_SOURCES = tableopts.l4 tableopts_ver_r-Cm.ver$(EXEEXT): tableopts_ver_r-Cm.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_r_Cem_ver_SOURCES = tableopts.l4 tableopts_ver_r-Cem.ver$(EXEEXT): tableopts_ver_r-Cem.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_r_Cae_ver_SOURCES = tableopts.l4 tableopts_ver_r-Cae.ver$(EXEEXT): tableopts_ver_r-Cae.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_r_Caef_ver_SOURCES = tableopts.l4 tableopts_ver_r-Caef.ver$(EXEEXT): tableopts_ver_r-Caef.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_r_CaeF_ver_SOURCES = tableopts.l4 tableopts_ver_r-CaeF.ver$(EXEEXT): tableopts_ver_r-CaeF.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_r_Cam_ver_SOURCES = tableopts.l4 tableopts_ver_r-Cam.ver$(EXEEXT): tableopts_ver_r-Cam.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< tableopts_ver_r_Caem_ver_SOURCES = tableopts.l4 tableopts_ver_r-Caem.ver$(EXEEXT): tableopts_ver_r-Caem.$(OBJEXT) - $(LINK) -o $@ $< + $(AM_V_CCLD)$(LINK) -o $@ $< TABLEOPTS_TESTS = tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaeF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaeF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaeF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaeF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaeF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaeF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver diff --git a/tests/tableopts.sh b/tests/tableopts.sh index 63a36d3..c1ac19e 100755 --- a/tests/tableopts.sh +++ b/tests/tableopts.sh @@ -1,12 +1,15 @@ -#!/bin/bash -set -euo pipefail -IFS=$'\n\t' +#!/bin/sh +set -eu +# IFS=$'\n\t' +IFS=' +'' ' # This script is present to generate the automake _SOURCES variables # for the tableopts_* tests. It also generates the linking rules for # each test since automake isn't able to handle the pattern rules that # would be natural to use. Output is written to standard output for -# inclusion in a Makefile.am, typically by redirecting the output and then an automake include directive. +# inclusion in a Makefile.am, typically by redirecting the output and +# then an automake include directive. TABLEOPTS_TESTS="" tableopts_tables="" @@ -17,12 +20,12 @@ for kind in opt ser ver ; do testname=tableopts_${kind}_${threading}${opt}.${kind} if [ "${TABLEOPTS_TESTS}" = "" ] ;then TABLEOPTS_TESTS=${testname} - if [ "$kind" = "ser" -o "$kind" = "ver" ] ; then + if [ "$kind" = "ser" ] || [ "$kind" = "ver" ] ; then tableopts_tables=${testname}.tables fi else TABLEOPTS_TESTS="${TABLEOPTS_TESTS} ${testname}" - if [ "$kind" = "ser" -o "$kind" = "ver" ] ; then + if [ "$kind" = "ser" ] || [ "$kind" = "ver" ] ; then tableopts_tables="${tableopts_tables} ${testname}.tables" fi fi @@ -32,7 +35,7 @@ for kind in opt ser ver ; do tableopts_${kind}_${threading}_${bare_opt}_${kind}_SOURCES = tableopts.l4 ${testname}\$(EXEEXT): tableopts_${kind}_${threading}${opt}.\$(OBJEXT) - \$(LINK) -o \$@ \$< + \$(AM_V_CCLD)\$(LINK) -o \$@ \$< EOF done diff --git a/tests/testwrapper-direct.sh b/tests/testwrapper-direct.sh new file mode 100755 index 0000000..589ad33 --- /dev/null +++ b/tests/testwrapper-direct.sh @@ -0,0 +1,20 @@ +#!/bin/sh +set -vx +set -euvx + +# testwrapper-direct.sh: run some specialized flex tests that care where +# they're run from. + +while getopts :b:s: OPTION ; do + case $OPTION in + b) BINARY_DIR=$OPTARG ;; + s) SOURCE_DIR=$OPTARG ;; + esac + done + +shift $(($OPTIND-1)) +TESTNAME=$1 + +INPUT_NAME=`basename "${TESTNAME%.exe}"`.txt + +cd ${SOURCE_DIR} && ${BINARY_DIR}/${TESTNAME} ${INPUT_NAME} diff --git a/tests/testwrapper.sh b/tests/testwrapper.sh index 051e20b..6a7e666 100755 --- a/tests/testwrapper.sh +++ b/tests/testwrapper.sh @@ -1,9 +1,11 @@ -#!/bin/bash -vx -set -euo pipefail +#!/bin/sh +set -vx +set -euvx # testwrapper.sh: run a flex test, typically called by a Makefile -# Each test will exercise some feature or aspect of flex. Run the test with any input it may need. +# Each test will exercise some feature or aspect of flex. Run the test with any +# input it may need. INPUT_DIRECTORY="" INPUT_NAME="" @@ -15,7 +17,7 @@ while getopts :d:i:rt1 OPTION ; do case $OPTION in d) INPUT_DIRECTORY=$OPTARG ;; i) - if [ "$INPUT_NAME" == "" ] ; then + if [ "$INPUT_NAME" = "" ] ; then INPUT_NAME="$OPTARG" else INPUT_NAME="$INPUT_NAME $OPTARG" @@ -26,27 +28,30 @@ while getopts :d:i:rt1 OPTION ; do t) USE_TABLES=1 ;; 1) DO_COMPARISON=1 ;; esac - done +done -TESTNAME="${!OPTIND}" +shift $(($OPTIND-1)) +TESTNAME=$1 -INPUT_NAME=${INPUT_NAME:-$INPUT_DIRECTORY/`basename $TESTNAME`.txt} +INPUT_NAME=${INPUT_NAME:-$INPUT_DIRECTORY/`basename "${TESTNAME%.exe}"`.txt} -if [ "$DO_COMPARISON" -eq "1" ] ; then - test `$TESTNAME 1 < $INPUT_NAME` -eq `$TESTNAME < $INPUT_NAME` +if [ $DO_COMPARISON = 1 ] ; then + TEST_OUTPUT=`$TESTNAME < $INPUT_NAME` + REF_OUTPUT=`$TESTNAME 1 < $INPUT_NAME` + test "$TEST_OUTPUT" -eq "$REF_OUTPUT" exit $? - fi +fi if [ $INPUT_COUNT -gt 1 ] ; then - $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME}.tables} ${INPUT_NAME} + $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} ${INPUT_NAME} exit $? - fi +fi if [ -f ${INPUT_NAME} ] ; then - if [ $USE_REDIRECT == 1 ] ; then - $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME}.tables} < $INPUT_NAME + if [ $USE_REDIRECT = 1 ] ; then + $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} < $INPUT_NAME else - $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME}.tables} $INPUT_NAME + $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} $INPUT_NAME fi else $TESTNAME diff --git a/tests/yyextra.l b/tests/yyextra.l index 8957cbb..bf2a6eb 100644 --- a/tests/yyextra.l +++ b/tests/yyextra.l @@ -62,7 +62,7 @@ static void append_char (char c, yyscan_t scanner ); int main(void); int -main () +main (void) { yyscan_t scanner; struct Buffer * buf; @@ -72,7 +72,7 @@ main () buf->curr_len =0; buf->max_len = 4; buf->grow_len = 100; - buf->data = malloc(buf->max_len); + buf->data = malloc((size_t) buf->max_len); testlex_init(&scanner); testset_in( stdin, scanner); @@ -103,7 +103,7 @@ static void append_char (char c, yyscan_t scanner ) new_buf = malloc(sizeof(struct Buffer)); new_buf->max_len = buf->max_len + buf->grow_len; new_buf->grow_len = buf->grow_len; - new_buf->data = malloc(new_buf->max_len); + new_buf->data = malloc((size_t) new_buf->max_len); for( new_buf->curr_len = 0; new_buf->curr_len < buf->curr_len; new_buf->curr_len++ ) |