287 Commits

Author SHA1 Message Date
Azat Khuzhin
23c2914f6b Notify event base if there are no more events, so it can exit without delay
Fixes: #623
2018-04-26 01:14:49 +03:00
Vincent JARDIN
56010f37ae test: fix warning
In function ‘send_a_byte_cb’:
test/regress.c:1853:2: warning: ignoring return value of ‘write’, declared with
attribute warn_unused_result [-Wunused-result]
  (void) write(*sockp, "A", 1);
2017-09-11 21:56:30 +02:00
Carlo Marcelo Arenas Belón
a86f89d333 test: avoid regress hanging in macOS
a backtrace of the process without this patch :
  * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    * frame #0: 0x00007fffb1fb7d96 libsystem_kernel.dylib`kevent + 10
      frame #1: 0x0000000108ed0a58 libevent-2.2.1.dylib`kq_dispatch + 696
      frame #2: 0x0000000108ec53d8 libevent-2.2.1.dylib`event_base_loop + 696
      frame #3: 0x0000000108e1763b regress`test_fork + 1931
      frame #4: 0x0000000108e5c7ad regress`run_legacy_test_fn + 45
      frame #5: 0x0000000108e690aa regress`testcase_run_one + 858
      frame #6: 0x0000000108e6954f regress`tinytest_main + 495
      frame #7: 0x0000000108e5c94b regress`main + 171
      frame #8: 0x00007fffb1e88235 libdyld.dylib`start + 1
      frame #9: 0x00007fffb1e88235 libdyld.dylib`start + 1

