Upload Tizen:Base source
[external/binutils.git] / binutils / testsuite / binutils-all / size.exp
1 #   Copyright 1993, 1994, 1995, 1997, 1998, 2007, 2009
2 #   Free Software Foundation, Inc.
3
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.
13
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.
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-dejagnu@prep.ai.mit.edu
20
21 # This file was written by Rob Savoye <rob@cygnus.com>
22 # and rewritten by Ian Lance Taylor <ian@cygnus.com>
23
24 if ![is_remote host] {
25     if {[which $SIZE] == 0} then {
26         perror "$SIZE does not exist"
27         return
28     }
29 }
30
31 send_user "Version [binutil_version $SIZE]"
32
33
34 if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
35     return
36 }
37
38 if [is_remote host] {
39     set testfile [remote_download host tmpdir/bintest.o]
40 } else {
41     set testfile tmpdir/bintest.o
42 }
43
44 set dec "\[0-9\]+"
45 set hex "\[0-9a-fA-F\]+"
46
47 # Test size with no arguments
48
49 set got [binutils_run $SIZE "$SIZEFLAGS $testfile"]
50
51 set want "($dec)\[      \]+($dec)\[     \]+($dec)\[     \]+($dec)\[     \]+($hex)\[     \]+${testfile}"
52
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)"
63     }
64 }
65
66 # Test size -A
67
68 set got [binutils_run $SIZE "$SIZEFLAGS -A ${testfile}"]
69
70 set want "${testfile}.*(text|TEXT)\[^\n\r\]*\[  \]($dec)\[      \]+$dec.*(\\.data|DATA)\[^\n\r\]*\[     \]($dec)\[      \]+$dec"
71
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"
81     }
82 }