Optimize _bfd_elf_allocate_ifunc_dyn_relocs.
[binutils.git] / gold / testsuite / incremental_test.sh
blob930d7d14cf9ed876d07d8728ef8bf3c6912b7732
1 #!/bin/sh
3 # incremental_test.sh -- test that incremental linking information is correct.
5 # Copyright 2009, 2010 Free Software Foundation, Inc.
6 # Written by Rafael Avila de Espindola <espindola@google.com>
7 # and Cary Coutant <ccoutant@google.com>
9 # This file is part of gold.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 3 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
24 # MA 02110-1301, USA.
26 check_cmp()
28 if ! cmp -s "$1" "$2"
29 then
30 echo "Actual output differs from expected:"
31 echo "diff $1 $2"
32 diff $1 $2
33 exit 1
37 check()
39 if ! grep -q "$2" "$1"
40 then
41 echo "Did not find expected output in $1:"
42 echo " $2"
43 echo ""
44 echo "Actual output below:"
45 cat "$1"
46 exit 1
50 # Extract actual command line from linker's -v output.
51 cat incremental_test.cmdline |
52 grep "gcctestdir/ld " |
53 sed "s/--incremental[-a-z]* //g" |
54 cut -d ' ' -f 2- > actual
56 # Extract recorded command line from dump of the output file.
57 cat incremental_test.stdout |
58 grep "Link command line" |
59 cut -d : -f 2- |
60 cut -d ' ' -f 3- |
61 sed "s/'//g" > recorded
63 # Verify that the command line was recorded correctly.
64 check_cmp actual recorded
66 rm -f actual recorded
68 # Filter the incremental-dump output into a format that can be grepped
69 # more easily.
71 awk '
72 /^[A-Za-z][A-Za-z ]+:$/ { section = $0; }
73 /^[[]/ { subsection = $0; }
74 /^ / { print section, subsection, $0; }
75 ' < incremental_test.stdout > incremental_test.dump
77 check incremental_test.dump "Input sections: .* incremental_test_1.o *1 "
78 check incremental_test.dump "Input sections: .* incremental_test_2.o *1 "
79 check incremental_test.dump "Global symbol table: .* main .* relocation type "
80 check incremental_test.dump "Global symbol table: .* a *incremental_test_1.o "
81 check incremental_test.dump "Global symbol table: .* a .* relocation type "
82 check incremental_test.dump "Global symbol table: .* b *incremental_test_2.o "
83 check incremental_test.dump "Global symbol table: .* b .* relocation type "
84 check incremental_test.dump "Global symbol table: .* t1 *incremental_test_2.o "
85 check incremental_test.dump "Global symbol table: .* t1 .* relocation type "
87 rm -f incremental_test.dump
89 exit 0