Home | History | Annotate | Download | only in debug
      1 // -*- C++ -*-
      2 //===----------------------------------------------------------------------===//
      3 //
      4 //                     The LLVM Compiler Infrastructure
      5 //
      6 // This file is dual licensed under the MIT and the University of Illinois Open
      7 // Source Licenses. See LICENSE.TXT for details.
      8 //
      9 //===----------------------------------------------------------------------===//
     10 
     11 // MODULES_DEFINES: _LIBCPP_DEBUG=0
     12 
     13 // Can't test the system lib because this test enables debug mode
     14 // UNSUPPORTED: with_system_cxx_lib
     15 
     16 // Test that the default debug handler aborts the program.
     17 
     18 #define _LIBCPP_DEBUG 0
     19 
     20 #include <csignal>
     21 #include <cstdlib>
     22 #include <__debug>
     23 
     24 void signal_handler(int signal)
     25 {
     26     if (signal == SIGABRT)
     27       std::_Exit(EXIT_SUCCESS);
     28     std::_Exit(EXIT_FAILURE);
     29 }
     30 
     31 int main()
     32 {
     33   if (std::signal(SIGABRT, signal_handler) != SIG_ERR)
     34     _LIBCPP_ASSERT(false, "foo");
     35   return EXIT_FAILURE;
     36 }
     37