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]

Testsuite patch to make cxa_atexit test available in gcc subdir


There is a C++ test, g++.old-deja/g++.other/init18.C, that is failing on
HP-UX platforms.  There are two reasons for the failure; one is that the
test calls _Exit which does not exist on HP-UX and the other is that the
test is only going to pass on systems that use __cxa_atexit and will not
pass on systems that use atexit (even if they define _Exit or if _Exit
were changed to _exit).

I would like to move the dg-require-cxa-atexit definition from the
libstdc++ subdirectory to the gcc subdirectory so that it can be used by
tests in the gcc/testsuite/g++ suites (specifically
g++.old-deja/g++.other/init18.C).  The libstdc++ testsuite already gets
other dg-require-* tests from the gcc subdir so there is no problem with
the library testsuite continuing to use this check.  I also removed the
definition of dg-require-iconv from the libstdc++ version of
dg-options.exp while I was there because that function is also defined
in the gcc subdirectory and libstdc++ can use that one instead of having
a duplicate version.

Tested by re-running the libstdc++ testsuite on ia64-hp-hpux11.11 with
no failures.  Note that the actual change to init18.C is not in this
patch, this is just the infrastructure changes needed to make it
available to the gcc subdirectory so I can later xfail init18.C if the
target does not support __cxa_atexit.

libstdc++/ChangeLog

2006-05-09  Steve Ellcey  <sje@cup.hp.com>

	
	* libstdc++/testsuite/lib/libstdc++.exp (check_v3_target_cxa_atexit):
	Remove.
	* libstdc++/testsuite/lib/dg-options.exp (dg-require-iconv): Remove.
	(dg-require-cxa-atexit): Remove.

gcc/testsuite/ChangeLog

2006-05-09  Steve Ellcey  <sje@cup.hp.com>

	
	* lib/target-supports-dg.exp (dg-require-cxa-atexit): New.
	* lib/target-supports.dg (check_v3_target_cxa_atexit): New.


Index: testsuite/lib/libstdc++.exp
===================================================================
--- testsuite/lib/libstdc++.exp	(revision 113639)
+++ testsuite/lib/libstdc++.exp	(working copy)
@@ -529,90 +529,6 @@ proc check_v3_target_namedlocale { } {
     return $et_namedlocale_saved
 }
 
