binutils: Add new GNU format mode to `size` utility
[deliverable/binutils-gdb.git] / binutils / testsuite / binutils-all / size.exp
CommitLineData
82704155 1# Copyright (C) 1993-2019 Free Software Foundation, Inc.
252b5132
RH
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
32866df7 5# the Free Software Foundation; either version 3 of the License, or
252b5132
RH
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
b43b5d5f 15# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
252b5132
RH
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-dejagnu@prep.ai.mit.edu
19
20# This file was written by Rob Savoye <rob@cygnus.com>
21# and rewritten by Ian Lance Taylor <ian@cygnus.com>
22
23if ![is_remote host] {
24 if {[which $SIZE] == 0} then {
25 perror "$SIZE does not exist"
26 return
27 }
28}
29
30send_user "Version [binutil_version $SIZE]"
31
32
33if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
f795c494 34 fail "size (assembling)"
252b5132 35} else {
252b5132 36
f795c494
AM
37 if [is_remote host] {
38 set testfile [remote_download host tmpdir/bintest.o]
39 } else {
40 set testfile tmpdir/bintest.o
41 }
252b5132 42
f795c494
AM
43 set dec "\[0-9\]+"
44 set hex "\[0-9a-fA-F\]+"
252b5132 45
f795c494 46 # Test size with no arguments
252b5132 47
f795c494 48 set got [binutils_run $SIZE "$SIZEFLAGS $testfile"]
252b5132 49
f795c494
AM
50 set want "($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($hex)\[ \]+${testfile}"
51
52 if ![regexp $want $got all text data bss dtot hextot] then {
252b5132
RH
53 fail "size (no arguments)"
54 } else {
f795c494
AM
55 if {$text < 8 || $data < 4} then {
56 # The z80-coff port defaults to a "binary" like output
57 # file format which does not include a data section.
58 setup_xfail "z80-*-coff"
59 fail "size (no arguments)"
60 } else {
61 pass "size (no arguments)"
62 }
252b5132 63 }
252b5132 64
f795c494 65 # Test size -A
252b5132 66
f795c494 67 set got [binutils_run $SIZE "$SIZEFLAGS -A ${testfile}"]
252b5132 68
f795c494 69 set want "${testfile}.*(text|TEXT|P)\[^\n\r\]*\[ \]($dec)\[ \]+$dec.*(\\.data|DATA|D_1)\[^\n\r\]*\[ \]($dec)\[ \]+$dec"
252b5132 70
f795c494 71 if ![regexp $want $got all textname textsize dataname datasize] then {
252b5132
RH
72 fail "size -A"
73 } else {
f795c494
AM
74 verbose "text size: $textsize"
75 verbose "data size: $datasize"
76 if {$textsize < 8 || $datasize < 4} then {
77 fail "size -A"
78 } else {
79 pass "size -A"
80 }
252b5132 81 }
46cbf38d
AB
82
83 # Test size -G
84
85 set got [binutils_run $SIZE "$SIZEFLAGS -G $testfile"]
86
87 set want "($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+${testfile}"
88
89 if ![regexp $want $got all text data bss dtot hextot] then {
90 fail "size -G"
91 } else {
92 if {$text < 8 || $data < 4} then {
93 # The z80-coff port defaults to a "binary" like output
94 # file format which does not include a data section.
95 setup_xfail "z80-*-coff"
96 fail "size -G"
97 } else {
98 pass "size -G"
99 }
100 }
101
252b5132 102}
This page took 0.895671 seconds and 4 git commands to generate.