2 * Unit test suite for signal function.
4 * Copyright 2009 Peter Rosin
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/test.h"
25 static int test_value
= 0;
27 static void __cdecl
sighandler(int signum
)
29 void **ret
= __pxcptinfoptrs();
31 ok(ret
!= NULL
, "ret = NULL\n");
33 ok(*ret
== (void*)0xdeadbeef, "*ret = %p\n", *ret
);
34 else if(signum
== SIGSEGV
)
35 ok(*ret
== NULL
, "*ret = %p\n", *ret
);
39 static void test_signal(void)
41 void (__cdecl
*old
)(int);
44 old
= signal(SIGBREAK
, sighandler
);
45 ok(old
!= SIG_ERR
, "Failed to install signal handler for SIGBREAK\n");
47 res
= raise(SIGBREAK
);
48 ok(res
== 0, "Failed to raise SIGBREAK\n");
49 ok(test_value
== 1, "SIGBREAK handler not invoked\n");
52 static void test___pxcptinfoptrs(void)
54 void **ret
= __pxcptinfoptrs();
57 ok(ret
!= NULL
, "ret == NULL\n");
58 ok(*ret
== NULL
, "*ret != NULL\n");
62 *ret
= (void*)0xdeadbeef;
63 signal(SIGSEGV
, sighandler
);
65 ok(res
== 0, "failed to raise SIGSEGV\n");
66 ok(*ret
== (void*)0xdeadbeef, "*ret = %p\n", *ret
);
68 signal(SIGABRT
, sighandler
);
70 ok(res
== 0, "failed to raise SIGBREAK\n");
71 ok(*ret
== (void*)0xdeadbeef, "*ret = %p\n", *ret
);
73 ok(test_value
== 2, "test_value = %d\n", test_value
);
79 test___pxcptinfoptrs();