-proc check_v3_target_cxa_atexit { } {
-    global et_cxa_atexit
-    global et_cxa_atexit_target_name
-    global tool	
-
-    if { ![info exists et_cxa_atexit_target_name] } {
-	set et_cxa_atexit_target_name ""
-    }
-
-    # If the target has changed since we set the cached value, clear it.
-    set current_target [current_target_name]
-    if { $current_target != $et_cxa_atexit_target_name } {
-	verbose "check_v3_target_cxa_atexit: `$et_cxa_atexit_target_name'" 2
-	set et_cxa_atexit_target_name $current_target
-	if [info exists et_cxa_atexit] {
-	    verbose "check_v3_target_cxa_atexit: removing cached result" 2
-	    unset et_cxa_atexit
-	}
-    }
-
-    if [info exists et_cxa_atexit] {
-	verbose "check_v3_target_cxa_atexit: using cached result" 2
-    } else {
-	set et_cxa_atexit 0
-
-	# Set up, compile, and execute a C++ test program that depends
-	# on correct ordering of static object destructors. This is
-	# indicative of the presence and use of __cxa_atexit.
-	set src cxaatexit[pid].cc
-	set exe cxaatexit[pid].x
-
-	set f [open $src "w"]
-	puts $f "#include <stdlib.h>"
-	puts $f "static unsigned int count;"
-	puts $f "struct X"
-	puts $f "{"
-	puts $f "  X() { count = 1; }"
-	puts $f "  ~X()"
-	puts $f "  {"
-	puts $f "    if (count != 3)"
-	puts $f "      exit(1);"
-	puts $f "    count = 4;"
-        puts $f "  }"
-        puts $f "};"
-	puts $f "void f()"
-	puts $f "{"
-	puts $f "  static X x;"
-        puts $f "}"
-	puts $f "struct Y"
-	puts $f "{"
-	puts $f "  Y() { f(); count = 2; }"
-	puts $f "  ~Y()"
-	puts $f "  {"
-	puts $f "    if (count != 2)"
-	puts $f "      exit(1);"
-	puts $f "    count = 3;"
-        puts $f "  }"
-        puts $f "};"
-	puts $f "Y y;"
-	puts $f "int main()"
-	puts $f "{ return 0; }"
-	close $f
-
-	set lines [v3_target_compile $src $exe executable ""]
-	file delete $src
-
-	if [string match "" $lines] {
-	    # No error message, compilation succeeded.
-	    set result [${tool}_load "./$exe" "" ""]
-	    set status [lindex $result 0]
-	    remote_file build delete $exe
-
-	    verbose "check_v3_target_cxa_atexit: status is <$status>" 2
-
-	    if { $status == "pass" } {
-		set et_cxa_atexit 1
-	    }
-	} else {
-	    verbose "check_v3_target_cxa_atexit: compilation failed" 2
-	}
-    }
-    return $et_cxa_atexit
-}
-
 proc check_v3_target_debug_mode { } {
     global cxxflags
     global et_debug_mode
Index: testsuite/lib/dg-options.exp
===================================================================
--- testsuite/lib/dg-options.exp	(revision 113639)
+++ testsuite/lib/dg-options.exp	(working copy)
@@ -17,27 +17,8 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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
-}
-
 proc dg-require-namedlocale { args } {
     if { ![ check_v3_target_namedlocale ] } {
-	upvar dg-do-what dg-do-what
-	set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
-	return
-    }
-    return
-}
-
-proc dg-require-cxa-atexit { args } {
-    if { ![ check_v3_target_cxa_atexit ] } {
 	upvar dg-do-what dg-do-what
 	set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
 	return
Index: lib/target-supports-dg.exp
===================================================================
--- lib/target-supports-dg.exp	(revision 113639)
+++ lib/target-supports-dg.exp	(working copy)
@@ -140,6 +140,15 @@ proc dg-require-mkfifo { args } {
     }
 }
 
+# If this target does not use __cxa_atexit, skip this test.
+
+proc dg-require-cxa-atexit { args } {
+    if { ![ check_v3_target_cxa_atexit ] } {
+        upvar dg-do-what dg-do-what
+        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+    }
+}
+
 # Check the flags with which the test will be run against options in
 # a test directive that will skip or xfail that test.  The DejaGnu proc
 # check_conditional_xfail will look at the options in compiler_flags, so
Index: lib/target-supports.exp
===================================================================
--- lib/target-supports.exp	(revision 113639)
+++ lib/target-supports.exp	(working copy)
@@ -916,6 +916,93 @@ proc check_mkfifo_available {} {
     return [check_function_available "mkfifo"]
 }
 
+# Returns true iff "__cxa_atexit" is used on the target system.
+
+proc check_v3_target_cxa_atexit { } {
+    global et_cxa_atexit
+    global et_cxa_atexit_target_name
+    global tool	
+
+    if { ![info exists et_cxa_atexit_target_name] } {
+	set et_cxa_atexit_target_name ""
+    }
+
+    # If the target has changed since we set the cached value, clear it.
+    set current_target [current_target_name]
+    if { $current_target != $et_cxa_atexit_target_name } {
+	verbose "check_v3_target_cxa_atexit: `$et_cxa_atexit_target_name'" 2
+	set et_cxa_atexit_target_name $current_target
+	if [info exists et_cxa_atexit] {
+	    verbose "check_v3_target_cxa_atexit: removing cached result" 2
+	    unset et_cxa_atexit
+	}
+    }
+
+    if [info exists et_cxa_atexit] {
+	verbose "check_v3_target_cxa_atexit: using cached result" 2
+    } else {
+	set et_cxa_atexit 0
+
+	# Set up, compile, and execute a C++ test program that depends
+	# on correct ordering of static object destructors. This is
+	# indicative of the presence and use of __cxa_atexit.
+	set src cxaatexit[pid].cc
+	set exe cxaatexit[pid].x
+
+	set f [open $src "w"]
+	puts $f "#include <stdlib.h>"
+	puts $f "static unsigned int count;"
+	puts $f "struct X"
+	puts $f "{"
+	puts $f "  X() { count = 1; }"
+	puts $f "  ~X()"
+	puts $f "  {"
+	puts $f "    if (count != 3)"
+	puts $f "      exit(1);"
+	puts $f "    count = 4;"
+        puts $f "  }"
+        puts $f "};"
+	puts $f "void f()"
+	puts $f "{"
+	puts $f "  static X x;"
+        puts $f "}"
+	puts $f "struct Y"
+	puts $f "{"
+	puts $f "  Y() { f(); count = 2; }"
+	puts $f "  ~Y()"
+	puts $f "  {"
+	puts $f "    if (count != 2)"
+	puts $f "      exit(1);"
+	puts $f "    count = 3;"
+        puts $f "  }"
+        puts $f "};"
+	puts $f "Y y;"
+	puts $f "int main()"
+	puts $f "{ return 0; }"
+	close $f
+
+	set lines [v3_target_compile $src $exe executable ""]
+	file delete $src
+
+	if [string match "" $lines] {
+	    # No error message, compilation succeeded.
+	    set result [${tool}_load "./$exe" "" ""]
+	    set status [lindex $result 0]
+	    remote_file build delete $exe
+
+	    verbose "check_v3_target_cxa_atexit: status is <$status>" 2
+
+	    if { $status == "pass" } {
+		set et_cxa_atexit 1
+	    }
+	} else {
+	    verbose "check_v3_target_cxa_atexit: compilation failed" 2
+	}
+    }
+    return $et_cxa_atexit
+}
+
+
 # Return 1 if we're generating 32-bit code using default options, 0
 # otherwise.
 


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