23 lines
733 B
C++
23 lines
733 B
C++
#include <Void/System/SignalWatcher.hpp>
|
|
#include <Void/Testing/Assert.hpp>
|
|
#include <Void/Testing/Test.hpp>
|
|
|
|
#include <chrono>
|
|
#include <csignal>
|
|
|
|
Void::Testing::Test signal_watcher_polls_and_receives_blocked_signal()
|
|
{
|
|
#ifdef __linux__
|
|
auto watcher = Void::Process::SignalWatcher::create({SIGUSR1});
|
|
Void::Testing::require(watcher.has_value());
|
|
auto empty = watcher->poll();
|
|
Void::Testing::require(empty.has_value());
|
|
Void::Testing::expect(!empty->has_value());
|
|
Void::Testing::require(::raise(SIGUSR1) == 0);
|
|
auto received = watcher->wait(std::chrono::milliseconds{100});
|
|
Void::Testing::require(received.has_value());
|
|
Void::Testing::require(received->has_value());
|
|
Void::Testing::expect_eq(**received, SIGUSR1);
|
|
#endif
|
|
}
|