22 |
*/ |
*/ |
23 |
|
|
24 |
#include <stdio.h> |
#include <stdio.h> |
25 |
|
#include <utilities/config.h> |
26 |
#include <utilities/ascConfig.h> |
#include <utilities/ascConfig.h> |
27 |
#ifdef __WIN32__ |
#ifdef __WIN32__ |
28 |
#include <io.h> |
#include <io.h> |
29 |
#endif |
#endif |
30 |
#include <utilities/ascMalloc.h> |
#include <utilities/ascMalloc.h> |
31 |
|
#ifdef ASC_SIGNAL_TRAPS |
32 |
#include <utilities/ascSignal.h> |
#include <utilities/ascSignal.h> |
33 |
|
#endif |
34 |
#include <utilities/ascPanic.h> |
#include <utilities/ascPanic.h> |
35 |
#include "CUnit/CUnit.h" |
#include "CUnit/CUnit.h" |
36 |
#include "test_ascSignal.h" |
#include "test_ascSignal.h" |
37 |
#include "printutil.h" |
#include "printutil.h" |
38 |
|
|
39 |
#include <signal.h> |
#ifdef ASC_SIGNAL_TRAPS |
|
|
|
40 |
static JMP_BUF my_jmp_buf1; |
static JMP_BUF my_jmp_buf1; |
41 |
|
# define MEMUSED(N) CU_TEST(ascmeminuse()==N) |
|
#define MEMUSED(N) CU_TEST(ascmeminuse()==N) |
|
|
|
|
42 |
static int f_handler1_called; |
static int f_handler1_called; |
43 |
static int f_handler1_sigval; |
static int f_handler1_sigval; |
44 |
|
|
45 |
/* |
/* |
46 |
* Signal handler for unit tests. |
* Signal handler for unit tests. |
47 |
* Resets the signal handlers and sets f_handler1_called to |
* Resets the signal handlers and sets f_handler1_called to |
123 |
old_seg_handler = SIGNAL(SIGSEGV, my_handler1); |
old_seg_handler = SIGNAL(SIGSEGV, my_handler1); |
124 |
} |
} |
125 |
|
|
126 |
#define CHECK_SIGNALS_MATCH_STACKS(FPEFN,INTFN,SEGFN) \ |
# define CHECK_SIGNALS_MATCH_STACKS(FPEFN,INTFN,SEGFN) \ |
127 |
{ SigHandlerFn *oldfpe, *oldint, *oldseg; \ |
{ SigHandlerFn *oldfpe, *oldint, *oldseg; \ |
128 |
oldfpe = signal(SIGFPE,SIG_IGN);\ |
oldfpe = signal(SIGFPE,SIG_IGN);\ |
129 |
CU_TEST(oldfpe == FPEFN);\ |
CU_TEST(oldfpe == FPEFN);\ |
750 |
MEMUSED(0); |
MEMUSED(0); |
751 |
} |
} |
752 |
|
|
753 |
|
#endif /* ASC_SIGNAL_TRAPS */ |
754 |
|
|
755 |
/*===========================================================================*/ |
/*===========================================================================*/ |
756 |
/* Registration information */ |
/* Registration information */ |
757 |
|
|
758 |
#define T(N) {#N,test_ascsignal_##N} |
#define T(N) {#N,test_ascsignal_##N} |
759 |
static CU_TestInfo ascSignal_test_list[] = { |
static CU_TestInfo ascSignal_test_list[] = { |
760 |
|
#ifdef ASC_SIGNAL_TRAPS |
761 |
T(basic) |
T(basic) |
762 |
, T(pushpopint) |
, T(pushpopint) |
763 |
, T(pushpop) |
, T(pushpop) |
765 |
, T(nestingfpe) |
, T(nestingfpe) |
766 |
, T(nestingint) |
, T(nestingint) |
767 |
, T(nestingsegv) |
, T(nestingsegv) |
768 |
, CU_TEST_INFO_NULL |
, |
769 |
|
#endif |
770 |
|
CU_TEST_INFO_NULL |
771 |
}; |
}; |
772 |
#undef T |
#undef T |
773 |
|
|