Commit | Line | Data |
---|---|---|
92b7c7b6 L |
1 | # Expect script for various DWARF tests. |
2 | # Copyright 2006 Free Software Foundation, Inc. | |
3 | # | |
4 | # This file is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 2 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | # | |
18 | ||
19 | # | |
20 | # Written by H.J. Lu (hongjiu.lu@intel.com) | |
21 | # | |
22 | ||
23 | # Exclude non-ELF targets. | |
24 | ||
25 | if ![is_elf_format] { | |
26 | return | |
27 | } | |
28 | ||
29 | # The following tests require running the executable generated by ld. | |
30 | if ![isnative] { | |
31 | return | |
32 | } | |
33 | ||
34 | # Check if compiler works | |
35 | if { [which $CC] == 0 } { | |
36 | return | |
37 | } | |
38 | ||
39 | # Skip if -feliminate-dwarf2-dups isn't supported. | |
40 | if ![ld_compile "$CC -g -feliminate-dwarf2-dups" $srcdir/$subdir/dummy.c tmpdir/dummy.o] { | |
41 | return | |
42 | } | |
43 | ||
44 | set build_tests { | |
45 | {"Build libdwarf1.so" | |
46 | "-s -shared" "-fPIC -g -feliminate-dwarf2-dups" | |
47 | {dwarf1.c} {} "libdwarf1.so"} | |
48 | } | |
49 | ||
50 | set run_tests { | |
51 | {"Run with libdwarf1.so first" | |
52 | "tmpdir/libdwarf1.so" "" | |
53 | {dwarf1main.c} "dwarf1a" "dwarf1.out" | |
54 | "-g -feliminate-dwarf2-dups"} | |
55 | {"Run with libdwarf1.so last" | |
56 | "tmpdir/dwarf1main.o tmpdir/libdwarf1.so" "" | |
57 | {dummy.c} "dwarf1b" "dwarf1.out" | |
58 | "-g -feliminate-dwarf2-dups"} | |
59 | } | |
60 | ||
61 | run_cc_link_tests $build_tests | |
62 | run_ld_link_exec_tests [] $run_tests | |
63 | ||
64 | proc strip_test {} { | |
65 | global ld | |
66 | global strip | |
67 | global NM | |
68 | ||
69 | set test "libdwarf1c.so" | |
70 | set test_name "Strip -s $test" | |
71 | set prog $strip | |
72 | ||
73 | if ![ld_simple_link $ld tmpdir/$test "-shared tmpdir/dwarf1.o"] { | |
74 | unresolved "$test_name" | |
75 | return | |
76 | } | |
77 | ||
78 | send_log "$NM -D tmpdir/$test > tmpdir/$test.exp\n" | |
79 | catch "exec $NM -D tmpdir/$test > tmpdir/$test.exp" got | |
80 | if ![string match "" $got] then { | |
81 | send_log "$got\n" | |
82 | unresolved "$test_name" | |
83 | return | |
84 | } | |
85 | ||
86 | send_log "$prog -s tmpdir/$test\n" | |
87 | catch "exec $prog -s tmpdir/$test" got | |
88 | if ![string match "" $got] then { | |
89 | send_log "$got\n" | |
90 | fail "$test_name" | |
91 | return | |
92 | } | |
93 | ||
94 | send_log "$NM -D tmpdir/$test > tmpdir/$test.out\n" | |
95 | catch "exec $NM -D tmpdir/$test > tmpdir/$test.out" got | |
96 | if ![string match "" $got] then { | |
97 | send_log "$got\n" | |
98 | unresolved "$test_name" | |
99 | return | |
100 | } | |
101 | ||
102 | if { [catch {exec cmp tmpdir/$test.exp tmpdir/$test.out}] } then { | |
103 | send_log "tmpdir/$test.exp tmpdir/$test.out differ.\n" | |
104 | fail "$test_name" | |
105 | return | |
106 | } | |
107 | ||
108 | pass "$test_name" | |
109 | } | |
110 | ||
111 | strip_test |