bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */
0043fea12a75cf8fcf2892673106844376da8e76Stephan Boschkill_timeout(struct test_context_delayed *tctx ATTR_UNUSED)
0043fea12a75cf8fcf2892673106844376da8e76Stephan Boschtest_timeout(struct test_context_delayed *tctx)
0043fea12a75cf8fcf2892673106844376da8e76Stephan Boschsignal_handler_delayed(const siginfo_t *si ATTR_UNUSED,
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch test_begin("lib-signals delayed - init lib-signals first");
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch lib_signals_set_handler(SIGALRM, LIBSIG_FLAGS_SAFE,
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch to_kill = timeout_add_short(200, kill_timeout, &tctx);
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch to_test = timeout_add_short(400, test_timeout, &tctx);
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch test_begin("lib-signals delayed - init ioloop first");
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch lib_signals_set_handler(SIGALRM, LIBSIG_FLAGS_SAFE,
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch to_kill = timeout_add_short(200, kill_timeout, &tctx);
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch to_test = timeout_add_short(400, test_timeout, &tctx);
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch test_begin("lib-signals delayed in nested ioloop");
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch lib_signals_set_handler(SIGALRM, LIBSIG_FLAGS_SAFE,
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch /* briefly run outer ioloop */
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch to_test = timeout_add_short(100, test_timeout, &tctx);
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch /* run inner ioloop, which triggers the signal */
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch to_kill = timeout_add_short(200, kill_timeout, &tctx);
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch to_test = timeout_add_short(400, test_timeout, &tctx);
0043fea12a75cf8fcf2892673106844376da8e76Stephan Boschtest_lib_signals_delayed_no_ioloop_automove(void)
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch test_begin("lib-signals delayed with NO_IOLOOP_AUTOMOVE - unmoved");
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch LIBSIG_FLAGS_SAFE | LIBSIG_FLAG_NO_IOLOOP_AUTOMOVE,
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch /* briefly run outer ioloop */
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch to_test = timeout_add_short(100, test_timeout, &tctx);
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch /* run inner ioloop, which triggers the signal but musn't handle it */
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch to_kill = timeout_add_short(200, kill_timeout, &tctx);
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch to_test = timeout_add_short(400, test_timeout, &tctx);
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch /* run outer ioloop once more */
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch to_test = timeout_add_short(100, test_timeout, &tctx);
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch test_begin("lib-signals delayed with NO_IOLOOP_AUTOMOVE - moved");
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch LIBSIG_FLAGS_SAFE | LIBSIG_FLAG_NO_IOLOOP_AUTOMOVE,
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch /* briefly run outer ioloop */
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch to_test = timeout_add_short(100, test_timeout, &tctx);
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch /* run inner ioloop, which triggers the signal */
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch to_kill = timeout_add_short(200, kill_timeout, &tctx);
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch to_test = timeout_add_short(400, test_timeout, &tctx);