* 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.
This commit is contained in:
Ralf Wildenhues 2005-12-03 08:33:48 +00:00
parent efbbaaaf16
commit 1ef097dbf6
6 changed files with 96 additions and 5 deletions

View File

@ -1,3 +1,15 @@
2005-12-03 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* 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 <peter@pogma.com>
* libltdl/m4/libtool.m4 [darwin]: Use $LTCC $LTCFLAGS to create

View File

@ -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

View File

@ -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
}

View File

@ -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

70
tests/fail.at Normal file
View File

@ -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

View File

@ -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