ReactOS 0.4.16-dev-226-g79f2289
signal.c
Go to the documentation of this file.
1/*
2 * Unit test suite for signal function.
3 *
4 * Copyright 2009 Peter Rosin
5 *
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.
10 *
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.
15 *
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
19 */
20
21#include "wine/test.h"
22#include <winbase.h>
23#include <signal.h>
24
25static int test_value = 0;
26
27static void __cdecl sighandler(int signum)
28{
29 void **ret = __pxcptinfoptrs();
30
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;
37}
38
39static void test_signal(void)
40{
41 void (__cdecl *old)(int);
42 int res;
43
45 ok(old != SIG_ERR, "Failed to install signal handler for SIGBREAK\n");
46 test_value = 0;
48 ok(res == 0, "Failed to raise SIGBREAK\n");
49 ok(test_value == 1, "SIGBREAK handler not invoked\n");
50}
51
52static void test___pxcptinfoptrs(void)
53{
54 void **ret = __pxcptinfoptrs();
55 int res;
56
57 ok(ret != NULL, "ret == NULL\n");
58 ok(*ret == NULL, "*ret != NULL\n");
59
60 test_value = 0;
61
62 *ret = (void*)0xdeadbeef;
64 res = raise(SIGSEGV);
65 ok(res == 0, "failed to raise SIGSEGV\n");
66 ok(*ret == (void*)0xdeadbeef, "*ret = %p\n", *ret);
67
69 res = raise(SIGABRT);
70 ok(res == 0, "failed to raise SIGBREAK\n");
71 ok(*ret == (void*)0xdeadbeef, "*ret = %p\n", *ret);
72
73 ok(test_value == 2, "test_value = %d\n", test_value);
74}
75
77{
80}
#define __cdecl
Definition: accygwin.h:79
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
int __cdecl raise(int _SigNum)
Definition: signal.c:71
#define SIG_ERR
Definition: signal.h:52
void **__cdecl __pxcptinfoptrs(void)
Definition: xcptinfo.c:6
#define SIGABRT
Definition: signal.h:28
#define SIGSEGV
Definition: signal.h:33
#define SIGBREAK
Definition: signal.h:40
#define NULL
Definition: types.h:112
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLuint res
Definition: glext.h:9613
static void test_signal(void)
Definition: signal.c:39
static void test___pxcptinfoptrs(void)
Definition: signal.c:52
static void __cdecl sighandler(int signum)
Definition: signal.c:27
static int test_value
Definition: signal.c:25
int signal
Definition: except.c:82
int ret