]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* libltdl/config/general.m4sh (func_show_eval):
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 3 Dec 2005 08:33:48 +0000 (08:33 +0000)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 3 Dec 2005 08:33:48 +0000 (08:33 +0000)
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.

ChangeLog
Makefile.am
libltdl/config/general.m4sh
libltdl/config/ltmain.m4sh
tests/fail.at [new file with mode: 0644]
tests/testsuite.at

index d7a09c5ce6d4d1b3de0218b689aca9ea96ebabde..0c109a5b0817f1db72bead6ad58191ad43cb7caf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index e9f2956f5c3af3a3f6124fc9b1ffe165ca5fcb4f..b7f979d392b0e6e44b2edd97f754e1e5967dd11b 100644 (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
index ce2b3e2ccd0500b10cf4986ab46409efb4fdeebf..2fdafd9656c7e25508e2d7d516521a717eef3197 100644 (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
 }
index cd0748ec3feb9a6e95b5b56b7408f850340b695f..e7b5f4089edada47e7fe5119c9e22048babd6414 100644 (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
diff --git a/tests/fail.at b/tests/fail.at
new file mode 100644 (file)
index 0000000..b72915f
--- /dev/null
@@ -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
index 0d9ac0d10cad9a0b4e4986b82983ccf0196a266d..13de1045407ab32ecfcf34ac587ddc815e475a4e 100644 (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