signal.test.h
Go to the documentation of this file.
/* -*- C++ -*- (c) 2009 Enrico Zini <enrico@enricozini.org> */
#include <wibble/sys/signal.h>
#include <set>
#include <cstdlib>
#include <unistd.h>
#include <wibble/test.h>
using namespace std;
using namespace wibble::sys;
static int counter;
static void test_signal_action(int signum)
{
++counter;
}
struct TestSignal {
Test sigAction() {
#ifdef POSIX
struct sigaction a;
a.sa_handler = test_signal_action;
sigemptyset(&a.sa_mask);
a.sa_flags = 0;
counter = 0;
sig::Action act(SIGUSR1, a);
kill(getpid(), SIGUSR1);
assert_eq(counter, 1);
#endif
}
Test sigProcMask() {
#ifdef POSIX
sigset_t blocked;
struct sigaction a;
a.sa_handler = test_signal_action;
sigemptyset(&a.sa_mask);
a.sa_flags = 0;
sigemptyset(&blocked);
sigaddset(&blocked, SIGUSR1);
counter = 0;
sig::Action act(SIGUSR1, a);
{
sig::ProcMask mask(blocked);
kill(getpid(), SIGUSR1);
assert_eq(counter, 0);
}
assert_eq(counter, 1);
#endif
}
};
// vim:set ts=4 sw=4:
TestSignal
Definition: signal.test.h:18
Test
void Test
Definition: test.h:178
test.h
std
wibble::sys
Definition: buffer.cpp:28
assert_eq
#define assert_eq(x, y)
Definition: test.h:33
TestSignal::sigAction
Test sigAction()
Definition: signal.test.h:19
signal.h
TestSignal::sigProcMask
Test sigProcMask()
Definition: signal.test.h:34