23968096324f8652200c88aa2c9fb47d76fb7da2
[external/binutils.git] / gas / testsuite / lib / gas-dg.exp
1 # Define gas callbacks for dg.exp.
2 # Copyright (C) 2012-2016 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, MA 02110-1301, USA.  
17
18 load_lib dg.exp
19
20 # The use of this function is still in a bit of flux.
21 # It should be theoretically possible to assemble, link, and run a file
22 # but we currently don't support that.  Assembler testcases aren't usually
23 # that elaborate anyway.  :-)
24
25 proc gas-dg-test { prog do_what tool_flags } {
26     # FIXME: the gas testsuite doesn't define tmpdir.  Use outdir?
27     set output_file "./a.out"
28
29     switch $do_what {
30         "preprocess" {
31         }
32         "assemble" {
33         }
34         "link" {
35         }
36         "run" {
37             # This is the only place where we care if an executable was
38             # created or not.  If it was, dg.exp will try to run it.
39             remote_file host delete "$output_file"
40         }
41         default {
42             perror "$do_what: not a valid dg-do keyword"
43             return ""
44         }
45     }
46
47     # gas_start prepends $srcdir/$subdir so we must remove it from PROG
48     # if present.  First remove extraneous //'s.
49     global srcdir subdir
50     set dir "$srcdir/$subdir"
51     regsub -all "//" $dir "/" dir
52     regsub -all "//" $prog "/" prog
53     if [string match "$dir/*" $prog] {
54         # We use (?q) to treat $dir as a literal.
55         regsub "(?q)$dir" $prog "" prog
56     }
57
58     # FIXME: This should be gas_start but it doesn't set comp_output.
59     return [gas_run $prog $tool_flags ""]
60 }
61
62 proc gas-dg-prune { system text } {
63     #send_user "Before:$text\n"
64     regsub -all "(^|\n)\[^\n\]*: Assembler messages:\[^\n\]*" $text "" text
65     regsub -all "(^|\n)\[^\n\]*: End of file not at end\[^\n\]*Newline inserted." $text "" text
66     #send_user "After:$text\n"
67
68     return $text
69 }