summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzat Khuzhin <azat@libevent.org>2023-02-12 21:39:04 +0100
committerAzat Khuzhin <azat@libevent.org>2023-02-12 21:54:45 +0100
commit0ea20582520e25659586afa460ec15de0e590725 (patch)
treef7028c874d5e1a7b5ef6c399945f5d0ea0c5441f
parent765fb4108d06726b43a30afda8a6e3b55b5e91b3 (diff)
downloadlibevent-0ea20582520e25659586afa460ec15de0e590725.tar.gz
test: add del_wait/del_notify tests for windows
Test manually, since CI is too slow
-rw-r--r--test/regress.c185
1 files changed, 93 insertions, 92 deletions
diff --git a/test/regress.c b/test/regress.c
index 63c935e5..e7e8d21c 100644
--- a/test/regress.c
+++ b/test/regress.c
@@ -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