2009-09-02 Tristan Gingold <gingold@adacore.com>
[binutils.git] / binutils / testsuite / binutils-all / size.exp
blob5050a5481dac8c3a3046217e5c6d40c2874d81a6
1 # Copyright 1993, 1994, 1995, 1997, 1998, 2007, 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.
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.
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 # This file was written by Rob Savoye <rob@cygnus.com>
22 # and rewritten by Ian Lance Taylor <ian@cygnus.com>
24 if ![is_remote host] {
25 if {[which $SIZE] == 0} then {
26 perror "$SIZE does not exist"
27 return
31 send_user "Version [binutil_version $SIZE]"
34 if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
35 return
38 if [is_remote host] {
39 set testfile [remote_download host tmpdir/bintest.o]
40 } else {
41 set testfile tmpdir/bintest.o
44 set dec "\[0-9\]+"
45 set hex "\[0-9a-fA-F\]+"
47 # Test size with no arguments
49 set got [binutils_run $SIZE "$SIZEFLAGS $testfile"]
51 set want "($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($hex)\[ \]+${testfile}"
53 if ![regexp $want $got all text data bss dtot hextot] then {
54 fail "size (no arguments)"
55 } else {
56 if {$text < 8 || $data < 4} then {
57 # The z80-coff port defaults to a "binary" like output
58 # file format which does not include a data section.
59 setup_xfail "z80-*-coff"
60 fail "size (no arguments)"
61 } else {
62 pass "size (no arguments)"
66 # Test size -A
68 set got [binutils_run $SIZE "$SIZEFLAGS -A ${testfile}"]
70 set want "${testfile}.*(text|TEXT)\[^\n\r\]*\[ \]($dec)\[ \]+$dec.*(\\.data|DATA)\[^\n\r\]*\[ \]($dec)\[ \]+$dec"
72 if ![regexp $want $got all textname textsize dataname datasize] then {
73 fail "size -A"
74 } else {
75 verbose "text size: $textsize"
76 verbose "data size: $datasize"
77 if {$textsize < 8 || $datasize < 4} then {
78 fail "size -A"
79 } else {
80 pass "size -A"