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]
Other format: [Raw text]

[libstdc++ 1/2] Add testsuite comments, shuffle a bit of code.


The changes needed to support Eric's iconv tests are minimal, once you
know where everything goes and what the magic names are.  Has any of that
ever been written down?  Only in target.exp Tcl comments.

Last time I had to figure all this stuff out, I added comments.  Ha!
They weren't enough.  So this time I added more.  Also, some of the harness
code is moved around, with an eye towards enabling the interactive tests
which currently have to be run by hand (we're using Expect, after all;
if any language should be able to do that, it's Expect).

Eric needed a new dg-xxx keyword, and we've had some of our own that we've
wanted for a while, so I started a new file for them.


2004-02-27  Phil Edwards  <phil@codesourcery.com>

	* testsuite/config/default.exp:  Update with comments.
	(${tool}_target_compile):  New wrapper routine.
	* testsuite/lib/dg-options.exp:  New file, with dg-require-iconv.
	* testsuite/lib/libstdc++.exp:  Update with comments and cosmetic
	fixes.
	(load_gcc_lib, v3track):  New routines.
	(v3-init):  Rename to libstdc++_init.
	* testsuite/libstdc++-dg/normal.exp:  No longer call v3-init.
	Move DEFAULT_CXXFLAGS handling into libstdc++_init.


Index: testsuite/config/default.exp
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/config/default.exp,v
retrieving revision 1.3
diff -u -p -r1.3 default.exp
--- testsuite/config/default.exp	12 May 2001 16:52:35 -0000	1.3
+++ testsuite/config/default.exp	27 Feb 2004 21:42:41 -0000
@@ -1,5 +1,7 @@
-# Copyright (C) 2001 Free Software Foundation, Inc.
+# libstdc++ "tool-and-target file" for DejaGNU
 
+# Copyright (C) 2001, 2004 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
@@ -14,8 +16,18 @@
 # 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:
-# libstdc++@gcc.gnu.org
 
+# This file is loaded only if a target-specific file or OS-specific file
+# is not found first.  It should provide libstdc++_load, which runs a
+# program.  (The default calls the standard remote_load.)  It may also
+# provide libstdc++_compile, but this is not presently used.  It must
+# provide libstdc++_target_compile, which does the same thing and is used.
+
+# Here are the default definitions:
 load_lib "standard.exp"
+
+# target-supports.exp uses this
+proc ${tool}_target_compile { srcfile destfile compile_type options } {
+    target_compile $srcfile $destfile $compile_type $options
+}
 
Index: testsuite/lib/dg-options.exp
===================================================================
RCS file: testsuite/lib/dg-options.exp
diff -N testsuite/lib/dg-options.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/lib/dg-options.exp	27 Feb 2004 21:42:41 -0000
@@ -0,0 +1,29 @@
+# Handlers for additional dg-xxx keywords in tests.
+
+# Copyright (C) 2004 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.  
+
+
+# Copied from GCC.
+proc dg-require-iconv { args } {
+    if { ![ check_iconv_available ${args} ] } {
+	upvar dg-do-what dg-do-what
+	set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+	return
+    }
+    return
+}
+
Index: testsuite/lib/libstdc++.exp
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/lib/libstdc++.exp,v
retrieving revision 1.15
diff -u -p -r1.15 libstdc++.exp
--- testsuite/lib/libstdc++.exp	12 Jan 2004 20:47:44 -0000	1.15
+++ testsuite/lib/libstdc++.exp	27 Feb 2004 21:42:41 -0000
@@ -1,5 +1,7 @@
-# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+# libstdc++ "tool init file" for DejaGNU
 
+# Copyright (C) 2001, 2002, 2003, 2004 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
@@ -14,11 +16,46 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
 
-# Define callbacks for dg.exp.  This file is loaded early.
 
+# Define callbacks and load other libraries.  This file is loaded relatively
+# early, and before any other file we write ourselves.  "load_lib" will
+# find anything in the DejaGNU installation tree, or in our lib directory.
+# "load_gcc_lib" will search the core compiler's .exp collection instead.
+#
+# The naming rule is that dg.exp looks for "tool-" and runtest.exp looks
+# for "tool_" when finding callbacks.  Utility routines we define for
+# our callbacks begin with "v3-".
+#
+# libstdc++_* callbacks we don't define, but could:
+# ..._option_help           prints additional --help output
+# ..._option_proc (--foo)   process our own options
+# ..._exit                  cleanup routines (do we need any?)
+# ..._init (normal.exp)     called once per test file
+# ..._finish                bracketing function for libstdc++_init
+# ...-dg-prune              removing output text, see top of system dg.exp
+#
+# Useful hook:  if ${hostname}_init exists, it will be called, almost
+# the last thing before testing begins.  This can be defined in, e.g.,
+# ~/.dejagnurc or $DEJAGNU.
+
+proc load_gcc_lib { filename } {
+    global srcdir
+    load_file $srcdir/../../gcc/testsuite/lib/$filename
+}
+
+# system routines
 load_lib dg.exp
 load_lib libgloss.exp
+# compiler routines, then ours
 load_lib prune.exp
+load_lib dg-options.exp
+
+# Useful for debugging.  Pass the name of a variable and the verbosity
+# threshold (number of -v's on the command line).
+proc v3track { var n } {
+    upvar $var val
+    verbose "++ $var is $val" $n
+}
 
 # Called by v3-init below.  "Static" to this file.
 proc v3-copy-files {srcfiles dstdir} {
@@ -36,22 +73,44 @@ proc v3-copy-files {srcfiles dstdir} {
     }
 }
 
-# Called once, from libstdc++/dg.exp.
-proc v3-init { args } {
-    global srcdir
-    global outdir
-    global blddir
-    global cxx
+# Called once, during runtest.exp setup.
+proc libstdc++_init { testfile } {
+    global env
+    global srcdir outdir blddir objdir tool_root_dir
+    global cxx cxxflags
     global includes
-    global cxxflags
-    global objdir
     global gluefile wrap_flags
-    global env
-    global ld_library_path
-    global original_ld_library_path
-    global tool_root_dir
+    global ld_library_path original_ld_library_path
+    global target_triplet
 
     set blddir [lookfor_file [get_multilibs] libstdc++-v3]
+    set flags_file "${blddir}/scripts/testsuite_flags"
+    v3track flags_file 2
+
+    # If a test doesn't have special options, use DEFAULT_CXXFLAGS.
+    # Use this variable if the behavior
+    #   1) only applies to libstdc++ testing
+    #   2) might need to be negated 
+    # In particular, some tests have to be run without precompiled
+    # headers, or without assertions.
+    global DEFAULT_CXXFLAGS
+    if ![info exists DEFAULT_CXXFLAGS] then {
+	set DEFAULT_CXXFLAGS "-D_GLIBCXX_ASSERT"
+
+	# Set up includes for stdc++.h.gch, the precompiled header file.
+	if { [file exists $flags_file] } {
+	    set cxxpchflags [exec sh $flags_file --cxxpchflags]
+	} else {
+	    set cxxpchflags ""
+	}
+	append DEFAULT_CXXFLAGS " ${cxxpchflags}"
+
+	# Host specific goo here.
+	if { [string match "powerpc-*-darwin*" $target_triplet] } {
+	    append DEFAULT_CXXFLAGS " -multiply_defined suppress"
+	} 
+    }
+    v3track DEFAULT_CXXFLAGS 2
 
     # By default, we assume we want to run program images.
     global dg-do-what-default
@@ -87,6 +146,7 @@ proc v3-init { args } {
     if {$gccdir != ""} {
         set gccdir [file dirname $gccdir]
     }
+    v3track gccdir 3
 
     # Compute what needs to be added to the existing LD_LIBRARY_PATH.
     set ld_library_path ""
@@ -138,7 +198,6 @@ proc v3-init { args } {
       set includes "-I./"
     } else {
         # If we find a testsuite_flags file, we're testing in the build dir.
-        set flags_file "${blddir}/scripts/testsuite_flags"
         if { [file exists $flags_file] } {
             set cxx [exec sh $flags_file --build-cxx]
             set cxxflags [exec sh $flags_file --cxxflags]
@@ -166,7 +225,6 @@ proc v3-init { args } {
 # Callback from system dg-test.
 proc libstdc++-dg-test { prog do_what extra_tool_flags } {
     # Set up the compiler flags, based on what we're going to do.
-
     switch $do_what {
         "preprocess" {
             set compile_type "preprocess"
@@ -204,6 +262,8 @@ proc libstdc++-dg-test { prog do_what ex
         lappend options "additional_flags=$extra_tool_flags"
     }
 
+    # There is a libstdc++_compile made for us by default (via the tool-
+    # and-target file), but the defaults are lacking in goodness.
     set comp_output [v3_target_compile "$prog" "$output_file" "$compile_type" $options];
     set comp_output [ prune_g++_output $comp_output ];
 
@@ -242,7 +302,7 @@ proc v3_target_compile { source dest typ
 }
 
 
-# Called once, from libstdc++*/dg.exp.
+# Called once, from libstdc++/normal.exp.
 proc v3-list-tests { filename } {
     global srcdir
     global outdir
Index: testsuite/libstdc++-dg/normal.exp
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/libstdc++-dg/normal.exp,v
retrieving revision 1.3
diff -u -p -r1.3 normal.exp
--- testsuite/libstdc++-dg/normal.exp	22 Dec 2003 20:09:23 -0000	1.3
+++ testsuite/libstdc++-dg/normal.exp	27 Feb 2004 21:42:41 -0000
@@ -1,5 +1,7 @@
-#   Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+# Primary test file for libstdc++.
 
+# Copyright (C) 2001, 2002, 2003, 2004 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
@@ -18,36 +20,9 @@
 
 # Initialization.
 dg-init
-v3-init
-
-# If a libstdc++ test file doesn't have special options, use DEFAULT_CXXFLAGS.
-# Use this variable if the behavior
-# 1) only applies to libstdc++ testing
-# 2) might need to be negated 
-# In particular, some tests have to be run without precompiled
-# headers, or without assertions.
-global blddir
-global target_triplet
-global DEFAULT_CXXFLAGS
-if ![info exists DEFAULT_CXXFLAGS] then {
-    set DEFAULT_CXXFLAGS "-D_GLIBCXX_ASSERT"
-
-    # Set up includes for stdc++.h.gch, the precompiled header file.
-    set flags_file "${blddir}/scripts/testsuite_flags"
-    if { [file exists $flags_file] } {
-	set cxxpchflags [exec sh $flags_file --cxxpchflags]
-    } else {
-	set cxxpchflags ""
-    }
-    append DEFAULT_CXXFLAGS " ${cxxpchflags}"
-
-    # Host specific goo here.
-    if { [string match "powerpc-*-darwin*" $target_triplet] } {
-	append DEFAULT_CXXFLAGS " -multiply_defined suppress"
-    } 
-}
 
 # Main loop.
+global DEFAULT_CXXFLAGS
 dg-runtest [v3-list-tests testsuite_files] "" $DEFAULT_CXXFLAGS
 #dg-runtest [v3-list-tests testsuite_files_interactive] "" $DEFAULT_CXXFLAGS
 


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