summaryrefslogtreecommitdiff
path: root/binutils/testsuite/binutils-all/x86-64/objects.exp
blob: b77d43d7a6b7e2e50eb2cb6e1141f5e3919a436a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Expect script for x86-64 object tests.
#   Copyright (C) 2017-2021 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
# MA 02110-1301, USA.

if {![istarget "x86_64-*-linux*"] || [is_remote host]} {
    return
}

set tempfile tmpdir/x86-64-object-temp.o
set copyfile tmpdir/x86-64-object-copy.o

set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.o.bz2]]
foreach t $test_list {
    # We need to strip the ".bz2", but can leave the dirname.
    set test $subdir/[file tail $t]
    set testname [file rootname $test]
    verbose $testname
    if {[catch "system \"bzip2 -dc $t > $tempfile\""] != 0} {
	untested "bzip2 -dc ($testname)"
	continue
    }
    set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS $tempfile $copyfile"]
    if ![string equal "" $got] then {
	fail "objcopy ($testname)"
    } else {
	set got [remote_exec host "$READELF -a $tempfile" "" "/dev/null" "${tempfile}.out"]
	if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
	    fail "objcopy ($testname)"
	    continue
	}
	set got [remote_exec host "$READELF -a $copyfile" "" "/dev/null" "${copyfile}.out"]
	if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
	    fail "objcopy ($testname)"
	    continue
	}
	set got [binutils_run cmp "${tempfile}.out ${copyfile}.out"]
	if ![string equal "" $got] then {
	    fail "objcopy ($testname)"
	    continue
	}
	pass "objcopy ($testname)"
    }
}