libstdc++: Fix testcase by using terminate handler
authorJonathan Wakely <jwakely@redhat.com>
Fri, 2 Oct 2020 20:10:55 +0000 (21:10 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 2 Oct 2020 21:18:51 +0000 (22:18 +0100)
This test was supposed to verify that when __libc_single_threaded is
available we successfully detect recursive static initialization even
when linked to libpthread. But I forgot to that when recursive init is
detected, we terminate, and so the test fails.

This adds a terminate handler that exits cleanly, so the test passes
when recursive init is detected.

libstdc++-v3/ChangeLog:

* testsuite/18_support/96817.cc: Use terminate handler that
calls _Exit(0).

libstdc++-v3/testsuite/18_support/96817.cc

index 4c4da40afa94f51a08de77111a75ba901295293b..19399c473ef17ec9318759cd6d68a0737e60fbe2 100644 (file)
@@ -21,6 +21,9 @@
 
 // PR libstdc++/96817
 
+#include <exception>
+#include <stdlib.h>
+
 int init()
 {
 #if __has_include(<sys/single_threaded.h>)
@@ -32,8 +35,11 @@ int init()
   return 0;
 }
 
+void clean_terminate() { _Exit(0); }
+
 int
 main (int argc, char **argv)
 {
+  std::set_terminate(clean_terminate);
   init();
 }