Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / demo-relink.test
1 #! /bin/sh
2 # demo-relink.test - check to see whether shlibpath overrides runpath
3 #
4 #   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
5 #   Written by Gary V. Vaughan, 2003
6 #
7 #   This file is part of GNU Libtool.
8 #
9 # GNU Libtool is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of
12 # the License, or (at your option) any later version.
13 #
14 # GNU Libtool is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with GNU Libtool; see the file COPYING.  If not, a copy
21 # can be downloaded from  http://www.gnu.org/licenses/gpl.html,
22 # or obtained by writing to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 ####
25
26 . tests/defs || exit 1
27
28 func_restore_files ()
29 {
30     mv -f "$objdir"/temp/libs/* "$objdir"
31     mv -f "$objdir/temp/libhello.la" .
32     rm -rf "$objdir/temp"
33 }
34
35 func_save_files ()
36 {
37     func_mkdir_p "$objdir/temp/libs"
38     cp -f libhello.la "$objdir/temp"
39     cp -f "$objdir"/libhello.* "$objdir/lt-hell$EXEEXT" "$objdir/temp/libs"
40     trap "func_restore_files" 0 1 2 13 15
41 }
42
43 func_require "demo-inst" "$prefix/lib/libhello.la"  "tests/demo/libhello.la"
44
45 func_mkprefixdir
46 func_cd "tests/demo"
47
48 # Check to make sure we have a dynamic library.
49 func_get_config "library_names" "cat libhello.la"
50 test -z "$library_names" \
51   && func_skip "Exiting: demo/libhello.la is not a shared library"
52
53 func_save_files
54
55 func_get_config 'shlibpath_overrides_runpath
56 hardcode_action
57 hardcode_direct
58 hardcode_into_libs' "./libtool --config" ": fatal"
59
60 ./hell$EXEEXT # so that it links on-demand if needed
61
62 func_msg "removing libhello.la from demo"
63 rm -f libhello.la "$objdir"/libhello.*
64
65 func_msg "running demo/hell"
66 if ./hell$EXEEXT; then
67   :
68 elif test "x,$hardcode_action,$hardcode_direct" = x,relink,yes; then
69   func_msg "Ok, uninstalled programs fail after uninstalled libraries are removed."
70   func_msg "This works in other configurations, but not in this particular one."
71 else
72   func_fail "Exiting: demo/hell does not run, maybe libhello was not installed"
73 fi
74
75 func_msg "linking a broken demo/libhello.la"
76 func_make libhello.la libhello_la_OBJECTS=hello.lo \
77   || func_fail "Exiting: cannot link broken libhello.la"
78 rm -f libhello.la
79
80 func_msg "running demo/hell with broken libhello.la"
81 if (./hell) 2>&1; then
82   func_msg "Exiting: demo/hell runs even though libhello.la is incomplete"
83   func_fail "shlibpath_overrides_runpath should be set to no"
84 else
85   func_msg "Failed, as expected"
86 fi
87
88 if test "x$hardcode_action" = xrelink; then
89   func_msg "Exiting: install-time relinking is required"
90   exit $EXIT_SUCCESS
91 fi
92
93 if test "$shlibpath_overrides_runpath" != yes; then
94   rm -f $objdir/lt-hell$EXEEXT || exit $EXIT_FAILURE
95   cp $objdir/hell$EXEEXT $objdir/lt-hell$EXEEXT || exit $EXIT_FAILURE
96   func_msg "running demo/hell with installed libhello.la"
97   if ./hell; then
98     func_msg "Worked, as expected"
99   else
100     func_msg "shlibpath_overrides_runpath should be set to yes"
101     status=$EXIT_FAILURE
102   fi
103 fi
104
105 exit $status