aboutsummaryrefslogtreecommitdiff
path: root/libstdc++/testsuite/lib/libstdc++.exp
blob: 588f72a3a94f14455686bdf45de2c9e1af0045bd (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Copyright (C) 1997 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  

# Please email any bugs, comments, and/or additions to this file to:
# bug-lib-g++@prep.ai.mit.edu

# This file was written by Bob Manson. (manson@cygnus.com)

load_lib "libgloss.exp"

global tmpdir

if ![info exists tmpdir] {
    set tmpdir "/tmp"
}

#
# Build the status wrapper library as needed.
#
proc libstdc++_init { args } {
    global wrapper_file;
    global wrap_compile_flags;
    set wrapper_file "";
    set wrap_compile_flags "";
    if [target_info exists needs_status_wrapper] {
	set result [build_wrapper "testglue.o"];
	if { $result != "" } {
	    set wrapper_file [lindex $result 0];
	    set wrap_compile_flags [lindex $result 1];
	} else {
	    warning "Status wrapper failed to build."
	}
    }
}
#
# Run the test specified by srcfile and resultfile. compile_args and
# exec_args are additional arguments to be passed in when compiling and
# running the testcase, respectively.
#

proc test_libstdc++ { options srcfile compile_args inpfile resultfile exec_args } {
    global base_dir
    global LIBSTDCPP
    global srcdir subdir objdir
    global TOOL_OPTIONS

    if [info exists LIBSTDCPP] {
	set libstdcpp $LIBSTDCPP;
    } else {
	set gp [get_multilibs];
	if { $gp != "" } {
	    if [file exists "$gp/libstdc++/libstdc++.a"] {
		set libstdcpp "-L$gp/libstdc++ -lstdc++";
	    }
	}
	if ![info exists libstdcpp] {
	set libstdcpp [findfile $base_dir/../../libstdc++/libstdc++.a "-L$base_dir/../../libstdc++ -lstdc++" -lstdc++]
	}
    }

    verbose "using LIBSTDCPP = $libstdcpp" 2
    set args ""
    if { $compile_args != "" } {
	lappend args "additional_flags=$compile_args"
    }
    lappend args "incdir=.."
    lappend args "incdir=$srcdir/.."
    lappend args "incdir=$srcdir/../stl"
    lappend args "incdir=."
    if [info exists TOOL_OPTIONS] {
	lappend args "additional_flags=$TOOL_OPTIONS"
    }

    global wrapper_file wrap_compile_flags;
    # We have to include libio, for _G_config.h.
    lappend args "additional_flags=$wrap_compile_flags";
    lappend args "libs=$wrapper_file";
    lappend args "libs=$libstdcpp";
    lappend args "additional_flags=[libio_include_flags]"
    lappend args "additional_flags=[g++_link_flags]"
    lappend args debug

    regsub "^.*/(\[^/.\]+)\[.\]\[^/]*$" "$srcfile" "\\1" out
    set executable "${objdir}/$out"
    set errname "[file tail $srcfile]"
    if { $compile_args != "" } {
	set errname "$errname $compile_args"
    }

    if { [target_compile $srcfile "$executable" executable $args] != "" } {
	fail "$errname compilation"
	setup_xfail "*-*-*"
	fail "$errname execution"
	setup_xfail "*-*-*"
	fail "$errname output"
	return;
    }
    pass "$errname compilation"

    set result [libstdc++_load $executable "$exec_args" "$inpfile"];
    set status [lindex $result 0];
    set output [lindex $result 1];
    $status "$errname execution"
    if { $status != "pass" } {
	setup_xfail "*-*-*"
	fail "$errname output"
	return;
    }

    verbose "resultfile is $resultfile"
    set id [open $resultfile r];
    set expected ""
    append expected [read $id];
    regsub -all "\r" "$output" "" output;
    regsub "\n*$" $expected "" expected
    regsub "\n*$" $output "" output
    regsub "^\n*" $expected "" expected
    regsub "^\n*" $output "" output
    regsub -all "\[ \t\]\[ \t\]*" $expected " " expected
    regsub -all "\[ \t\]*\n\n*" $expected "\n" expected
    regsub -all "\[ \t\]\[ \t\]*" $output " " output
    regsub -all "\[ \t\]*\n\n*" $output "\n" output
    verbose "expected is $expected"
    verbose "actual is $output"
    set passed 0;
    if {$options == "regexp_match"} {
	if [regexp $expected $output] {
	    set passed 1;
	}
    } else {
	if { $expected == $output } {
	    set passed 1;
	}
    }
    if { $passed == 1 } {
	pass "$errname output"
    } else {
	clone_output "expected was $expected"
	clone_output "output was $output"
	fail "$errname output"
    }
    close $id;
}

#
# libstdc++_version -- extract and print the version number of libstdc++p
#
proc default_libstdc++_version {} {
}

proc default_libstdc++_start { } {
}