]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/libcxx/debug/debug_abort.pass.cpp
Vendor import of libc++ trunk r300422:
[FreeBSD/FreeBSD.git] / test / libcxx / debug / debug_abort.pass.cpp
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 // Test that the default debug handler aborts the program.
14
15 #define _LIBCPP_DEBUG 0
16
17 #include <csignal>
18 #include <cstdlib>
19 #include <__debug>
20
21 void signal_handler(int signal)
22 {
23     if (signal == SIGABRT)
24       std::_Exit(EXIT_SUCCESS);
25     std::_Exit(EXIT_FAILURE);
26 }
27
28 int main()
29 {
30   if (std::signal(SIGABRT, signal_handler) != SIG_ERR)
31     _LIBCPP_ASSERT(false, "foo");
32   return EXIT_FAILURE;
33 }