Issue: #546
2017-09-11 01:48:35 +03:00
Azat Khuzhin
5ff83989f3 test: cover that after event_del() callback will not be scheduled again
Refs: #236
Refs: #225
2017-04-30 01:35:03 +03:00
Azat Khuzhin
a4b1828d6d test: windows doesn't have WNOWAIT
Fixes: 66a4eb0c3ae3b1f22b084b2d3aeb5c872f37efbd ("Check for WNOWAIT in
waitpid() in runtime (not in cmake/configure)")
2017-03-14 00:04:26 +03:00
Azat Khuzhin
66a4eb0c3a Check for WNOWAIT in waitpid() in runtime (not in cmake/configure)
Because checking in cmake breaks cross-compiling.

Introduced-in: 43eb56c7c738e3642f0981e3dd6ab9e082eec798.
Fixes: #482
Fixes: #462
Refs: #475

v2: use waitid() with WNOWAIT
v3: use WNOWAIT only if it available in waitpid(), because not all netbsd
    supports it
2017-03-08 13:31:55 +03:00
Tim Hentenaar
cb0df5cfac test/regress: cover a polling of invalid fd
Test that an event's callback is called if the fd is closed prior to being
polled for activity.

azat: make it run only for poll backend/method, and do not close fd
twice
2016-11-04 03:28:42 +03:00
Azat Khuzhin
43eb56c7c7 tests: use waitpid(..., WNOWAIT) to fix failing of main/fork under solaris
According to solaris docs:
  "One instance of a SIGCHLD signal is queued for each child process whose
  status has changed. If waitpid() returns because the status of a child
  process is available, and WNOWAIT was not specified in options, any pending
  SIGCHLD signal associated with the process ID of that child process is
  discarded. Any other pending SIGCHLD signals remain pending."

And interesting thing that it works if you add sleep(1) before waitpid(), and
also if you run with --verbose (some race or what).

But linux doesn't support WNOWAIT in waitpid() so add detection into
cmake/autotools.

Fixes: #387
Link: https://bugzilla.redhat.com/show_bug.cgi?id=840782
2016-08-11 17:08:35 +03:00
Azat Khuzhin
16d220cb6f test: replace sleeping with syncing pair in main/fork
About this syncing pair:
- read endpoint, must be blocked, to make it a checkpoint or smth like this
- write endpoint, must be nonblocking, to avoid readcb hung

Refs: #387
2016-08-11 16:18:12 +03:00
Azat Khuzhin
04fc82f7ad test: use EVUTIL_SHUT_WR 2016-03-11 01:28:43 +03:00
Nick Mathewson
4f778ab6d7 Add missing return statement to del_wait_thread so libevent can build. 2016-01-22 11:16:05 -05:00
Azat Khuzhin
5b58b709b2 test/regress: cover event_del() waiting mechanism
Since we have some issues (see refs) for changing waiting order in event_del()
I wrote this simple test, so maybe this test can explain something or at least
cover what we have before and show it will be broken.

P.S. we really need avoid such stuff like lets-test-with-sleep/usleep.

Refs: #225
Refs: #226
Refs: #236
2016-01-03 00:46:47 +03:00
Azat Khuzhin
ceddc607ca test/regress: cover existing signal callbacks and fork() + event_reinit()
Regression-for: 88640aa ("event_reinit: make signals works after fork() without
evsig_add()")
2015-12-27 09:30:10 +03:00
Azat Khuzhin
b075b81cd3 test/regress: cover signals after fork() + event_reinit()
Regression-for: ad0c237 ("event_reinit: always re-init signal's socketpair")
2015-12-27 09:29:57 +03:00
Azat Khuzhin
088d8b39f9 test/regress: main/fork: rewrite assertions by just removing event in callback
Instead of assigning some variable value (got_child), and schedule exit from
loop from that callback, just remove event for that signal, and event loop will
exit automatically when there will be no events.
2015-12-27 09:28:07 +03:00
Ed Schouten
fd36647af1 Don't use BSD u_* types.
These types are not part of POSIX. As we only use them in a small number
of places, we'd better replace them by C standard types. This makes a
larger part of the code build for CloudABI.
2015-08-25 19:15:50 +03:00
Nick Mathewson
89c1a3b7fe Fix several memory leaks in the unit tests.
Also add a comment to buffer.c about why we call
evbuffer_file_segment_free on failure to add the segment.
2014-09-18 12:40:38 -04:00
Nick Mathewson
a677b72bd6 Use evutil_weakrand() in unit tests.
(Coverity doesn't like random() or rand().  We don't care; this is
for unit tests.)

Fixes CID 1239298, 1239296, 1239295, 1239293.
2014-09-18 12:02:13 -04:00
Azat Khuzhin
b897beff6a test/regress: add simplestsignal: to track reorder bugs separately 2014-06-29 17:39:33 +04:00
Nick Mathewson
c2076824a3 Fix a c90 warning 2014-01-21 12:21:37 -05:00
Nick Mathewson
867f401f9b Fix a pile of coverity warnings in the unit tests
Most of these problems can only trigger when the tests fail, but it's
good hygiene to keep the code warning-free in any case.
2014-01-08 11:51:22 -05:00
Nick Mathewson
f9e091bf4e Merge remote-tracking branch 'asweeny86/event-count-max' 2014-01-06 12:11:30 -05:00
Andrew Sweeney
26230a2d21 Added unit test for max event counts 2014-01-05 16:30:35 -05:00
Nick Mathewson
87fa2b004a Unit tests for active_by_fd; unsupport active_by_fd(TIMEOUT)
[It turns out that event_base_active_by_fd(TIMEOUT) didn't actually
work right. Feel free to add it back in as a patch.]
2013-12-23 20:46:38 -05:00
Nick Mathewson
1104d0bee9 Fix a (failure-only) null dereference in the unit tests 2013-08-06 19:31:26 -04:00
Nick Mathewson
7080d55c49 Use void casts to suppress some "unchecked return value" warns 2013-08-06 19:28:53 -04:00
Mobai Zhang
0fa107d8cb Added event_base_get_num_events() 2013-07-02 16:01:02 -04:00
Nick Mathewson
702c9aa403 Fix a bug in the new main/event_foreach test
It wasn't making sure that the events weren't internal.
2013-04-26 19:14:05 -04:00
Nick Mathewson
d5967397b0 More unit tests for initializing common timeouts.
Try with: misformed usecs in inputs, and with initializing common timeouts
from other common timeouts.
2013-04-26 17:51:33 -04:00
Nick Mathewson
f09629eac5 A test for event_get_assignment() 2013-04-26 17:46:33 -04:00
Nick Mathewson
30ea2910d5 Unit tests for event_base_gettimeofday_cached() and event_base_update_cache_time() 2013-04-26 17:37:15 -04:00
Nick Mathewson
0b096efee5 New tests for event_base_foreach_event()
Our dump-events code had exercised this a bit, but only via the
nonlocking backend. Also, nothing was checking the "Search for a
specific event" code.
2013-04-26 13:52:51 -04:00
Nick Mathewson
a153874d18 New test for active_later->active transition on event_active
When event_active is called, an active_later event is supposed to become
active now.  We had lacked a test for that.
2013-04-26 13:49:45 -04:00
Nick Mathewson
1c3147f5e7 Add a test with an active_later event at event_base_free time. 2013-04-10 18:03:16 -04:00
Nick Mathewson
96150dd0c6 Unit test for event_remove_timer with EV_PERSIST.
Patch from dcicppin on sourceforge.
2013-02-13 11:41:11 -05:00
Nick Mathewson
e3b2e0869e Add an event_remove_timer() to remove timer on an event without deleting it 2012-11-16 16:43:17 -05:00
Nick Mathewson
5a9a014189 Fix a couple of compile warnings in the unit tests 2012-11-16 16:17:07 -05:00
Nick Mathewson
4343edf3c6 Add a unit test in which an event is created with event_base_once() but never fires 2012-11-16 10:17:34 -05:00
Nick Mathewson
7ef04e4b48 Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	configure.in
	test/regress_buffer.c
	test/regress_dns.c
2012-07-26 10:09:13 -04:00
Nick Mathewson
3cde5bf57a Avoid more crashes/bad calls in unit tests; found by coverity 2012-07-26 10:04:43 -04:00
Nick Mathewson
4f3732d75e Fix various check-after-dereference issues in unit tests: found by coverity 2012-07-26 09:35:43 -04:00
Nick Mathewson
c8009d2985 Check return value of write() in regress.c 2012-06-29 12:47:03 -04:00
Nick Mathewson
745a63dba3 Add "active later" event_callbacks to supersede deferred
An event or event callback can now be in an additional state: "active
later".  When an event is in this state, it will become active the
next time we run through the event loop.  This lets us do what we
wanted to with deferred callbacks: make a type of active thing that
avoids infinite circular regress in a way that starves other events or
exhausts the stack.  It improves on deferred callbacks by respecting
priorities, and by having a non-kludgy way to avoid event starvation.
2012-05-09 12:05:53 -04:00
Nick Mathewson
e06206ebd8 Oops; fix the *right* windows compile issue 2012-05-03 12:15:11 -04:00
Nick Mathewson
be7a0be816 Fix win32 build issues: sleep, pid_t 2012-05-03 12:05:52 -04:00
Nick Mathewson
a163026099 Merge branch '21_robust_monotonic' 2012-05-01 13:22:56 -04:00
Nick Mathewson
2e882a071b Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	event.c
2012-04-30 22:00:05 -04:00
Nick Mathewson
30f0671526 Merge remote-tracking branch 'github/20_active_prio_inv' into patches-2.0 2012-04-30 21:45:43 -04:00
Nick Mathewson
b3887cdf3b Work-around a stupid gcov-breaking bug in OSX 10.6
This only affects the unit tests.

Fix found at http://rachelbythebay.com/w/2011/07/12/forkcrash/

(Backport from 2.1)
2012-04-30 21:17:26 -04:00
Nick Mathewson
2bfda4012c If a higher-priority event becomes active, don't continue running events of the current priority.
Bug found by Ralph Castain.
2012-04-30 17:30:48 -04:00