diff options
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r-- | libstdc++-v3/testsuite/19_diagnostics/23591_thread-1.c | 63 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/Makefile.in | 5 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/ext/mt_allocator/22309_thread.cc | 2 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/lib/libstdc++.exp | 25 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/libstdc++-dg/normal.exp | 7 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/testsuite_shared.cc | 39 |
6 files changed, 132 insertions, 9 deletions
diff --git a/libstdc++-v3/testsuite/19_diagnostics/23591_thread-1.c b/libstdc++-v3/testsuite/19_diagnostics/23591_thread-1.c new file mode 100644 index 00000000000..8c953eaed0e --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/23591_thread-1.c @@ -0,0 +1,63 @@ +// { dg-require-sharedlib "" } +// { dg-options "-g -O2 -pthread -ldl -x c" { target *-*-linux* } } + +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library 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, or (at your option) +// any later version. +// +// This library 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 library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include <pthread.h> +#include <dlfcn.h> +#include <errno.h> +#include <stdio.h> +#include <string.h> + +// NB: This must be compiled and linked as a "C" executable. +static void* run(void* arg) +{ + typedef void (*function_type) (void); + void* lib; + void (*cb)(); + + lib = dlopen("./testsuite_shared.so", RTLD_NOW); + if (lib == NULL) + { + printf("dlopen failed: %s\n", strerror(errno)); + return NULL; + } + cb = (function_type) dlsym(lib, "try_throw_exception"); + if (cb == NULL) + { + printf("dlsym failed: %s\n", strerror(errno)); + return NULL; + } + cb(); + dlclose(lib); + return NULL; +} + +// libstdc++/23591 +int main(void) +{ + pthread_t pt; + + if (pthread_create(&pt, NULL, &run, NULL) != 0) + return 1; + if (pthread_join(pt, NULL) != 0) + return 1; + + return 0; +} diff --git a/libstdc++-v3/testsuite/Makefile.in b/libstdc++-v3/testsuite/Makefile.in index dcfb5f80696..0b25a5a8686 100644 --- a/libstdc++-v3/testsuite/Makefile.in +++ b/libstdc++-v3/testsuite/Makefile.in @@ -40,11 +40,12 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(top_srcdir)/fragment.am subdir = testsuite ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/../config/lead-dot.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../config/enable.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ $(top_srcdir)/../config/no-executables.m4 \ $(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \ $(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/../config/tls.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) CONFIG_HEADER = $(top_builddir)/config.h diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/22309_thread.cc b/libstdc++-v3/testsuite/ext/mt_allocator/22309_thread.cc index f2243657a5d..1df94b7c666 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/22309_thread.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/22309_thread.cc @@ -50,7 +50,7 @@ check_dlsym(void*& h) typedef void (*function_type) (void); function_type fn; - fn = reinterpret_cast<function_type>(dlsym(h, "foo")); + fn = reinterpret_cast<function_type>(dlsym(h, "try_allocation")); try { diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 0f10e6dff91..ee5111dfaf9 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -266,14 +266,32 @@ proc libstdc++-dg-test { prog do_what extra_tool_flags } { # created or not. If it was, dg.exp will try to run it. remote_file build delete $output_file; } - default { + default { perror "$do_what: not a valid dg-do keyword" return "" } } + set options "" if { $extra_tool_flags != "" } { - lappend options "additional_flags=$extra_tool_flags" + verbose -log "extra_tool_flags are:" + verbose -log $extra_tool_flags + if { [string first "-x c" $extra_tool_flags ] != -1 } { + # Short-circut a bunch of complicated goo here for the + # special case of compiling a test file as a "C" file, not + # as C++: just use target_compile, instead of the usual + # gimmicks. + verbose -log "compiling and executing as C, not C++" + set compile_type "executable" + set output_file "./[file rootname [file tail $prog]].exe" + remote_file build delete $output_file; + lappend options "additional_flags=$extra_tool_flags" + set comp_output [target_compile "$prog" "$output_file" "$compile_type" $options]; + set comp_output [ prune_g++_output $comp_output ]; + return [list $comp_output $output_file] + } else { + lappend options "additional_flags=$extra_tool_flags" + } } # There is a libstdc++_compile made for us by default (via the tool- @@ -608,8 +626,7 @@ proc check_v3_target_debug_mode { } { set et_debug_mode 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. + # on debug mode working. set src debug_mode[pid].cc set exe debug_mode[pid].exe diff --git a/libstdc++-v3/testsuite/libstdc++-dg/normal.exp b/libstdc++-v3/testsuite/libstdc++-dg/normal.exp index 6ebe6b439ec..21bc3c1b915 100644 --- a/libstdc++-v3/testsuite/libstdc++-dg/normal.exp +++ b/libstdc++-v3/testsuite/libstdc++-dg/normal.exp @@ -1,4 +1,4 @@ -# Primary test file for libstdc++. +# Functional and regression tests in C++ for libstdc++. # Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. # @@ -61,6 +61,11 @@ if {[info exists tests_file] && [file exists $tests_file]} { # Find all the tests. foreach s $subdirs { set subdir_tests [find $s *.cc] + set subdir_tests_c [find $s *.c] + foreach e $subdir_tests_c { + lappend subdir_tests $e + } + # Filter out tests that should not be run. foreach t $subdir_tests { # The DejaGNU "find" procedure sometimes returns a list diff --git a/libstdc++-v3/testsuite/testsuite_shared.cc b/libstdc++-v3/testsuite/testsuite_shared.cc index a829fb47aa7..58803a2ae4f 100644 --- a/libstdc++-v3/testsuite/testsuite_shared.cc +++ b/libstdc++-v3/testsuite/testsuite_shared.cc @@ -17,11 +17,14 @@ // USA. #include <string> +#include <stdexcept> +#include <iostream> +#include <sstream> #include <ext/mt_allocator.h> // libstdc++/22309 extern "C" void -foo() +try_allocation() { typedef char value_t; @@ -34,3 +37,37 @@ foo() string_t s; s += "west beach, indiana dunes"; } + +// libstdc++/23591 +extern "C" void +try_throw_exception() +{ + try + { + throw std::bad_exception(); + } + catch (const std::exception& e) + { } +} + +extern "C" void +try_function_random_fail() +{ + long seed = lrand48(); + if (seed < 2000) + seed = 2000; + + { + std::ostringstream s; + s << "random_throw, seed: " << seed << std::endl; + std::cout << s.str(); + } + + while (--seed > 0) + { + try_throw_exception(); + } + + // Randomly throw. See if other threads cleanup. + throw std::bad_exception(); +} |