1 # Copyright 1995, 1997, 2002, 2004, 2007 Free Software Foundation, Inc.
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.
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.
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.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-dejagnu@prep.ai.mit.edu
20 # Written by Ian Lance Taylor <ian@cygnus.com>
22 if ![is_remote host] {
23 if {[which $AR] == 0} then {
24 perror "$AR does not exist"
29 # send_user "Version [binutil_version $AR]"
31 # Test long file name support
33 proc long_filenames { } {
37 set testname "ar long file names"
39 set n1 "abcdefghijklmnopqrstuvwxyz1"
40 set n2 "abcdefghijklmnopqrstuvwxyz2"
44 remote_file build delete $file1
45 remote_file host delete $n1
47 # Some file systems truncate file names at 14 characters, which
48 # makes it impossible to run this test. Check for that now.
49 set status [catch "set f [open tmpdir/$n1 w]" errs]
51 verbose -log "open tmpdir/$n1 returned $errs"
58 remote_file build delete $file2
59 remote_file host delete $n2
61 set status [catch "set f [open tmpdir/$n2 w]" errs]
63 verbose -log "open tmpdir/$n2 returned $errs"
71 set file1 [remote_download host $file1]
72 set file2 [remote_download host $file2]
75 set dest tmpdir/artest.a
78 remote_file host delete $dest
80 set got [binutils_run $AR "rc $dest $file1 $file2"]
82 remote_upload host $file1 tmpdir/$n1
85 set f [open tmpdir/$n1 r]
88 if ![string match "first" $string] {
89 verbose -log "reading tmpdir/$n1 returned $string"
94 remote_file host delete $dest
95 set got [binutils_run $AR "rc $dest $file1 $file2"]
97 if ![string match "" $got] {
102 remote_file build delete tmpdir/$n1
103 remote_file build delete tmpdir/$n2
105 set got [binutils_run $AR "t $dest"]
106 regsub "\[\r\n \t\]*$" "$got" "" got
107 if ![string match "$n1*$n2" $got] {
112 if [is_remote host] {
113 remote_file host delete $file1
114 remote_file host delete $file2
117 verbose -log "$AR x $dest"
118 set exec_output [binutils_run $AR "x $dest"]
119 set exec_output [prune_warnings $exec_output]
120 if ![string match "" $exec_output] {
121 verbose -log $exec_output
126 if [is_remote host] {
127 remote_upload host $n1 tmpdir/$n1
128 remote_upload host $n2 tmpdir/$n2
136 if ![file exists $file1] {
137 verbose -log "$file1 does not exist"
141 if ![file exists $file2] {
142 verbose -log "$file2 does not exist"
147 set f [open $file1 r]
148 if { [gets $f line] == -1 || $line != "first" } {
149 verbose -log "$file1 contents:"
157 set f [open $file2 r]
158 if { [gets $f line] == -1 || $line != "second" } {
159 verbose -log "$file2 contents:"
167 file delete $file1 $file2
171 # Test building the symbol table.
173 proc symbol_table { } {
180 set testname "ar symbol table"
182 if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o] {
187 if [is_remote host] {
189 set objfile [remote_download host tmpdir/bintest.o]
190 remote_file host delete $archive
192 set archive tmpdir/artest.a
193 set objfile tmpdir/bintest.o
196 remote_file build delete tmpdir/artest.a
198 set got [binutils_run $AR "rc $archive ${objfile}"]
199 if ![string match "" $got] {
204 set got [binutils_run $NM "--print-armap $archive"]
205 if { ![string match "*text_symbol in bintest.o*" $got] \
206 || ![string match "*data_symbol in bintest.o*" $got] \
207 || ![string match "*common_symbol in bintest.o*" $got] \
208 || [string match "*static_text_symbol in bintest.o*" $got] \
209 || [string match "*static_data_symbol in bintest.o*" $got] \
210 || [string match "*external_symbol in bintest.o*" $got] } {
218 # Test POSIX-compatible argument parsing.
220 proc argument_parsing { } {
226 set testname "ar argument parsing"
228 if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o] {
233 if [is_remote host] {
235 set objfile [remote_download host tmpdir/bintest.o]
236 remote_file host delete $archive
238 set archive tmpdir/artest.a
239 set objfile tmpdir/bintest.o
242 remote_file build delete tmpdir/artest.a
244 set got [binutils_run $AR "-r -c $archive ${objfile}"]
245 if ![string match "" $got] {