Revision 418, 0.9 kB
(checked in by vbarta, 15 years ago)
|
#27: added UnitTest?++ to bdm sources, changed test_user_data to use it
|
Line | |
---|
1 | #ifndef UNITTEST_SIGNALTRANSLATOR_H |
---|
2 | #define UNITTEST_SIGNALTRANSLATOR_H |
---|
3 | |
---|
4 | #include <setjmp.h> |
---|
5 | #include <signal.h> |
---|
6 | |
---|
7 | namespace UnitTest { |
---|
8 | |
---|
9 | class SignalTranslator |
---|
10 | { |
---|
11 | public: |
---|
12 | SignalTranslator(); |
---|
13 | ~SignalTranslator(); |
---|
14 | |
---|
15 | static sigjmp_buf* s_jumpTarget; |
---|
16 | |
---|
17 | private: |
---|
18 | sigjmp_buf m_currentJumpTarget; |
---|
19 | sigjmp_buf* m_oldJumpTarget; |
---|
20 | |
---|
21 | struct sigaction m_old_SIGFPE_action; |
---|
22 | struct sigaction m_old_SIGTRAP_action; |
---|
23 | struct sigaction m_old_SIGSEGV_action; |
---|
24 | struct sigaction m_old_SIGBUS_action; |
---|
25 | struct sigaction m_old_SIGABRT_action; |
---|
26 | struct sigaction m_old_SIGALRM_action; |
---|
27 | }; |
---|
28 | |
---|
29 | #if !defined (__GNUC__) |
---|
30 | #define UNITTEST_EXTENSION |
---|
31 | #else |
---|
32 | #define UNITTEST_EXTENSION __extension__ |
---|
33 | #endif |
---|
34 | |
---|
35 | #define UNITTEST_THROW_SIGNALS \ |
---|
36 | UnitTest::SignalTranslator sig; \ |
---|
37 | if (UNITTEST_EXTENSION sigsetjmp(*UnitTest::SignalTranslator::s_jumpTarget, 1) != 0) \ |
---|
38 | throw ("Unhandled system exception"); |
---|
39 | |
---|
40 | } |
---|
41 | |
---|
42 | #endif |
---|