2018-04-04 14:35:50 +00:00
|
|
|
|
|
|
|
#include <machinarium.h>
|
|
|
|
#include <odyssey_test.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <signal.h>
|
|
|
|
|
2020-12-28 11:22:53 +00:00
|
|
|
static void coroutine(void *arg)
|
2018-04-04 14:35:50 +00:00
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
sigset_t mask;
|
|
|
|
sigemptyset(&mask);
|
|
|
|
sigaddset(&mask, SIGINT);
|
|
|
|
|
2019-12-18 08:44:00 +00:00
|
|
|
sigset_t ignore;
|
|
|
|
sigemptyset(&ignore);
|
|
|
|
|
2018-04-04 14:35:50 +00:00
|
|
|
int rc;
|
2019-12-18 08:44:00 +00:00
|
|
|
rc = machine_signal_init(&mask, &ignore);
|
2018-04-04 14:35:50 +00:00
|
|
|
test(rc == 0);
|
|
|
|
|
|
|
|
rc = kill(getpid(), SIGINT);
|
|
|
|
test(rc == 0);
|
|
|
|
|
|
|
|
rc = machine_signal_wait(UINT32_MAX);
|
|
|
|
test(rc == SIGINT);
|
|
|
|
|
|
|
|
rc = machine_signal_wait(100);
|
|
|
|
test(rc == -1);
|
|
|
|
}
|
|
|
|
|
2020-12-28 11:22:53 +00:00
|
|
|
void machinarium_test_signal1(void)
|
2018-04-04 14:35:50 +00:00
|
|
|
{
|
|
|
|
sigset_t mask;
|
|
|
|
sigemptyset(&mask);
|
|
|
|
sigaddset(&mask, SIGINT);
|
|
|
|
sigprocmask(SIG_BLOCK, &mask, NULL);
|
|
|
|
|
|
|
|
machinarium_init();
|
|
|
|
|
|
|
|
int id;
|
|
|
|
id = machine_create("test", coroutine, NULL);
|
|
|
|
test(id != -1);
|
|
|
|
|
|
|
|
int rc;
|
|
|
|
rc = machine_wait(id);
|
|
|
|
test(rc != -1);
|
|
|
|
|
|
|
|
machinarium_free();
|
|
|
|
|
|
|
|
sigprocmask(SIG_UNBLOCK, &mask, NULL);
|
|
|
|
}
|