This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / binutils / testsuite / binutils-all / ar.exp
1 # Copyright (C) 1995, 1997 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-dejagnu@prep.ai.mit.edu
19
20 # Written by Ian Lance Taylor <ian@cygnus.com>
21
22 if {[which $AR] == 0} then {
23 perror "$AR does not exist"
24 return
25 }
26
27 # send_user "Version [binutil_version $AR]"
28
29 # Test long file name support
30
31 proc long_filenames { } {
32 global AR
33 global host_triplet
34
35 set testname "ar long file names"
36
37 set n1 "abcdefghijklmnopqrstuvwxyz1"
38 set n2 "abcdefghijklmnopqrstuvwxyz2"
39
40 binutils_remove tmpdir/$n1
41 set status [catch "set f [open tmpdir/$n1 w]" errs]
42 if { $status != 0 } {
43 verbose -log "open tmpdir/$n1 returned $errs"
44 unsupported $testname
45 return
46 }
47 puts $f "first"
48 close $f
49
50 binutils_remove tmpdir/$n2
51 set status [catch "set f [open tmpdir/$n2 w]" errs]
52 if { $status != 0 } {
53 verbose -log "open tmpdir/$n2 returned $errs"
54 unsupported $testname
55 return
56 }
57 puts $f "second"
58 close $f
59
60 # Some file systems truncate file names at 14 characters, which
61 # makes it impossible to run this test. Check for that now.
62 set f [open tmpdir/$n1 r]
63 gets $f string
64 close $f
65 if ![string match "first" $string] {
66 verbose -log "reading tmpdir/$n1 returned $string"
67 unsupported $testname
68 return
69 }
70
71 binutils_remove tmpdir/artest.a
72 set got [binutils_run $AR "rc tmpdir/artest.a tmpdir/$n1 tmpdir/$n2"]
73 if ![string match "" $got] {
74 fail $testname
75 return
76 }
77
78 binutils_remove tmpdir/$n1
79 binutils_remove tmpdir/$n2
80
81 set got [binutils_run $AR "t tmpdir/artest.a"]
82 if ![string match "$n1*$n2" $got] {
83 fail $testname
84 return
85 }
86
87 verbose -log "cd tmpdir; $AR x artest.a"
88 catch "exec /bin/sh -c \"cd tmpdir; $AR x artest.a\"" exec_output
89 set exec_output [prune_warnings $exec_output]
90 if ![string match "" $exec_output] {
91 verbose -log $exec_output
92 fail $testname
93 return
94 }
95
96 if ![file exists tmpdir/$n1] {
97 verbose -log "tmpdir/$n1 does not exist"
98 fail $testname
99 return
100 }
101 if ![file exists tmpdir/$n2] {
102 verbose -log "tmpdir/$n2 does not exist"
103 fail $testname
104 return
105 }
106
107 set f [open tmpdir/$n1 r]
108 if { [gets $f line] == -1 || $line != "first" } {
109 verbose -log "tmpdir/$n1 contents:"
110 verbose -log "$line"
111 close $f
112 fail $testname
113 return
114 }
115 close $f
116
117 set f [open tmpdir/$n2 r]
118 if { [gets $f line] == -1 || $line != "second" } {
119 verbose -log "tmpdir/$n2 contents:"
120 verbose -log "$line"
121 close $f
122 fail $testname
123 return
124 }
125 close $f
126
127 pass $testname
128 }
129
130 # Test building the symbol table.
131
132 proc symbol_table { } {
133 global AR
134 global AS
135 global NM
136 global srcdir
137 global subdir
138
139 set testname "ar symbol table"
140
141 if ![binutils_assemble $AS $srcdir/$subdir/bintest.s tmpdir/bintest.o] {
142 unresolved $testname
143 return
144 }
145
146 binutils_remove tmpdir/artest.a
147
148 set got [binutils_run $AR "rc tmpdir/artest.a tmpdir/bintest.o"]
149 if ![string match "" $got] {
150 fail $testname
151 return
152 }
153
154 set got [binutils_run $NM "--print-armap tmpdir/artest.a"]
155 if { ![string match "*text_symbol in bintest.o*" $got] \
156 || ![string match "*data_symbol in bintest.o*" $got] \
157 || ![string match "*common_symbol in bintest.o*" $got] \
158 || [string match "*static_text_symbol in bintest.o*" $got] \
159 || [string match "*static_data_symbol in bintest.o*" $got] \
160 || [string match "*external_symbol in bintest.o*" $got] } {
161 fail $testname
162 return
163 }
164
165 pass $testname
166 }
167
168 # Run the tests.
169
170 long_filenames
171 symbol_table
This page took 0.047306 seconds and 5 git commands to generate.