test: add del_wait/del_notify tests for windows

Test manually, since CI is too slow
This commit is contained in:
Azat Khuzhin 2023-02-12 21:39:04 +01:00
parent 765fb4108d
commit 0ea2058252

View File

@ -1026,97 +1026,6 @@ test_fork(void)
evutil_closesocket(child_pair[1]);
}
#ifdef EVTHREAD_USE_PTHREADS_IMPLEMENTED
static void* del_wait_thread(void *arg)
{
struct timeval tv_start, tv_end;
evutil_gettimeofday(&tv_start, NULL);
event_dispatch();
evutil_gettimeofday(&tv_end, NULL);
test_timeval_diff_eq(&tv_start, &tv_end, 300);
end:
return NULL;
}
static void
del_wait_cb(evutil_socket_t fd, short event, void *arg)
{
struct timeval delay = { 0, 300*1000 };
TT_BLATHER(("Sleeping: %i", test_ok));
evutil_usleep_(&delay);
++test_ok;
}
static void
test_del_wait(void)
{
struct event ev;
THREAD_T thread;
setup_test("event_del will wait: ");
event_set(&ev, pair[1], EV_READ|EV_PERSIST, del_wait_cb, &ev);
event_add(&ev, NULL);
THREAD_START(thread, del_wait_thread, NULL);
if (write(pair[0], TEST1, strlen(TEST1)+1) < 0) {
tt_fail_perror("write");
}
{
struct timeval delay = { 0, 30*1000 };
evutil_usleep_(&delay);
}
{
struct timeval tv_start, tv_end;
evutil_gettimeofday(&tv_start, NULL);
event_del(&ev);
evutil_gettimeofday(&tv_end, NULL);
test_timeval_diff_eq(&tv_start, &tv_end, 270);
}
THREAD_JOIN(thread);
tt_int_op(test_ok, ==, 1);
end:
;
}
static void null_cb(evutil_socket_t fd, short what, void *arg) {}
static void* test_del_notify_thread(void *arg)
{
event_dispatch();
return NULL;
}
static void
test_del_notify(void)
{
struct event ev;
THREAD_T thread;
test_ok = 1;
event_set(&ev, -1, EV_READ, null_cb, &ev);
event_add(&ev, NULL);
THREAD_START(thread, test_del_notify_thread, NULL);
{
struct timeval delay = { 0, 1000 };
evutil_usleep_(&delay);
}
event_del(&ev);
THREAD_JOIN(thread);
}
#endif
static void
signal_cb_sa(int sig)
{
@ -1437,8 +1346,100 @@ test_signal_while_processing(void)
cleanup_test();
return;
}
#endif // \_WIN32
#ifndef EVENT__DISABLE_THREAD_SUPPORT
static void* del_wait_thread(void *arg)
{
struct timeval tv_start, tv_end;
evutil_gettimeofday(&tv_start, NULL);
event_dispatch();
evutil_gettimeofday(&tv_end, NULL);
test_timeval_diff_eq(&tv_start, &tv_end, 300);
end:
return NULL;
}
static void
del_wait_cb(evutil_socket_t fd, short event, void *arg)
{
struct timeval delay = { 0, 300*1000 };
TT_BLATHER(("Sleeping: %i", test_ok));
evutil_usleep_(&delay);
++test_ok;
}
static void
test_del_wait(void)
{
struct event ev;
THREAD_T thread;
setup_test("event_del will wait: ");
event_set(&ev, pair[1], EV_READ|EV_PERSIST, del_wait_cb, &ev);
event_add(&ev, NULL);
THREAD_START(thread, del_wait_thread, NULL);
if (write(pair[0], TEST1, strlen(TEST1)+1) < 0) {
tt_fail_perror("write");
}
{
struct timeval delay = { 0, 30*1000 };
evutil_usleep_(&delay);
}
{
struct timeval tv_start, tv_end;
evutil_gettimeofday(&tv_start, NULL);
event_del(&ev);
evutil_gettimeofday(&tv_end, NULL);
test_timeval_diff_eq(&tv_start, &tv_end, 270);
}
THREAD_JOIN(thread);
tt_int_op(test_ok, ==, 1);
end:
;
}
static void null_cb(evutil_socket_t fd, short what, void *arg) {}
static void* test_del_notify_thread(void *arg)
{
event_dispatch();
return NULL;
}
static void
test_del_notify(void)
{
struct event ev;
THREAD_T thread;
test_ok = 1;
event_set(&ev, -1, EV_READ, null_cb, &ev);
event_add(&ev, NULL);
THREAD_START(thread, test_del_notify_thread, NULL);
{
struct timeval delay = { 0, 1000 };
evutil_usleep_(&delay);
}
event_del(&ev);
THREAD_JOIN(thread);
}
#endif
static void
test_free_active_base(void *ptr)
{
@ -3590,7 +3591,7 @@ struct testcase_t main_testcases[] = {
LEGACY(fork, TT_ISOLATED),
#endif
#ifdef EVTHREAD_USE_PTHREADS_IMPLEMENTED
#ifndef EVENT__DISABLE_THREAD_SUPPORT
LEGACY(del_wait, TT_ISOLATED|TT_NEED_THREADS|TT_RETRIABLE),
LEGACY(del_notify, TT_ISOLATED|TT_NEED_THREADS),
#endif