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 proc libio_init { args } {
28 global wrap_compile_flags;
30 set wrap_compile_flags "";
31 if [target_info exists needs_status_wrapper] {
32 set result [build_wrapper "testglue.o"];
33 if { $result != "" } {
34 set wrapper_file [lindex $result 0];
35 set wrap_compile_flags [lindex $result 1];
37 warning "Status wrapper failed to build."
42 # Run the test specified by srcfile and resultfile. compile_args and
43 # exec_args are additional arguments to be passed in when compiling and
44 # running the testcase, respectively.
47 proc test_libio { srcfile compile_args inpfile resultfile exec_args } {
49 global srcdir subdir objdir
51 global wrapper_file wrap_compile_flags
52 global ld_library_path
54 if { $inpfile != "" } {
55 set inpfile "$srcdir/../tests/$inpfile"
59 set ld_library_path ""
60 lappend args "additional_flags=-O3";
61 lappend args "additional_flags=-I.. -I$srcdir/.."
62 lappend args "additional_flags=$wrap_compile_flags";
63 lappend args "libs=$wrapper_file";
64 if { $compile_args != "" } {
65 lappend args "additional_flags=$compile_args"
68 if [regexp "\.cc$" $srcfile] {
69 lappend args "additional_flags=-nostdinc++"
70 lappend args "additional_flags=[libstdc++_include_flags]";
71 lappend args "additional_flags=[libstdc++_link_flags]";
72 lappend args "libs=-lstdc++"
74 if [info exists LIBIO] {
75 lappend args "libdir=$LIBIO"
77 lappend args "additional_flags=[libio_link_flags]";
79 lappend args "additional_flags=[libio_link_flags]";
80 lappend args "libs=-lio"
83 if [target_info exists slow_simulator] then {
84 lappend args "additional_flags=-DSLOW_SIMULATOR"
87 if [info exists TOOL_OPTIONS] {
88 lappend args "additional_options=$TOOL_OPTIONS"
91 set gp [get_multilibs];
93 if [file exists $gp/libiberty/libiberty.a] {
94 lappend args "libdir=$gp/libiberty";
95 set found_libiberty 1;
98 if ![info exists found_libiberty] {
99 set lib [lookfor_file "$objdir" "libiberty/libiberty.a"];
101 lappend args "libdir=[file dirname $lib]";
104 lappend args "libs=-liberty"
105 lappend args "debug";
107 set errname "$srcfile"
108 set srcfile "$srcdir/../tests/$srcfile"
109 regsub "\\..*$" "[file tail $srcfile]" "" executable
110 set executable "$objdir/$executable"
112 if { [target_compile $srcfile $executable executable $args] != "" } {
113 fail "$errname compilation $exec_args";
115 fail "$errname execution $exec_args"
116 if { $resultfile != "" } {
118 fail "$errname output $exec_args"
122 pass "$errname compilation $exec_args"
124 set result [libio_load $executable $exec_args $inpfile];
125 set status [lindex $result 0];
126 set output [lindex $result 1];
127 if { $status == "unsupported" } {
128 unsupported "target does not support loading $srcfile"
131 if { $status != "pass" } {
132 $status "$errname execution $exec_args"
134 fail "$errname output $exec_args"
137 pass "$errname execution $exec_args"
139 if { $resultfile != "" } {
140 set id [open $srcdir/../tests/$resultfile r];
142 append expected [read $id];
143 verbose "expected is $expected"
144 verbose "actual is $output"
145 regsub -all "\r" $output "" output
146 regsub "\n+$" $expected "" expected
147 regsub "\n+$" $output "" output
148 regsub "^\n+" $expected "" expected
149 regsub "^\n+" $output "" output
150 if { $expected == $output } {
151 pass "$errname output $exec_args"
153 fail "$errname output $exec_args"
160 # libio_version -- extract and print the version number of libio
162 proc default_libio_version {} {
166 proc default_libio_start { } {