This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] testsuite eh classes
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 01 Jun 2007 19:06:02 +0200
- Subject: [v3] testsuite eh classes
More merging from system_error work. Perparing for addition of
testsuite_eh...
tested x86/linux
-benjamin
2007-06-01 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/19_diagnostics/logic_error/what-big.cc: New.
* testsuite/19_diagnostics/logic_error/what-3.cc: Same.
* testsuite/19_diagnostics/runtime_error/what-big.cc: Same.
* testsuite/19_diagnostics/runtime_error/what-3.cc: Same.
* testsuite/18_support/14493.cc: Break into...
* testsuite/18_support/exception/what.cc: ...this.
* testsuite/18_support/bad_cast/what.cc: ...this.
* testsuite/18_support/bad_alloc/what.cc: ...this.
* testsuite/18_support/bad_typeid/what.cc: ...this.
* testsuite/18_support/bad_exception/what.cc: ...this.
* testsuite/19_diagnostics/bad_exception/23591_thread-1.c: Move...
* testsuite/18_support/bad_exception/23591_thread-1.c: ...here.
* testsuite/18_support/14026.cc: Move...
* testsuite/18_support/uncaught_exception/14026.cc: ...here.
Index: testsuite/19_diagnostics/bad_exception/23591_thread-1.c
===================================================================
--- testsuite/19_diagnostics/bad_exception/23591_thread-1.c (revision 125265)
+++ testsuite/19_diagnostics/bad_exception/23591_thread-1.c (working copy)
@@ -1,63 +0,0 @@
-// { 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;
-}
Index: testsuite/19_diagnostics/logic_error/what-big.cc
===================================================================
--- testsuite/19_diagnostics/logic_error/what-big.cc (revision 0)
+++ testsuite/19_diagnostics/logic_error/what-big.cc (revision 0)
@@ -0,0 +1,41 @@
+// 2007-05-29 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007 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 <cstring>
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+// Can construct and return 10k character error string.
+void test01()
+{
+ typedef std::logic_error test_type;
+
+ bool test __attribute__((unused)) = true;
+ const std::string xxx(10000, 'x');
+ test_type t(xxx);
+ VERIFY( std::strcmp(t.what(), xxx.c_str()) == 0 );
+}
+
+int main(void)
+{
+ test01();
+ return 0;
+}
Index: testsuite/19_diagnostics/logic_error/what-3.cc
===================================================================
--- testsuite/19_diagnostics/logic_error/what-3.cc (revision 0)
+++ testsuite/19_diagnostics/logic_error/what-3.cc (revision 0)
@@ -0,0 +1,69 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007
+// 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 <string>
+#include <stdexcept>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// test copy ctors, assignment operators, and persistence of member string data
+// libstdc++/1972
+// via Greg Bumgardner <bumgard@roguewave.com>
+void allocate_on_stack(void)
+{
+ const size_t num = 512;
+ __extension__ char array[num];
+ for (size_t i = 0; i < num; i++)
+ array[i]=0;
+}
+
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+ const std::string s("CA ISO emergency once again:immediate power down");
+ const char* strlit1 = "wish I lived in Palo Alto";
+ const char* strlit2 = "...or Santa Barbara";
+ std::logic_error obj1(s);
+
+ // block 01
+ {
+ const std::string s2(strlit1);
+ std::logic_error obj2(s2);
+ obj1 = obj2;
+ }
+ allocate_on_stack();
+ VERIFY( std::strcmp(strlit1, obj1.what()) == 0 );
+
+ // block 02
+ {
+ const std::string s3(strlit2);
+ std::logic_error obj3 = std::logic_error(s3);
+ obj1 = obj3;
+ }
+ allocate_on_stack();
+ VERIFY( std::strcmp(strlit2, obj1.what()) == 0 );
+}
+
+int main(void)
+{
+ test04();
+ return 0;
+}
Index: testsuite/19_diagnostics/runtime_error/what-big.cc
===================================================================
--- testsuite/19_diagnostics/runtime_error/what-big.cc (revision 0)
+++ testsuite/19_diagnostics/runtime_error/what-big.cc (revision 0)
@@ -0,0 +1,41 @@
+// 2007-05-29 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007 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 <cstring>
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+// Can construct and return 10k character error string.
+void test01()
+{
+ typedef std::runtime_error test_type;
+
+ bool test __attribute__((unused)) = true;
+ const std::string xxx(10000, 'x');
+ test_type t(xxx);
+ VERIFY( std::strcmp(t.what(), xxx.c_str()) == 0 );
+}
+
+int main(void)
+{
+ test01();
+ return 0;
+}
Index: testsuite/19_diagnostics/runtime_error/what-3.cc
===================================================================
--- testsuite/19_diagnostics/runtime_error/what-3.cc (revision 125265)
+++ testsuite/19_diagnostics/runtime_error/what-3.cc (working copy)
@@ -26,7 +26,7 @@
#include <cstring>
#include <testsuite_hooks.h>
-// test copy ctors and assignment operators
+// test copy ctors, assignment operators, and persistence of member string data
// libstdc++/1972
// via Greg Bumgardner <bumgard@roguewave.com>
void allocate_on_stack(void)
@@ -36,6 +36,7 @@
for (size_t i = 0; i < num; i++)
array[i]=0;
}
+
void test04()
{
bool test __attribute__((unused)) = true;
Index: testsuite/18_support/14026.cc
===================================================================
--- testsuite/18_support/14026.cc (revision 125265)
+++ testsuite/18_support/14026.cc (working copy)
@@ -1,34 +0,0 @@
-// PR 14026
-// 18.6.4 uncaught_exception
-
-#include <cstdlib>
-#include <exception>
-#include <testsuite_hooks.h>
-
-static void
-no_uncaught ()
-{
- if (std::uncaught_exception ())
- abort ();
-}
-
-int
-main ()
-{
- try
- {
- throw 1;
- }
- catch (...)
- {
- try
- {
- throw;
- }
- catch (...)
- {
- no_uncaught ();
- }
- }
- no_uncaught ();
-}
Index: testsuite/18_support/bad_cast/what.cc
===================================================================
--- testsuite/18_support/bad_cast/what.cc (revision 0)
+++ testsuite/18_support/bad_cast/what.cc (revision 0)
@@ -0,0 +1,41 @@
+// 2007-01-30 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007 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 <new>
+#include <typeinfo>
+#include <exception>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// libstdc++/14493
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ bad_cast bc;
+ VERIFY( !strcmp(bc.what(), "std::bad_cast") );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
Index: testsuite/18_support/bad_alloc/what.cc
===================================================================
--- testsuite/18_support/bad_alloc/what.cc (revision 0)
+++ testsuite/18_support/bad_alloc/what.cc (revision 0)
@@ -0,0 +1,41 @@
+// 2007-01-30 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007 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 <new>
+#include <typeinfo>
+#include <exception>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// libstdc++/14493
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ bad_alloc ba;
+ VERIFY( !strcmp(ba.what(), "std::bad_alloc") );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
Index: testsuite/18_support/bad_typeid/what.cc
===================================================================
--- testsuite/18_support/bad_typeid/what.cc (revision 0)
+++ testsuite/18_support/bad_typeid/what.cc (revision 0)
@@ -0,0 +1,41 @@
+// 2007-01-30 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007 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 <new>
+#include <typeinfo>
+#include <exception>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// libstdc++/14493
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ bad_typeid bt;
+ VERIFY( !strcmp(bt.what(), "std::bad_typeid") );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
Index: testsuite/18_support/bad_exception/what.cc
===================================================================
--- testsuite/18_support/bad_exception/what.cc (revision 0)
+++ testsuite/18_support/bad_exception/what.cc (revision 0)
@@ -0,0 +1,41 @@
+// 2007-01-30 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007 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 <new>
+#include <typeinfo>
+#include <exception>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// libstdc++/14493
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ bad_exception be;
+ VERIFY( !strcmp(be.what(), "std::bad_exception") );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
Index: testsuite/18_support/bad_exception/23591_thread-1.c
===================================================================
--- testsuite/18_support/bad_exception/23591_thread-1.c (revision 0)
+++ testsuite/18_support/bad_exception/23591_thread-1.c (revision 0)
@@ -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;
+}
Index: testsuite/18_support/14493.cc
===================================================================
--- testsuite/18_support/14493.cc (revision 125265)
+++ testsuite/18_support/14493.cc (working copy)
@@ -1,53 +0,0 @@
-// 2007-01-30 Paolo Carlini <pcarlini@suse.de>
-
-// Copyright (C) 2007 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 <new>
-#include <typeinfo>
-#include <exception>
-#include <cstring>
-#include <testsuite_hooks.h>
-
-// libstdc++/14493
-void test01()
-{
- bool test __attribute__((unused)) = true;
- using namespace std;
-
- bad_alloc ba;
- VERIFY( !strcmp(ba.what(), "std::bad_alloc") );
-
- bad_cast bc;
- VERIFY( !strcmp(bc.what(), "std::bad_cast") );
-
- bad_typeid bt;
- VERIFY( !strcmp(bt.what(), "std::bad_typeid") );
-
- exception e;
- VERIFY( !strcmp(e.what(), "std::exception") );
-
- bad_exception be;
- VERIFY( !strcmp(be.what(), "std::bad_exception") );
-}
-
-int main()
-{
- test01();
- return 0;
-}
Index: testsuite/18_support/uncaught_exception/14026.cc
===================================================================
--- testsuite/18_support/uncaught_exception/14026.cc (revision 0)
+++ testsuite/18_support/uncaught_exception/14026.cc (working copy)
@@ -1,3 +1,21 @@
+// Copyright (C) 2004, 2007 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.
+
// PR 14026
// 18.6.4 uncaught_exception
@@ -8,12 +26,12 @@
static void
no_uncaught ()
{
- if (std::uncaught_exception ())
- abort ();
+ if (std::uncaught_exception())
+ abort();
}
int
-main ()
+main()
{
try
{
@@ -30,5 +48,7 @@
no_uncaught ();
}
}
- no_uncaught ();
+ no_uncaught();
+
+ return 0;
}
Index: testsuite/18_support/exception/what.cc
===================================================================
--- testsuite/18_support/exception/what.cc (revision 0)
+++ testsuite/18_support/exception/what.cc (revision 0)
@@ -0,0 +1,41 @@
+// 2007-01-30 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007 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 <new>
+#include <typeinfo>
+#include <exception>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// libstdc++/14493
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ exception e;
+ VERIFY( !strcmp(e.what(), "std::exception") );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}