1 # Copyright
1995, 1997, 2002, 2004, 2007, 2008, 2009
2 # Free Software Foundation
, Inc.
4 # This
program 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
3 of the License
, or
7 #
(at your option
) any later version.
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.
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.
18 # Please email
any bugs
, comments
, and
/or additions to this file to
:
19 # bug
-dejagnu@prep.ai.mit.edu
21 # Written by Ian Lance Taylor
<ian@cygnus.com
>
23 if ![is_remote host
] {
24 if {[which $AR
] == 0} then {
25 perror
"$AR does not exist"
30 # send_user
"Version [binutil_version $AR]"
32 # Test long file
name support
34 proc long_filenames
{ } {
38 set testname
"ar long file names"
40 set n1
"abcdefghijklmnopqrstuvwxyz1"
41 set n2
"abcdefghijklmnopqrstuvwxyz2"
45 remote_file build
delete $file1
46 remote_file host
delete $n1
48 # Some file systems truncate file names at
14 characters
, which
49 # makes it impossible to run this test. Check
for that now.
50 set status [catch
"set f [open tmpdir/$n1 w]" errs]
52 verbose
-log "open tmpdir/$n1 returned $errs"
59 remote_file build
delete $file2
60 remote_file host
delete $n2
62 set status [catch
"set f [open tmpdir/$n2 w]" errs]
64 verbose
-log "open tmpdir/$n2 returned $errs"
72 set file1
[remote_download host $file1
]
73 set file2
[remote_download host $file2
]
76 set dest tmpdir
/artest.a
79 remote_file host
delete $dest
81 set got
[binutils_run $AR
"rc $dest $file1 $file2"]
83 remote_upload host $file1 tmpdir
/$n1
86 set f
[open tmpdir
/$n1 r
]
89 if ![string match
"first" $string] {
90 verbose
-log "reading tmpdir/$n1 returned $string"
95 remote_file host
delete $dest
96 set got
[binutils_run $AR
"rc $dest $file1 $file2"]
98 if ![string match
"" $got] {
103 remote_file build
delete tmpdir
/$n1
104 remote_file build
delete tmpdir
/$n2
106 set got
[binutils_run $AR
"t $dest"]
107 regsub
"\[\r\n \t\]*$" "$got" "" got
108 if ![string match
"$n1*$n2" $got] {
113 if [is_remote host
] {
114 remote_file host
delete $file1
115 remote_file host
delete $file2
118 verbose
-log "$AR x $dest"
119 set exec_output
[binutils_run $AR
"x $dest"]
120 set exec_output
[prune_warnings $exec_output
]
121 if ![string match
"" $exec_output] {
122 verbose
-log $exec_output
127 if [is_remote host
] {
128 remote_upload host $n1 tmpdir
/$n1
129 remote_upload host $n2 tmpdir
/$n2
137 if ![file
exists $file1
] {
138 verbose
-log "$file1 does not exist"
142 if ![file
exists $file2
] {
143 verbose
-log "$file2 does not exist"
148 set f
[open $file1 r
]
149 if { [gets $f line
] == -1 || $line
!= "first" } {
150 verbose
-log "$file1 contents:"
158 set f
[open $file2 r
]
159 if { [gets $f line
] == -1 || $line
!= "second" } {
160 verbose
-log "$file2 contents:"
168 file
delete $file1 $file2
172 # Test building the symbol table.
174 proc symbol_table
{ } {
181 set testname
"ar symbol table"
183 if ![binutils_assemble $srcdir
/$subdir
/bintest.s tmpdir
/bintest.o
] {
188 if [is_remote host
] {
190 set objfile
[remote_download host tmpdir
/bintest.o
]
191 remote_file host
delete $archive
193 set archive tmpdir
/artest.a
194 set objfile tmpdir
/bintest.o
197 remote_file build
delete tmpdir
/artest.a
199 set got
[binutils_run $AR
"rc $archive ${objfile}"]
200 if ![string match
"" $got] {
205 set got
[binutils_run $NM
"--print-armap $archive"]
206 if { ![string match
"*text_symbol in bintest.o*" $got] \
207 ||
![string match
"*data_symbol in bintest.o*" $got] \
208 ||
![string match
"*common_symbol in bintest.o*" $got] \
209 ||
[string match
"*static_text_symbol in bintest.o*" $got] \
210 ||
[string match
"*static_data_symbol in bintest.o*" $got] \
211 ||
[string match
"*external_symbol in bintest.o*" $got] } {
219 # Test building a thin archive.
221 proc thin_archive
{ } {
228 set testname
"ar thin archive"
230 if ![binutils_assemble $srcdir
/$subdir
/bintest.s tmpdir
/bintest.o
] {
235 if [is_remote host
] {
237 set objfile
[remote_download host tmpdir
/bintest.o
]
238 remote_file host
delete $archive
240 set archive tmpdir
/artest.a
241 set objfile tmpdir
/bintest.o
244 remote_file build
delete tmpdir
/artest.a
246 set got
[binutils_run $AR
"rcT $archive ${objfile}"]
247 if ![string match
"" $got] {
252 set got
[binutils_run $NM
"--print-armap $archive"]
253 if { ![string match
"*text_symbol in *bintest.o*" $got] \
254 ||
![string match
"*data_symbol in *bintest.o*" $got] \
255 ||
![string match
"*common_symbol in *bintest.o*" $got] \
256 ||
[string match
"*static_text_symbol in *bintest.o*" $got] \
257 ||
[string match
"*static_data_symbol in *bintest.o*" $got] \
258 ||
[string match
"*external_symbol in *bintest.o*" $got] } {
266 # Test building a thin archive with a nested archive.
268 proc thin_archive_with_nested
{ } {
275 set testname
"ar thin archive with nested archive"
277 if ![binutils_assemble $srcdir
/$subdir
/bintest.s tmpdir
/bintest.o
] {
282 if [is_remote host
] {
284 set archive2 artest2.a
285 set objfile
[remote_download host tmpdir
/bintest.o
]
286 remote_file host
delete $archive
288 set archive tmpdir
/artest.a
289 set archive2 tmpdir
/artest2.a
290 set objfile tmpdir
/bintest.o
293 remote_file build
delete tmpdir
/artest.a
295 set got
[binutils_run $AR
"rc $archive ${objfile}"]
296 if ![string match
"" $got] {
301 remote_file build
delete tmpdir
/artest2.a
303 set got
[binutils_run $AR
"rcT $archive2 ${archive}"]
304 if ![string match
"" $got] {
309 set got
[binutils_run $NM
"--print-armap $archive"]
310 if { ![string match
"*text_symbol in *bintest.o*" $got] \
311 ||
![string match
"*data_symbol in *bintest.o*" $got] \
312 ||
![string match
"*common_symbol in *bintest.o*" $got] \
313 ||
[string match
"*static_text_symbol in *bintest.o*" $got] \
314 ||
[string match
"*static_data_symbol in *bintest.o*" $got] \
315 ||
[string match
"*external_symbol in *bintest.o*" $got] } {
323 # Test POSIX
-compatible
argument parsing.
325 proc argument_parsing
{ } {
331 set testname
"ar argument parsing"
333 if ![binutils_assemble $srcdir
/$subdir
/bintest.s tmpdir
/bintest.o
] {
338 if [is_remote host
] {
340 set objfile
[remote_download host tmpdir
/bintest.o
]
341 remote_file host
delete $archive
343 set archive tmpdir
/artest.a
344 set objfile tmpdir
/bintest.o
347 remote_file build
delete tmpdir
/artest.a
349 set got
[binutils_run $AR
"-r -c $archive ${objfile}"]
350 if ![string match
"" $got] {
358 # Test building a deterministic archive.
360 proc deterministic_archive
{ } {
367 set testname
"ar deterministic archive"
369 if ![binutils_assemble $srcdir
/$subdir
/bintest.s tmpdir
/bintest.o
] {
374 if [is_remote host
] {
376 set objfile
[remote_download host tmpdir
/bintest.o
]
377 remote_file host
delete $archive
379 set archive tmpdir
/artest.a
380 set objfile tmpdir
/bintest.o
383 remote_file build
delete tmpdir
/artest.a
385 set got
[binutils_run $AR
"rcD $archive ${objfile}"]
386 if ![string match
"" $got] {
391 set got
[binutils_run $AR
"tv $archive"]
392 # This only checks the file
mode and uid
/gid. We can
't easily match
393 # date because it's printed with the user
's timezone.
394 if ![string match "rw-r--r-- 0/0 *bintest.o*" $got] {
407 thin_archive_with_nested
409 deterministic_archive