From: Ralf Wildenhues Date: Sat, 3 Dec 2005 08:33:48 +0000 (+0000) Subject: * libltdl/config/general.m4sh (func_show_eval): X-Git-Tag: release-2-1b~381 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ef097dbf60b90b6a19f917dc801d24373964df5;p=thirdparty%2Flibtool.git * libltdl/config/general.m4sh (func_show_eval): Rewrite use the failure expression, because the exit status of the previous command may not be preserved in the next `eval' by some shells, such as pdksh. * libltdl/config/ltmain.m4sh (func_extract_an_archive): Use func_show_eval correctly. (func_mode_link): Likewise. Also, do not use `$status'. * tests/fail.at: New set of tests to ensure libtool fails. * Makefile.am, tests/testsuite.at: Adjusted. --- diff --git a/ChangeLog b/ChangeLog index d7a09c5ce..0c109a5b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-12-03 Ralf Wildenhues + + * libltdl/config/general.m4sh (func_show_eval): + Rewrite use the failure expression, because the exit status of + the previous command may not be preserved in the next `eval' by + some shells, such as pdksh. + * libltdl/config/ltmain.m4sh (func_extract_an_archive): + Use func_show_eval correctly. + (func_mode_link): Likewise. Also, do not use `$status'. + * tests/fail.at: New set of tests to ensure libtool fails. + * Makefile.am, tests/testsuite.at: Adjusted. + 2005-11-26 Peter O'Gorman * libltdl/m4/libtool.m4 [darwin]: Use $LTCC $LTCFLAGS to create diff --git a/Makefile.am b/Makefile.am index e9f2956f5..b7f979d39 100644 --- a/Makefile.am +++ b/Makefile.am @@ -372,6 +372,7 @@ TESTSUITE_AT = tests/testsuite.at \ tests/stresstest.at \ tests/subproject.at \ tests/link-order.at \ + tests/fail.at \ tests/convenience.at \ tests/early-libtool.at \ tests/template.at diff --git a/libltdl/config/general.m4sh b/libltdl/config/general.m4sh index ce2b3e2cc..2fdafd965 100644 --- a/libltdl/config/general.m4sh +++ b/libltdl/config/general.m4sh @@ -336,5 +336,11 @@ func_show_eval () eval "func_echo $func_quote_for_expand_result" } - ${opt_dry_run-false} || eval "$my_cmd" || eval "$my_fail_exp" + if ${opt_dry_run-false}; then :; else + eval "$my_cmd" + my_status=$? + if test "$my_status" -eq 0; then :; else + eval "(exit $my_status); $my_fail_exp" + fi + fi } diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index cd0748ec3..e7b5f4089 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -1014,7 +1014,7 @@ func_extract_an_archive () $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" - func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $? + func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" 'exit $?' if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else @@ -5583,15 +5583,15 @@ EOF link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. - func_show_eval "$link_command" - status=$? + exit_status=0 + func_show_eval "$link_command" 'exit_status=$?' # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi - exit $status + exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then diff --git a/tests/fail.at b/tests/fail.at new file mode 100644 index 000000000..b72915f89 --- /dev/null +++ b/tests/fail.at @@ -0,0 +1,70 @@ +# Hand crafted tests for GNU Libtool. -*- Autotest -*- +# Copyright 2005 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# Test that libtool really fails when it should. +# TODO: many possible failure cases missing. (But how to simulate a full disk?) + +AT_SETUP([Failure tests]) +eval `$LIBTOOL --config | $EGREP '^(pic_mode|pic_flag|build_old_libs|build_libtool_libs)='` +LDFLAGS="$LDFLAGS -no-undefined" + +m4_pushdef([FAIL_CHECK], +[AT_CHECK([if $1; then (exit 1); else :; fi], [0], [ignore], [ignore]) +]) + +# compile failure +echo 'choke me' > a.c +FAIL_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c]) +AT_CHECK([test -f a.lo], [1]) + +# non-PIC compile failure +case $pic_mode in default | yes) + case $build_old_libs,$pic_flag in yes,*-DPIC*) + AT_DATA([a.c], [[ +#ifndef PIC + choke me +#endif +]]) + FAIL_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -no-suppress -c a.c]) + AT_CHECK([test -f a.lo], [1]) + ;; + esac + ;; +esac + +# program creation failure +echo 'int not_main(void) { return 0; }' > a.c +$CC $CPPFLAGS $CFLAGS -c a.c +FAIL_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o a a.$OBJEXT]) +AT_CHECK([test -f a || test -f a$EXEEXT], [1]) +FAIL_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o a a.$OBJEXT -static]) +AT_CHECK([test -f a || test -f a$EXEEXT], [1]) + +# shared library creation failure +case $build_libtool_libs in yes) + echo 'int duplicate_name(void) { return 0; }' > a.c + echo 'double duplicate_name(double x) { return 2.*x; }' > b.c + $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c + $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c b.c + FAIL_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la a.lo b.lo -rpath /foo]) + AT_CHECK([test -f liba.la], [1]) + ;; +esac + +m4_popdef([FAIL_CHECK]) +AT_CLEANUP diff --git a/tests/testsuite.at b/tests/testsuite.at index 0d9ac0d10..13de10454 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -282,6 +282,8 @@ m4_include([inherited_flags.at]) m4_include([convenience.at]) # link order test m4_include([link-order.at]) +# ensure failure +m4_include([fail.at]) # Ensure our continued support for old interfaces. m4_include([old-m4-iface.at]) # Torturing subdir-objects builds