wibble 1.1
signal.test.h
Go to the documentation of this file.
1/* -*- C++ -*- (c) 2009 Enrico Zini <enrico@enricozini.org> */
2#include <wibble/sys/signal.h>
3#include <set>
4#include <cstdlib>
5#include <unistd.h>
6
7#include <wibble/test.h>
8
9using namespace std;
10using namespace wibble::sys;
11
12static int counter;
13static void test_signal_action(int signum)
14{
15 ++counter;
16}
17
18struct TestSignal {
20#ifdef POSIX
21 struct sigaction a;
22 a.sa_handler = test_signal_action;
23 sigemptyset(&a.sa_mask);
24 a.sa_flags = 0;
25
26 counter = 0;
27
28 sig::Action act(SIGUSR1, a);
29 kill(getpid(), SIGUSR1);
30 assert_eq(counter, 1);
31#endif
32 }
33
35#ifdef POSIX
37 struct sigaction a;
38 a.sa_handler = test_signal_action;
39 sigemptyset(&a.sa_mask);
40 a.sa_flags = 0;
41
44
45 counter = 0;
46
47 sig::Action act(SIGUSR1, a);
48 {
49 sig::ProcMask mask(blocked);
50 kill(getpid(), SIGUSR1);
51 assert_eq(counter, 0);
52 }
53 assert_eq(counter, 1);
54#endif
55 }
56};
57
58// vim:set ts=4 sw=4:
Definition buffer.cpp:28
Definition signal.test.h:18
Test sigAction()
Definition signal.test.h:19
Test sigProcMask()
Definition signal.test.h:34
Definition amorph.h:30
#define assert_eq(x, y)
Definition test.h:33