From 323c11e8aef18a09aa40d11a4fabf6b8c787d782 Mon Sep 17 00:00:00 2001 From: Will Estes Date: Sun, 15 Jun 2014 19:23:53 -0400 Subject: refactor multiple_scanners_nr test for new test suite layout --- tests/.gitignore | 2 ++ tests/Makefile.am | 10 ++++++ tests/multiple_scanners_nr_1.l | 50 ++++++++++++++++++++++++++ tests/multiple_scanners_nr_2.l | 49 ++++++++++++++++++++++++++ tests/multiple_scanners_nr_main.c | 51 +++++++++++++++++++++++++++ tests/test-multiple-scanners-nr/.gitignore | 8 ----- tests/test-multiple-scanners-nr/Makefile.am | 54 ----------------------------- tests/test-multiple-scanners-nr/main.c | 51 --------------------------- tests/test-multiple-scanners-nr/scanner-1.l | 50 -------------------------- tests/test-multiple-scanners-nr/scanner-2.l | 49 -------------------------- 10 files changed, 162 insertions(+), 212 deletions(-) create mode 100644 tests/multiple_scanners_nr_1.l create mode 100644 tests/multiple_scanners_nr_2.l create mode 100644 tests/multiple_scanners_nr_main.c delete mode 100644 tests/test-multiple-scanners-nr/.gitignore delete mode 100644 tests/test-multiple-scanners-nr/Makefile.am delete mode 100644 tests/test-multiple-scanners-nr/main.c delete mode 100644 tests/test-multiple-scanners-nr/scanner-1.l delete mode 100644 tests/test-multiple-scanners-nr/scanner-2.l diff --git a/tests/.gitignore b/tests/.gitignore index bd9304c..78d46c2 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -44,6 +44,8 @@ mem_nr mem_nr.c mem_r mem_r.c +multiple_scanners_nr +multiple_scanners_nr_[12].[ch] noansi_nr noansi_nr.c noansi_r diff --git a/tests/Makefile.am b/tests/Makefile.am index d22d5a2..d785e0a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -47,6 +47,7 @@ check_PROGRAMS = \ header_r \ mem_nr \ mem_r \ + multiple_scanners_nr \ noansi_nr \ noansi_r \ posix \ @@ -78,6 +79,7 @@ header_nr_SOURCES = header_nr_scanner.l header_nr_main.c header_r_SOURCES = header_r_scanner.l header_r_main.c 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 noansi_nr_SOURCES = noansi_nr.l noansi_r_SOURCES = noansi_r.l posix_SOURCES = posix.l @@ -100,6 +102,8 @@ BUILT_SOURCES = \ c_cxx_r.cc \ header_nr_scanner.h \ header_r_scanner.h \ + multiple_scanners_nr_1.h \ + multiple_scanners_nr_2.h \ top.h EXTRA_DIST = \ @@ -133,6 +137,8 @@ basic_nr.txt \ mem_nr.txt \ mem_r.txt \ noansi_nr.txt \ + multiple_scanners_nr_1.h \ + multiple_scanners_nr_2.h \ noansi_r.txt \ prefix_nr.txt \ prefix_r.txt \ @@ -171,6 +177,10 @@ header_nr_scanner.h: header_nr_scanner.c header_r_main$(objext): header_r_scanner.h header_r_scanner.h: header_r_scanner.c +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 +multiple_scanners_nr_2.h: multiple_scanners_nr_2.c + posixly_correct.c: posixly_correct.l POSIXLY_CORRECT=1 $(FLEX) -o $@ $< diff --git a/tests/multiple_scanners_nr_1.l b/tests/multiple_scanners_nr_1.l new file mode 100644 index 0000000..5e848c2 --- /dev/null +++ b/tests/multiple_scanners_nr_1.l @@ -0,0 +1,50 @@ +/* + * 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 template scanner file to build "scanner-1.c" and "scanner-1.h". */ +#include +#include +#include "config.h" + +%} + +%option header="multiple_scanners_nr_1.h" +%option 8bit prefix="S1_" +%option nounput nomain noyywrap +%option warn stack noyy_top_state + +%x ON +%x OFF +%% +{ +on yy_push_state(ON); return 10; +off yy_push_state(OFF); return 11; +.|\n return 12; +} +.|\n yy_pop_state(); return 13; + +.|\n yy_pop_state(); return 14; + +%% + diff --git a/tests/multiple_scanners_nr_2.l b/tests/multiple_scanners_nr_2.l new file mode 100644 index 0000000..5a9ac99 --- /dev/null +++ b/tests/multiple_scanners_nr_2.l @@ -0,0 +1,49 @@ +/* + * 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 template scanner file to build "scanner-2.c" and "scanner-2.h". */ +#include +#include +#include "config.h" + +%} + +%option header="multiple_scanners_nr_2.h" +%option 8bit prefix="S2_" +%option nounput nomain noyywrap +%option warn stack noyy_top_state + +%x OFF +%x ON +%% +{ +on yy_push_state(ON); return 3; +off yy_push_state(OFF); return 4; +.|\n return 5; +} +.|\n yy_pop_state(); return 6; + +.|\n yy_pop_state(); return 7; +%% + diff --git a/tests/multiple_scanners_nr_main.c b/tests/multiple_scanners_nr_main.c new file mode 100644 index 0000000..3763dbc --- /dev/null +++ b/tests/multiple_scanners_nr_main.c @@ -0,0 +1,51 @@ +/* + * 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 "multiple_scanners_nr_1.h" +#include "multiple_scanners_nr_2.h" + +int +main ( int argc, char** argv ) +{ + int S1_ok=1, S2_ok=1; + YY_BUFFER_STATE buff1, buff2; + S1_out = S2_out = stdout; + buff1 = S1__scan_string("foo on bar off"); + buff2 = S2__scan_string("on blah blah off foo on bar off"); + + /* scan simultaneously. */ + while(S1_ok || S2_ok) + { + if (S1_ok) + S1_ok = S1_lex(); + if (S2_ok) + S2_ok = S2_lex(); + } + S1__delete_buffer(buff1); + S2__delete_buffer(buff2); + printf("TEST RETURNING OK.\n"); + return 0; +} + + +/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */ diff --git a/tests/test-multiple-scanners-nr/.gitignore b/tests/test-multiple-scanners-nr/.gitignore deleted file mode 100644 index dfd4b07..0000000 --- a/tests/test-multiple-scanners-nr/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -Makefile -Makefile.in -scanner-1.c -scanner-1.h -scanner-2.c -scanner-2.h -test-multiple-scanners-nr -OUTPUT diff --git a/tests/test-multiple-scanners-nr/Makefile.am b/tests/test-multiple-scanners-nr/Makefile.am deleted file mode 100644 index 950dd23..0000000 --- a/tests/test-multiple-scanners-nr/Makefile.am +++ /dev/null @@ -1,54 +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. - - -FLEX = $(top_builddir)/flex - -builddir = @builddir@ - -EXTRA_DIST = scanner-1.l scanner-2.l main.c -CLEANFILES = scanner-1.c scanner-1.h $(testname)$(EXEEXT) OUTPUT $(OBJS) scanner-2.c scanner-2.h -OBJS = scanner-1.o scanner-2.o main.o - -AM_CPPFLAGS = -I$(srcdir) -I$(top_srcdir) -I$(top_builddir) -I$(builddir) -#LDFLAGS = $(top_srcdir)/libfl.a -#YFLAGS = --defines --output=parser.c - -testname = test-multiple-scanners-nr - -scanner-1.c: $(srcdir)/scanner-1.l - $(FLEX) $(LFLAGS) --header=scanner-1.h $< - -scanner-2.c: $(srcdir)/scanner-2.l - $(FLEX) $(LFLAGS) --header=scanner-2.h $< - -$(testname)$(EXEEXT): $(OBJS) - $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(OBJS) $(LOADLIBES) - -test: $(testname)$(EXEEXT) - ./$(testname)$(EXEEXT) - -.c.o: - $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) $(CFLAGS) $< - -main.o: scanner-1.h scanner-2.h -scanner-1.h: scanner-1.c -scanner-2.h: scanner-2.c diff --git a/tests/test-multiple-scanners-nr/main.c b/tests/test-multiple-scanners-nr/main.c deleted file mode 100644 index a83bec6..0000000 --- a/tests/test-multiple-scanners-nr/main.c +++ /dev/null @@ -1,51 +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. - */ - -#include "scanner-1.h" -#include "scanner-2.h" - -int -main ( int argc, char** argv ) -{ - int S1_ok=1, S2_ok=1; - YY_BUFFER_STATE buff1, buff2; - S1_out = S2_out = stdout; - buff1 = S1__scan_string("foo on bar off"); - buff2 = S2__scan_string("on blah blah off foo on bar off"); - - /* scan simultaneously. */ - while(S1_ok || S2_ok) - { - if (S1_ok) - S1_ok = S1_lex(); - if (S2_ok) - S2_ok = S2_lex(); - } - S1__delete_buffer(buff1); - S2__delete_buffer(buff2); - printf("TEST RETURNING OK.\n"); - return 0; -} - - -/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */ diff --git a/tests/test-multiple-scanners-nr/scanner-1.l b/tests/test-multiple-scanners-nr/scanner-1.l deleted file mode 100644 index 0d520b1..0000000 --- a/tests/test-multiple-scanners-nr/scanner-1.l +++ /dev/null @@ -1,50 +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 template scanner file to build "scanner-1.c" and "scanner-1.h". */ -#include -#include -#include "config.h" - -%} - -%option header="scanner-1.h" -%option 8bit outfile="scanner-1.c" prefix="S1_" -%option nounput nomain noyywrap -%option warn stack noyy_top_state - -%x ON -%x OFF -%% -{ -on yy_push_state(ON); return 10; -off yy_push_state(OFF); return 11; -.|\n return 12; -} -.|\n yy_pop_state(); return 13; - -.|\n yy_pop_state(); return 14; - -%% - diff --git a/tests/test-multiple-scanners-nr/scanner-2.l b/tests/test-multiple-scanners-nr/scanner-2.l deleted file mode 100644 index 88bd799..0000000 --- a/tests/test-multiple-scanners-nr/scanner-2.l +++ /dev/null @@ -1,49 +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 template scanner file to build "scanner-2.c" and "scanner-2.h". */ -#include -#include -#include "config.h" - -%} - -%option header="scanner-2.h" -%option 8bit outfile="scanner-2.c" prefix="S2_" -%option nounput nomain noyywrap -%option warn stack noyy_top_state - -%x OFF -%x ON -%% -{ -on yy_push_state(ON); return 3; -off yy_push_state(OFF); return 4; -.|\n return 5; -} -.|\n yy_pop_state(); return 6; - -.|\n yy_pop_state(); return 7; -%% - -- cgit v1.2.3