ba8e928bcb84849095ec5ba5a36083a4a5594167
[external/binutils.git] / binutils / testsuite / binutils-all / x86-64 / objects.exp
1 # Expect script for x86-64 object tests.
2 #   Copyright (C) 2017 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,
17 # MA 02110-1301, USA.
18
19 if {!([istarget "x86_64-*-linux*"]
20       || [istarget "x86_64-*-nacl*"])
21     || [is_remote host]} {
22     return
23 }
24
25 global OBJCOPY
26 global OBJCOPYFLAGS
27 global READELF
28 set tempfile tmpdir/x86-64-object-temp.o
29 set copyfile tmpdir/x86-64-object-copy.o
30
31 set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.o.bz2]]
32 foreach t $test_list {
33     # We need to strip the ".bz2", but can leave the dirname.
34     set test $subdir/[file tail $t]
35     set testname [file rootname $test]
36     verbose $testname
37     if {[catch "system \"bzip2 -dc $t > $tempfile\""] != 0} {
38         untested "bzip2 -dc ($testname)"
39         continue
40     }
41     set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS $tempfile $copyfile"]
42     if ![string equal "" $got] then {
43         fail "objcopy ($testname)"
44     } else {
45         set got [remote_exec host "$READELF -a $tempfile" "" "/dev/null" "${tempfile}.out"]
46         if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
47             fail "objcopy ($testname)"
48             continue
49         }
50         set got [remote_exec host "$READELF -a $copyfile" "" "/dev/null" "${copyfile}.out"]
51         if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
52             fail "objcopy ($testname)"
53             continue
54         }
55         set got [binutils_run cmp "${tempfile}.out ${copyfile}.out"]
56         if ![string equal "" $got] then {
57             fail "objcopy ($testname)"
58             continue
59         }
60         pass "objcopy ($testname)"
61     }
62 }