Add copyright notices
[binutils-gdb.git] / gas / testsuite / lib / gas-dg.exp
1 # Define gas callbacks for dg.exp.
2 # Copyright 2012
3 # Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
18
19 load_lib dg.exp
20
21 # The use of this function is still in a bit of flux.
22 # It should be theoretically possible to assemble, link, and run a file
23 # but we currently don't support that. Assembler testcases aren't usually
24 # that elaborate anyway. :-)
25
26 proc gas-dg-test { prog do_what tool_flags } {
27 # FIXME: the gas testsuite doesn't define tmpdir. Use outdir?
28 set output_file "./a.out"
29
30 switch $do_what {
31 "preprocess" {
32 }
33 "assemble" {
34 }
35 "link" {
36 }
37 "run" {
38 # This is the only place where we care if an executable was
39 # created or not. If it was, dg.exp will try to run it.
40 remote_file host delete "$output_file"
41 }
42 default {
43 perror "$do_what: not a valid dg-do keyword"
44 return ""
45 }
46 }
47
48 # gas_start prepends $srcdir/$subdir so we must remove it from PROG
49 # if present. First remove extraneous //'s.
50 global srcdir subdir
51 set dir "$srcdir/$subdir"
52 regsub -all "//" $dir "/" dir
53 regsub -all "//" $prog "/" prog
54 if [string match "$dir/*" $prog] {
55 # We use (?q) to treat $dir as a literal.
56 regsub "(?q)$dir" $prog "" prog
57 }
58
59 # FIXME: This should be gas_start but it doesn't set comp_output.
60 return [gas_run $prog $tool_flags ""]
61 }
62
63 proc gas-dg-prune { system text } {
64 #send_user "Before:$text\n"
65 regsub -all "(^|\n)\[^\n\]*: Assembler messages:\[^\n\]*" $text "" text
66 regsub -all "(^|\n)\[^\n\]*: End of file not at end\[^\n\]*Newline inserted." $text "" text
67 #send_user "After:$text\n"
68
69 return $text
70 }