1 # Copyright (C) 1997 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-lib-g++@prep.ai.mit.edu
20 # This file was written by Bob Manson. (manson@cygnus.com)
22 load_lib "libgloss.exp"
26 if ![info exists tmpdir] {
31 # Build the status wrapper library as needed.
33 proc libstdc++_init { args } {
35 global wrap_compile_flags;
37 set wrap_compile_flags "";
38 if [target_info exists needs_status_wrapper] {
39 set result [build_wrapper "testglue.o"];
40 if { $result != "" } {
41 set wrapper_file [lindex $result 0];
42 set wrap_compile_flags [lindex $result 1];
44 warning "Status wrapper failed to build."
49 # Run the test specified by srcfile and resultfile. compile_args and
50 # exec_args are additional arguments to be passed in when compiling and
51 # running the testcase, respectively.
54 proc test_libstdc++ { options srcfile compile_args inpfile resultfile exec_args } {
57 global srcdir subdir objdir
59 global ld_library_path
61 if [info exists LIBSTDCPP] {
62 set libstdcpp $LIBSTDCPP;
64 set gp [get_multilibs];
66 if [file exists "$gp/libstdc++/libstdc++.a"] {
67 set libstdcpp "-L$gp/libstdc++ -lstdc++";
70 if ![info exists libstdcpp] {
71 set libstdcpp [findfile $base_dir/../../libstdc++/libstdc++.a "-L$base_dir/../../libstdc++ -lstdc++" -lstdc++]
75 verbose "using LIBSTDCPP = $libstdcpp" 2
78 # Basically we want to build up a colon separated path list from
79 # the value of $libstdcpp.
81 # First strip away any -L arguments.
82 regsub -all -- "-L" $libstdcpp "" ld_library_path
84 # Then remove any -lstdc++ argument.
85 regsub -all -- " -lstdc.." $ld_library_path "" ld_library_path
87 # That's enough to make things work for the normal case.
88 # If we wanted to handle an arbitrary value of libstdcpp,
89 # then we'd have to do a lot more work.
91 if { $compile_args != "" } {
92 lappend args "additional_flags=$compile_args"
94 lappend args "incdir=.."
95 lappend args "incdir=$srcdir/.."
96 lappend args "incdir=$srcdir/../stl"
97 lappend args "incdir=."
98 if [info exists TOOL_OPTIONS] {
99 lappend args "additional_flags=$TOOL_OPTIONS"
102 global wrapper_file wrap_compile_flags;
103 # We have to include libio, for _G_config.h.
104 lappend args "additional_flags=$wrap_compile_flags";
105 lappend args "libs=$wrapper_file";
106 lappend args "libs=$libstdcpp";
107 lappend args "additional_flags=[libio_include_flags]"
110 regsub "^.*/(\[^/.\]+)\[.\]\[^/]*$" "$srcfile" "\\1" out
111 set executable "${objdir}/$out"
112 set errname "[file tail $srcfile]"
113 if { $compile_args != "" } {
114 set errname "$errname $compile_args"
117 if { [target_compile $srcfile "$executable" executable $args] != "" } {
118 fail "$errname compilation"
120 fail "$errname execution"
122 fail "$errname output"
125 pass "$errname compilation"
127 set result [libstdc++_load $executable "$exec_args" "$inpfile"];
128 set status [lindex $result 0];
129 set output [lindex $result 1];
130 $status "$errname execution"
131 if { $status != "pass" } {
133 fail "$errname output"
137 verbose "resultfile is $resultfile"
138 set id [open $resultfile r];
140 append expected [read $id];
141 regsub -all "\r" "$output" "" output;
142 regsub "\n*$" $expected "" expected
143 regsub "\n*$" $output "" output
144 regsub "^\n*" $expected "" expected
145 regsub "^\n*" $output "" output
146 regsub -all "\[ \t\]\[ \t\]*" $expected " " expected
147 regsub -all "\[ \t\]*\n\n*" $expected "\n" expected
148 regsub -all "\[ \t\]\[ \t\]*" $output " " output
149 regsub -all "\[ \t\]*\n\n*" $output "\n" output
150 verbose "expected is $expected"
151 verbose "actual is $output"
153 if {$options == "regexp_match"} {
154 if [regexp $expected $output] {
158 if { $expected == $output } {
162 if { $passed == 1 } {
163 pass "$errname output"
165 clone_output "expected was $expected"
166 clone_output "output was $output"
167 fail "$errname output"
173 # libstdc++_version -- extract and print the version number of libstdc++p
175 proc default_libstdc++_version {} {
178 proc default_libstdc++_start { } {