msvcrt: Use fpclass constants from public header.
[wine/zf.git] / dlls / msvcrt / tests / signal.c
blobad6ea6ecf906f105170e4b2e991d0d4829081b7c
1 /*
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"
22 #include <winbase.h>
23 #include <signal.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");
32 if(signum == SIGABRT)
33 ok(*ret == (void*)0xdeadbeef, "*ret = %p\n", *ret);
34 else if(signum == SIGSEGV)
35 ok(*ret == NULL, "*ret = %p\n", *ret);
36 ++test_value;
39 static void test_signal(void)
41 void (__cdecl *old)(int);
42 int res;
44 old = signal(SIGBREAK, sighandler);
45 ok(old != SIG_ERR, "Failed to install signal handler for SIGBREAK\n");
46 test_value = 0;
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();
55 int res;
57 ok(ret != NULL, "ret == NULL\n");
58 ok(*ret == NULL, "*ret != NULL\n");
60 test_value = 0;
62 *ret = (void*)0xdeadbeef;
63 signal(SIGSEGV, sighandler);
64 res = raise(SIGSEGV);
65 ok(res == 0, "failed to raise SIGSEGV\n");
66 ok(*ret == (void*)0xdeadbeef, "*ret = %p\n", *ret);
68 signal(SIGABRT, sighandler);
69 res = raise(SIGABRT);
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);
76 START_TEST(signal)
78 test_signal();
79 test___pxcptinfoptrs();