]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
lex tests: avoid possible hang; fix and extend
authorStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 1 Jun 2011 15:43:44 +0000 (17:43 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 1 Jun 2011 16:53:52 +0000 (18:53 +0200)
* tests/lex3.test (foo.l:yywrap): Return 1, not 0, to avoid hangs.
Bug introduced in commit 'v1.11-871-geb147a1'.
(Makefile.am): Do not add `@LEXLIB@' to `$(LDADD)', as we define
our own `yywrap' function.
* tests/lex.test (tscan.l): In `yywrap', return 1, not 0, for
consistency with the default flex implementation.
* tests/lex-libobj.test (yywrap.c): Likewise.
* tests/lex-subobj-nodep.test (s1.l): Likewise.
* tests/lexvpath.test (foo.c): Likewise.
* tests/silent-lex-gcc (foo.l): Likewise.
* tests/silent-lex-generic (foo.l): Likewise.
* tests/silent-many-gcc (foo5.l): Likewise.
* tests/silent-many-generic (foo5.l): Likewise.
* tests/lex-lib.test (mu.c): Likewise.
Update heading comments, to refer to ...
* tests/lex-lib-external.test: ... this new test, which checks
that we can get use the `yywrap' function from a system-wide
library, if that's available.

14 files changed:
ChangeLog
tests/Makefile.am
tests/Makefile.in
tests/cond35.test
tests/lex-lib-external.test [new file with mode: 0755]
tests/lex-lib.test
tests/lex-libobj.test
tests/lex-subobj-nodep.test
tests/lex3.test
tests/lexvpath.test
tests/silent-lex-gcc.test
tests/silent-lex-generic.test
tests/silent-many-gcc.test
tests/silent-many-generic.test

index cc9dd2ebef4e1eecb5b1cbde8ab32e214b680729..51567aaaf3ba34ced56e844c4546a47f8e912393 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2011-06-01  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       lex tests: avoid possible hang; fix and extend
+       * tests/lex3.test (foo.l:yywrap): Return 1, not 0, to avoid hangs.
+       Bug introduced in commit 'v1.11-871-geb147a1'.
+       (Makefile.am): Do not add `@LEXLIB@' to `$(LDADD)', as we define
+       our own `yywrap' function.
+       * tests/lex.test (tscan.l): In `yywrap', return 1, not 0, for
+       consistency with the default flex implementation.
+       * tests/lex-libobj.test (yywrap.c): Likewise.
+       * tests/lex-subobj-nodep.test (s1.l): Likewise.
+       * tests/lexvpath.test (foo.c): Likewise.
+       * tests/silent-lex-gcc (foo.l): Likewise.
+       * tests/silent-lex-generic (foo.l): Likewise.
+       * tests/silent-many-gcc (foo5.l): Likewise.
+       * tests/silent-many-generic (foo5.l): Likewise.
+       * tests/lex-lib.test (mu.c): Likewise.
+       Update heading comments, to refer to ...
+       * tests/lex-lib-external.test: ... this new test, which checks
+       that we can get use the `yywrap' function from a system-wide
+       library, if that's available.
+
 2011-06-01  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        tests: prefer `skip_' over `echo ...; Exit 77'
index 0bb993aa97c907f05ff404598d1e609f8049cdb1..02a99b6f0ff54a31a011a4e16a84c855d467e2f0 100644 (file)
@@ -558,6 +558,7 @@ lexcpp.test \
 lexvpath.test \
 lex-subobj-nodep.test \
 lex-lib.test \
+lex-lib-external.test \
 lex-libobj.test \
 lex-noyywrap.test \
 lflags.test \
index 875b06ed96d1c2a90ed9a318b5444b2f53987d5a..4e4d4a95336db5782633ef51da220423bb8e4585 100644 (file)
@@ -846,6 +846,7 @@ lexcpp.test \
 lexvpath.test \
 lex-subobj-nodep.test \
 lex-lib.test \
+lex-lib-external.test \
 lex-libobj.test \
 lex-noyywrap.test \
 lflags.test \
index 143c082bd465654cb8b04d7a132289620e075980..f2b0ded71f0fb05b31603d76c7efccd8a4f8a0bb 100755 (executable)
@@ -64,7 +64,7 @@ cat > tscan.l << 'END'
 /* Avoid possible link errors. */
 int yywrap (void)
 {
-  return 0;
+  return 1;
 }
 END
 
diff --git a/tests/lex-lib-external.test b/tests/lex-lib-external.test
new file mode 100755 (executable)
index 0000000..5f04594
--- /dev/null
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that we can get use the `yywrap' function from a system-wide
+# library, if that's available.
+
+required='cc lex'
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = lexer
+lexer_SOURCES = foo.l
+lexer_LDADD = $(LEXLIB)
+
+.PHONY: have-lexlib
+have-lexlib:
+       test x'$(LEXLIB)' != x
+       echo 'int main (void) { return yywrap (); }' > x.c
+       $(CC) -c x.c
+       $(CC) x.$(OBJEXT) $(LEXLIB)
+       rm -f x.c *.$(OBJEXT) *.o *.out *.exe
+END
+
+cat > foo.l <<'END'
+%%
+"GOOD"   return EOF;
+.
+%%
+int main (void)
+{
+  /* We don't use a 'while' loop here (like a real lexer would do)
+     to avoid possible hangs. */
+  if (yylex () == EOF)
+    return 0;
+  else
+    return 1;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE have-lexlib || skip_ "no system-wide lex library found"
+
+# Program should build and run and distribute.
+$MAKE all
+if cross_compiling; then :; else
+  echo GOOD | ./lexer
+  echo BAD | ./lexer && Exit 1
+fi
+$MAKE distcheck
+
+:
index 07af3ff19bac876ecab58fc645a03e08ba1e97b9..e5fdc00b5e039e0fe1e6d4df48e979f86caf7614 100755 (executable)
@@ -17,6 +17,7 @@
 
 # Check that we can provide a personal `yywrap' function in a custom
 # library.
+# See also test `lex-lib-external.test'.
 
 required='cc lex'
 . ./defs || Exit 1
@@ -41,7 +42,7 @@ END
 cat > mu.c << 'END'
 int yywrap (void)
 {
-  return 0;
+  return 1;
 }
 END
 
index 1ca1d4c9b67e11047e7a100e3a6e2494d08363b1..449bd474bbb22f71c7d1b4a4ce7c076fc8b72857 100755 (executable)
@@ -41,7 +41,7 @@ END
 cat > yywrap.c << 'END'
 int yywrap (void)
 {
-  return 0;
+  return 1;
 }
 END
 
@@ -64,7 +64,7 @@ grep LIBOBJS Makefile # For debugging.
 $MAKE
 $MAKE distclean
 
-# Force no "system lex library".
+# Force "no system lex library".
 ./configure LEXLIB='-L /lib'
 grep LIBOBJS Makefile # For debugging.
 grep '^LIBOBJS *=.*yywrap.*\.o' Makefile # Sanity check.
index 322ae96e3232757f040d643b2b8dc554a7542749..5db71685105f320f7ed26a41ba118ebe3986d04a 100755 (executable)
@@ -51,7 +51,7 @@ int main (void)
 
 int yywrap(void)
 {
-  return 0;
+  return 1;
 }
 END
 
index 9c2f5b49207eb68edadd95cb5420f4257e8a41ee..ae79796b4bad7a53a46ece1f3812d17eea658554 100755 (executable)
@@ -29,9 +29,8 @@ AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
-LDADD             = @LEXLIB@
-noinst_PROGRAMS   = foo
-foo_SOURCES       = foo.l
+noinst_PROGRAMS = foo
+foo_SOURCES = foo.l
 END
 
 cat > foo.l << 'END'
@@ -53,7 +52,7 @@ int main (void)
 /* Avoid possible link errors. */
 int yywrap (void)
 {
-  return 0;
+  return 1;
 }
 END
 
index 93902b30365ae5c55c2d283bebc66068583a4346..2f542568b07372afeaa9ea7198e50b07c9cbffa6 100755 (executable)
@@ -59,7 +59,7 @@ int main (void)
 /* Avoid possible link errors. */
 int yywrap (void)
 {
-  return 0;
+  return 1;
 }
 END
 
index 2a691c3142605f6cd7cb70a72e395caa0e633576..e01fd72ac87135880b67b29b9123f2b9a097c1f1 100755 (executable)
@@ -58,7 +58,7 @@ cat > foo.l <<'EOF'
 /* Avoid possible link errors. */
 int yywrap (void)
 {
-  return 0;
+  return 1;
 }
 int main (void)
 {
index bc3ffffae37366e158cd70d5be896aeed84bdcc0..7d2b197dbac3718d60356e221bcd35cc82e25149 100755 (executable)
@@ -58,7 +58,7 @@ cat > foo.l <<'EOF'
 /* Avoid possible link errors. */
 int yywrap (void)
 {
-  return 0;
+  return 1;
 }
 int main (void)
 {
index 8cdb35b9fc492e71a0101db5791f400d8c506551..b2d41749142e9719da551c36138cbcba4ade33dc 100755 (executable)
@@ -161,7 +161,7 @@ cat > foo5.l <<'EOF'
 /* Avoid possible link errors. */
 int yywrap (void)
 {
-  return 0;
+  return 1;
 }
 EOF
 cat > foo6.y <<'EOF'
index 7d615acb57c6180c7b9d70f1ca63bb92c6214663..17dea2cfc92b51ae610119274af43cf7dd7f6d56 100755 (executable)
@@ -162,7 +162,7 @@ cat > foo5.l <<'EOF'
 /* Avoid possible link errors. */
 int yywrap (void)
 {
-  return 0;
+  return 1;
 }
 EOF
 cat > foo6.y <<'EOF'