From: Stefano Lattarini Date: Sun, 12 Feb 2012 15:37:44 +0000 (+0100) Subject: tests: fix spurious failures due to missing 'yywrap()' function X-Git-Tag: v1.11b~118^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b34421dc2d78a163ce9eaca41348dd672c302ed;p=thirdparty%2Fautomake.git tests: fix spurious failures due to missing 'yywrap()' function The AC_PROG_LEX Autoconf macro does not diagnose a failure to find the "lex library" expected to provide a 'yywrap' function (function which is required to link most lex-generated programs). On the contrary, when all the link attempts (i.e., with '-ll' and '-lfl') fail, configure declares that no lex library is needed, and simply proceeds with the configuration process -- only for the build to possibly fail later, at make time. This behaviour is intended; the Autoconf manual reads: You are encouraged to use Flex in your sources, since it is both more pleasant to use than plain Lex and the C source it produces is portable. In order to ensure portability, however, you must either provide a function 'yywrap' or, if you don't use it (e.g., your scanner has no '#include'-like feature), simply include a '%noyywrap' statement in the scanner's source. This AC_PROG_LEX behaviour is causing some spurious failures of the Automake testsuite in environments which lack a proper library providing 'yywrap' (this happens for example on Fedora-based systems). The proper workaround is to simply provide a fall-back implementation of 'yywrap' in our lexers. See also similar commits 'v1.11-546-gca0ba5d' (24-10-2011), 'v1.11-1085-gb5c3968' (24-10-2011) and 'v1.11-871-geb147a1' (25-05-2011). * tests/lex-clean.test: Provide a dummy 'yywrap' function. * tests/lex-line.test: Likewise. * tests/lex-nodist.test: Likewise. * tests/lex-depend.test: Likewise. * tests/lex-clean-cxx.test: Move the dummy 'yywrap' function from the main '.cc' file into the '.lxx' file, so that it won't be subject to the namespace declaration in the '.cc' file (which was causing a spurious link error in systems without a default "lex library"). --- diff --git a/tests/lex-clean-cxx.test b/tests/lex-clean-cxx.test index ba7e36708..6ca807138 100755 --- a/tests/lex-clean-cxx.test +++ b/tests/lex-clean-cxx.test @@ -58,16 +58,17 @@ cat > parsefoo.lxx << 'END' %% "GOOD" return EOF; . +%% +int yywrap (void) +{ + return 1; +} END cp parsefoo.lxx parsebar.ll cat > mainfoo.cc << 'END' // This file should contain valid C++ but invalid C. using namespace std; -int yywrap (void) -{ - return 1; -} int main (int argc, char **argv) { extern int yylex (void); diff --git a/tests/lex-clean.test b/tests/lex-clean.test index 5bcb5c177..6f038871e 100755 --- a/tests/lex-clean.test +++ b/tests/lex-clean.test @@ -64,6 +64,12 @@ int main (void) { return yylex (); } + +/* Avoid possible link errors. */ +int yywrap (void) +{ + return 1; +} END $ACLOCAL diff --git a/tests/lex-depend.test b/tests/lex-depend.test index 13d5554df..2ef27dadf 100755 --- a/tests/lex-depend.test +++ b/tests/lex-depend.test @@ -55,6 +55,11 @@ int main (void) printf("%s\n", MESSAGE); return 0; } +/* Avoid possible link errors. */ +int yywrap (void) +{ + return 1; +} END cat > my-hdr.h <<'END' diff --git a/tests/lex-line.test b/tests/lex-line.test index 27958c895..a7e164074 100755 --- a/tests/lex-line.test +++ b/tests/lex-line.test @@ -70,6 +70,12 @@ int main () ; return 0; } + +/* Avoid possible link errors. */ +int yywrap (void) +{ + return 1; +} END cp zardoz.l dir/quux.l diff --git a/tests/lex-nodist.test b/tests/lex-nodist.test index 5948400ea..092e08960 100755 --- a/tests/lex-nodist.test +++ b/tests/lex-nodist.test @@ -65,6 +65,12 @@ int main () { return yylex (); } + +/* Avoid possible link errors. */ +int yywrap (void) +{ + return 1; +} END $ACLOCAL