* ld-undefined/undefined.exp: New test, to check reporting of
[external/binutils.git] / ld / testsuite / ld-undefined / undefined.exp
1 # Test that the linker reports undefined symbol errors correctly.
2 # By Ian Lance Taylor, Cygnus Support
3 #
4 #   Copyright (C) 1995 Free Software Foundation
5 #
6 # This file is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 set testund "undefined"
21 set testfn "undefined function"
22 set testline "undefined line"
23
24 if ![ld_compile "$CC -g" $srcdir$subdir/undefined.c tmpdir/undefined.o] {
25     unresolved $testund
26     unresolved $testfn
27     unresolved $testline
28     return
29 }
30
31 catch "exec rm -f tmpdir/undefined" exec_output
32
33 send_log "$ld -o tmpdir/undefined tmpdir/undefined.o\n"
34 verbose "$ld -o tmpdir/undefined tmpdir/undefined.o"
35
36 catch "exec $ld -o tmpdir/undefined tmpdir/undefined.o" exec_output
37 send_log "$exec_output\n"
38 verbose "$exec_output"
39
40 proc checkund { string testname } {
41     global exec_output
42
43     if [string match "*$string*" $exec_output] {
44         pass $testname
45     } else {
46         fail $testname
47     }
48 }
49
50 set mu "undefined reference to `this_function_is_not_defined'"
51 checkund $mu $testund
52
53 set mf "tmpdir/undefined.o: In function `function':"
54 checkund $mf $testfn
55
56 # ELF targets currently can not get line number information (except
57 # for MIPS ELF).
58 setup_xfail "*-*-elf*" "*-*-sysv4*" "*-*-unixware*" "*-*-solaris*" "*-*-gnu*"
59 setup_xfail "hppa*-*-lites*" "m88*-harris-cxux*" "m88*-*-dgux*"
60 setup_xfail "powerpc*-*-eabi*" "*-stratus-*" "*-cbm-*" "*-ncr-*"
61 clear_xfail "mips-*-elf*" "mips-*-sysv4*" "mips-*-gnu*"
62
63 set ml "undefined.c:9: undefined reference to `this_function_is_not_defined'"
64 checkund $ml $testline