This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] new g++.exp procs



Here is an implementation of Gaby's suggestion.  A new routine
testsuite/gcc-deps.exp (using the naming convention for gas-deps.exp
and sim-deps.exp) has been created which contains procs common to
gcc.exp and g++.exp.  Tested with 'make check-gcc' and 'make
check-g++' on i686-pc-linux-gnu.

Index: g++.exp
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/lib/g++.exp,v
retrieving revision 1.20
diff -u -2 -p -r1.20 g++.exp
--- g++.exp	2001/05/23 16:15:03	1.20
+++ g++.exp	2001/07/26 02:08:55
@@ -30,10 +30,15 @@
 set gpp_compile_options ""
 
+    load_lib gcc-defs.exp
+
 #
 # g++_version -- extract and print the version number of the compiler
 #
+
 proc g++_version { } {
     global GXX_UNDER_TEST
     
+    g++_init
+
     # ignore any arguments after the command
     set compiler [lindex $GXX_UNDER_TEST 0]
@@ -61,7 +66,8 @@ proc g++_version { } {
 
 #
-# provide new versions of g++_include_flags and g++_link_flags (both
-# originally from libgloss.exp) which know about the new gcc tree structure
+# g++_include_flags -- provide new version of g++_include_flags
+# (originally from libgloss.exp) which knows about the gcc tree structure
 #
+
 proc g++_include_flags { args } {
     global srcdir
@@ -94,4 +100,9 @@ proc g++_include_flags { args } {
 }
 
+#
+# g++_link_flags -- provide new version of g++_link_flags
+# (originally from libgloss.exp) which knows about the gcc tree structure
+#
+
 proc g++_link_flags { args } {
     global rootme
@@ -236,4 +247,7 @@ proc g++_init { args } {
 }
 
+#
+# g++_target_compile -- compile a source file
+#
 
 proc g++_target_compile { source dest type options } {
@@ -265,13 +279,4 @@ proc g++_target_compile { source dest ty
 }
 
-proc g++_exit { args } {
-    global gluefile;
-
-    if [info exists gluefile] {
-	file_on_build delete $gluefile;
-	unset gluefile;
-    }
-}
-
 # If this is an older version of dejagnu (without runtest_file_p),
 # provide one and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
@@ -299,4 +304,6 @@ if { [info procs prune_warnings] == "" }
 }
 
+#
+# g++_set_ld_library_path --
 # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
 # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
@@ -305,4 +312,5 @@ if { [info procs prune_warnings] == "" }
 # proper, so we do it here, by trickery.  We really only need to do 
 # this on IRIX, but it shouldn't hurt to do it anywhere else.
+#
 
 proc g++_set_ld_library_path { name element op } {
@@ -313,24 +321,15 @@ proc g++_set_ld_library_path { name elem
 trace variable env(LD_LIBRARY_PATH) w g++_set_ld_library_path
 
-# Utility used by mike-g++.exp and old-dejagnu.exp.
-# Check the compiler(/assembler/linker) output for text indicating that
-# the testcase should be marked as "unsupported".
-#
-# When dealing with a large number of tests, it's difficult to weed out the
-# ones that are too big for a particular cpu (eg: 16 bit with a small amount
-# of memory).  There are various ways to deal with this.  Here's one.
-# Fortunately, all of the cases where this is likely to happen will be using
-# gld so we can tell what the error text will look like.
-
-proc ${tool}_check_unsupported_p { output } {
-    if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
-	return "memory full"
-    }
-    return ""
-}
+#
+# ${tool}_option_help
+#
 
 proc ${tool}_option_help { } {
-    send_user "--additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated."
+    send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
 }
+
+#
+# ${tool}_option_proc
+#
 
 proc ${tool}_option_proc { option } {
Index: gcc-defs.exp
===================================================================
RCS file: gcc-defs.exp
diff -N gcc-defs.exp
--- /dev/null	Tue May  5 13:32:27 1998
+++ gcc-defs.exp	Wed Jul 25 19:08:55 2001
@@ -0,0 +1,169 @@
+# Copyright (C) 2001 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#
+# ${tool}_check_compile -- Reports and returns pass/fail for a compilation
+#
+
+proc ${tool}_check_compile {testcase option objname gcc_output} {
+    global tool
+    set fatal_signal "*cc: Internal compiler error: program*got fatal signal"
+ 
+    if [string match "$fatal_signal 6" $gcc_output] then {
+	${tool}_fail $testcase "Got Signal 6, $option"
+	return 0
+    }
+
+    if [string match "$fatal_signal 11" $gcc_output] then {
+	${tool}_fail $testcase "Got Signal 11, $option"
+	return 0
+    }
+
+    # We shouldn't get these because of -w, but just in case.
+    if [string match "*cc:*warning:*" $gcc_output] then {
+	warning "$testcase: (with warnings) $option"
+	send_log "$gcc_output\n"
+	unresolved "$testcase, $option"
+	return 0
+    }
+
+    set gcc_output [prune_warnings $gcc_output]
+
+    set unsupported_message [${tool}_check_unsupported_p $gcc_output]
+    if { $unsupported_message != "" } {
+	unsupported "$testcase: $unsupported_message"
+	return 0
+    }
+
+    # remove any leftover LF/CR to make sure any output is legit
+    regsub -all -- "\[\r\n\]*" $gcc_output "" gcc_output
+
+    # If any message remains, we fail.
+    if ![string match "" $gcc_output] then {
+	${tool}_fail $testcase $option
+	return 0
+    }
+
+    # fail if the desired object file doesn't exist.
+    # FIXME: there's no way of checking for existence on a remote host.
+    if {$objname != "" && ![is3way] && ![file exists $objname]} {
+	${tool}_fail $testcase $option
+	return 0
+    }
+
+    ${tool}_pass $testcase $option
+    return 1
+}
+
+#
+# ${tool}_pass -- utility to record a testcase passed
+#
+
+proc ${tool}_pass { testcase cflags } {
+    if { "$cflags" == "" } {
+	pass "$testcase"
+    } else {
+	pass "$testcase, $cflags"
+    }
+}
+
+#
+# ${tool}_fail -- utility to record a testcase failed
+#
+
+proc ${tool}_fail { testcase cflags } {
+    if { "$cflags" == "" } {
+	fail "$testcase"
+    } else {
+	fail "$testcase, $cflags"
+    }
+}
+
+#
+# ${tool}_finish -- called at the end of every script that calls ${tool}_init
+#
+# Hide all quirks of the testing environment from the testsuites.  Also
+# undo anything that ${tool}_init did that needs undoing.
+#
+
+proc ${tool}_finish { } {
+    # The testing harness apparently requires this.
+    global errorInfo;
+
+    if [info exists errorInfo] then {
+	unset errorInfo
+    }
+
+    # Might as well reset these (keeps our caller from wondering whether
+    # s/he has to or not).
+    global prms_id bug_id
+    set prms_id 0
+    set bug_id 0
+}
+
+#
+# ${tool}_exit -- Does final cleanup when testing is complete
+#
+
+proc ${tool}_exit { } {
+    global gluefile;
+
+    if [info exists gluefile] {
+	file_on_build delete $gluefile;
+	unset gluefile;
+    }
+}
+    
+#
+# ${tool}_check_unsupported_p -- Check the compiler(/assembler/linker) output 
+#	for text indicating that the testcase should be marked as "unsupported"
+#
+# Utility used by mike-gcc.exp and c-torture.exp.
+# When dealing with a large number of tests, it's difficult to weed out the
+# ones that are too big for a particular cpu (eg: 16 bit with a small amount
+# of memory).  There are various ways to deal with this.  Here's one.
+# Fortunately, all of the cases where this is likely to happen will be using
+# gld so we can tell what the error text will look like.
+#
+
+proc ${tool}_check_unsupported_p { output } {
+    if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
+	return "memory full"
+    }
+    return ""
+}
+
+#
+# prune_${tool}_output -- Prune messages that aren't useful.
+#
+
+proc prune_${tool}_output { text } {
+    #send_user "Before:$text\n"
+    regsub -all "(^|\n)\[^\n\]*: In (function|method) \[^\n\]*" $text "" text
+    regsub -all "(^|\n)\[^\n\]*: At top level:\[^\n\]*" $text "" text
+
+    # It would be nice to avoid passing anything to gcc that would cause it to
+    # issue these messages (since ignoring them seems like a hack on our part),
+    # but that's too difficult in the general case.  For example, sometimes
+    # you need to use -B to point gcc at crt0.o, but there are some targets
+    # that don't have crt0.o.
+    regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $text "" text
+    regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $text "" text
+
+    #send_user "After:$text\n"
+
+    return $text
+}
Index: gcc.exp
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/lib/gcc.exp,v
retrieving revision 1.5
diff -u -2 -p -r1.5 gcc.exp
--- gcc.exp	2001/02/08 02:29:38	1.5
+++ gcc.exp	2001/07/26 02:08:55
@@ -1,3 +1,4 @@
 # Copyright (C) 1992, 1993, 1994, 1996, 1997, 1999 Free Software Foundation, Inc.
+# 2000, 2001 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -27,4 +28,5 @@
 # we want to use libgloss so we can get find_gcc.
 load_lib libgloss.exp
+load_lib gcc-defs.exp
 
 #
@@ -68,6 +70,7 @@ proc default_gcc_version { } {
 
 #
-# Call gcc_version. We do it this way so we can override it if needed.
+# gcc_version -- Call default_gcc_version, so we can override it if needed.
 #
+
 proc gcc_version { } {
     default_gcc_version;
@@ -116,4 +119,8 @@ proc gcc_init { args } {
 }
 
+#
+# gcc_target_compile -- compile a source file
+#
+
 proc gcc_target_compile { source dest type options } {
     global tmpdir;
@@ -149,114 +156,4 @@ proc gcc_target_compile { source dest ty
 }
 
-
-# Reports pass/fail for a gcc compilation and returns true/false.
-proc gcc_check_compile {testcase option objname gcc_output} {
-
-    set fatal_signal "*cc: Internal compiler error: program*got fatal signal"
- 
-    if [string match "$fatal_signal 6" $gcc_output] then {
-	gcc_fail $testcase "Got Signal 6, $option"
-	return 0
-    }
-
-    if [string match "$fatal_signal 11" $gcc_output] then {
-	gcc_fail $testcase "Got Signal 11, $option"
-	return 0
-    }
-
-    # We shouldn't get these because of -w, but just in case.
-    if [string match "*cc:*warning:*" $gcc_output] then {
-	warning "$testcase: (with warnings) $option"
-	send_log "$gcc_output\n"
-	unresolved "$testcase, $option"
-	return 0
-    }
-
-    set gcc_output [prune_warnings $gcc_output]
-
-    set unsupported_message [gcc_check_unsupported_p $gcc_output]
-    if { $unsupported_message != "" } {
-	unsupported "$testcase: $unsupported_message"
-	return 0
-    }
-
-    # remove any leftover LF/CR to make sure any output is legit
-    regsub -all -- "\[\r\n\]*" $gcc_output "" gcc_output
-
-    # If any message remains, we fail.
-    if ![string match "" $gcc_output] then {
-	gcc_fail $testcase $option
-	return 0
-    }
-
-    # fail if the desired object file doesn't exist.
-    # FIXME: there's no way of checking for existence on a remote host.
-    if {$objname != "" && ![is3way] && ![file exists $objname]} {
-	gcc_fail $testcase $option
-	return 0
-    }
-
-    gcc_pass $testcase $option
-    return 1
-}
-
-
-
-#
-# gcc_pass -- utility to record a testcase passed
-#
-
-proc gcc_pass { testcase cflags } {
-    if { "$cflags" == "" } {
-	pass "$testcase"
-    } else {
-	pass "$testcase, $cflags"
-    }
-}
-
-#
-# gcc_fail -- utility to record a testcase failed
-#
-
-proc gcc_fail { testcase cflags } {
-    if { "$cflags" == "" } {
-	fail "$testcase"
-    } else {
-	fail "$testcase, $cflags"
-    }
-}
-
-#
-# gcc_finish -- called at the end of every .exp script that calls gcc_init
-#
-# The purpose of this proc is to hide all quirks of the testing environment
-# from the testsuites.  It also exists to undo anything that gcc_init did
-# (that needs undoing).
-#
-
-proc gcc_finish { } {
-    # The testing harness apparently requires this.
-    global errorInfo;
-
-    if [info exists errorInfo] then {
-	unset errorInfo
-    }
-
-    # Might as well reset these (keeps our caller from wondering whether
-    # s/he has to or not).
-    global prms_id bug_id
-    set prms_id 0
-    set bug_id 0
-}
-
-proc gcc_exit { } {
-    global gluefile;
-
-    if [info exists gluefile] {
-	file_on_build delete $gluefile;
-	unset gluefile;
-    }
-}
-    
 # If this is an older version of dejagnu (without runtest_file_p),
 # provide one and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
@@ -283,40 +180,2 @@ if { [info procs prune_warnings] == "" }
     }
 }
-
-# Utility used by mike-gcc.exp and c-torture.exp.
-# Check the compiler(/assembler/linker) output for text indicating that
-# the testcase should be marked as "unsupported".
-#
-# When dealing with a large number of tests, it's difficult to weed out the
-# ones that are too big for a particular cpu (eg: 16 bit with a small amount
-# of memory).  There are various ways to deal with this.  Here's one.
-# Fortunately, all of the cases where this is likely to happen will be using
-# gld so we can tell what the error text will look like.
-
-proc ${tool}_check_unsupported_p { output } {
-    if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
-	return "memory full"
-    }
-    return ""
-}
-
-# Prune messages from gcc that aren't useful.
-
-proc prune_gcc_output { text } {
-    #send_user "Before:$text\n"
-    regsub -all "(^|\n)\[^\n\]*: In (function|method) \[^\n\]*" $text "" text
-    regsub -all "(^|\n)\[^\n\]*: At top level:\[^\n\]*" $text "" text
-
-    # It would be nice to avoid passing anything to gcc that would cause it to
-    # issue these messages (since ignoring them seems like a hack on our part),
-    # but that's too difficult in the general case.  For example, sometimes
-    # you need to use -B to point gcc at crt0.o, but there are some targets
-    # that don't have crt0.o.
-    regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $text "" text
-    regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $text "" text
-
-    #send_user "After:$text\n"
-
-    return $text
-}
-


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]