75b878337081a6550370b534923b01bcfc2879eb
[deliverable/binutils-gdb.git] / binutils / testsuite / binutils-all / compress.exp
1 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
16
17 # Test compressed .debug section.
18
19 if { [is_remote host] || ![is_elf_format] || ![is_zlib_supported] } then {
20 return
21 }
22
23 set testfile tmpdir/dw2-1.o
24 set compressedfile tmpdir/dw2-1-compressed.o
25 set copyfile tmpdir/dw2-copy
26 set compressedfile2 tmpdir/dw2-2-compressed.o
27 set libfile tmpdir/libdw2.a
28 set compressedcopyfile tmpdir/dw2-copy-compressed
29
30 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S $testfile --nocompress-debug-sections] } then {
31 unsupported "compressed debug sections"
32 return
33 }
34
35 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S $compressedfile --compress-debug-sections] } then {
36 unsupported "compressed debug sections"
37 return
38 }
39
40 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S $compressedfile2 --compress-debug-sections] } then {
41 unsupported "compressed debug sections"
42 return
43 }
44
45 remote_file host delete $libfile
46 set got [binutils_run $AR "rc $libfile $compressedfile $compressedfile2"]
47 if ![string match "" $got] then {
48 fail "compressed debug sections"
49 return
50 }
51
52 set testname "objcopy compress debug sections"
53 set got [binutils_run $OBJCOPY "--compress-debug-sections $testfile ${copyfile}.o"]
54 if ![string match "" $got] then {
55 fail "objcopy ($testname)"
56 } else {
57 send_log "cmp $compressedfile ${copyfile}.o\n"
58 verbose "cmp $compressedfile ${copyfile}.o"
59 set src1 ${compressedfile}
60 set src2 ${copyfile}.o
61 set status [remote_exec build cmp "${src1} ${src2}"]
62 set exec_output [lindex $status 1]
63 set exec_output [prune_warnings $exec_output]
64
65 if [string match "" $exec_output] then {
66 pass "objcopy ($testname)"
67 } else {
68 send_log "$exec_output\n"
69 verbose "$exec_output" 1
70 fail "objcopy ($testname)"
71 }
72 }
73
74 set testname "objcopy decompress compressed debug sections"
75 set got [binutils_run $OBJCOPY "--decompress-debug-sections $compressedfile ${copyfile}.o"]
76 if ![string match "" $got] then {
77 fail "objcopy ($testname)"
78 } else {
79 send_log "cmp $testfile ${copyfile}.o\n"
80 verbose "cmp $testfile ${copyfile}.o"
81 set src1 ${testfile}
82 set src2 ${copyfile}.o
83 set status [remote_exec build cmp "${src1} ${src2}"]
84 set exec_output [lindex $status 1]
85 set exec_output [prune_warnings $exec_output]
86
87 if [string match "" $exec_output] then {
88 pass "objcopy ($testname)"
89 } else {
90 send_log "$exec_output\n"
91 verbose "$exec_output" 1
92 fail "objcopy ($testname)"
93 }
94 }
95
96 set testname "objcopy decompress debug sections in archive"
97 set got [binutils_run $OBJCOPY "--decompress-debug-sections $libfile ${copyfile}.a"]
98 if ![string match "" $got] then {
99 fail "objcopy ($testname)"
100 } else {
101 set got [remote_exec host "$READELF -S --wide ${copyfile}.a" "" "/dev/null" "tmpdir/libdw2.out"]
102
103 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
104 fail "$testname (reason: unexpected output)"
105 send_log $got
106 send_log "\n"
107 }
108
109 if { [regexp_diff tmpdir/libdw2.out $srcdir/$subdir/libdw2.out] } then {
110 fail "$testname"
111 } else {
112 pass "$testname"
113 }
114 }
115
116 set testname "objcopy compress debug sections in archive"
117 set got [binutils_run $OBJCOPY "--compress-debug-sections ${copyfile}.a ${compressedcopyfile}.a"]
118 if ![string match "" $got] then {
119 fail "objcopy ($testname)"
120 } else {
121 set got [remote_exec host "$OBJDUMP -s -j .zdebug_line ${compressedcopyfile}.a" "" "/dev/null" "tmpdir/libdw2-compressed.out"]
122
123 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
124 fail "$testname (reason: unexpected output)"
125 send_log $got
126 send_log "\n"
127 }
128
129 if { [regexp_diff tmpdir/libdw2-compressed.out $srcdir/$subdir/libdw2-compressed.out] } then {
130 fail "$testname"
131 } else {
132 pass "$testname"
133 }
134 }
135
136 set testname "objdump compress debug sections"
137 set got [remote_exec host "$OBJDUMP -W $compressedfile" "" "/dev/null" "objdump.out"]
138 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
139 fail "$testname"
140 send_log "$got\n"
141 }
142 if { [regexp_diff objdump.out $srcdir/$subdir/dw2-1.W] } then {
143 fail "$testname"
144 } else {
145 pass "$testname"
146 }
147
148 set testfile tmpdir/dw2-emty.o
149
150 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-empty.S $testfile --nocompress-debug-sections] } then {
151 unsupported "compressed debug sections"
152 return
153 }
154
155 set testname "objcopy compress empty debug sections"
156 set got [binutils_run $OBJCOPY "--compress-debug-sections $testfile ${copyfile}.o"]
157 if ![string match "" $got] then {
158 fail "objcopy ($testname)"
159 } else {
160 send_log "cmp $testfile ${copyfile}.o\n"
161 verbose "cmp $testfile ${copyfile}.o"
162 set src1 ${testfile}
163 set src2 ${copyfile}.o
164 set status [remote_exec build cmp "${src1} ${src2}"]
165 set exec_output [lindex $status 1]
166 set exec_output [prune_warnings $exec_output]
167
168 if [string match "" $exec_output] then {
169 pass "objcopy ($testname)"
170 } else {
171 send_log "$exec_output\n"
172 verbose "$exec_output" 1
173 fail "objcopy ($testname)"
174 }
175 }
176
177 if ![is_remote host] {
178 set tempfile tmpdir/debug_str.o
179 set copyfile tmpdir/debug_str.copy
180 } else {
181 set tempfile [remote_download host tmpdir/debug_str.o]
182 set copyfile debug_str.copy
183 }
184
185 run_dump_test "debug_str"
This page took 0.03553 seconds and 4 git commands to generate.