1183 Commits

Author SHA1 Message Date
Vis Virial
360aa233f0 add tests for evutil_date_rfc1123(). 2016-12-19 00:58:49 +03:00
Azat Khuzhin
cfe2ab22f2 test/https: fix ssl dirty bypass for https_simple
Tests:
- http/https_simple_dirty # not affected, since dirty is the default
- http/https_simple       # affected

v2: fix compilation with -DEVENT__DISABLE_OPENSSL=ON
2016-12-07 01:30:41 +03:00
Azat Khuzhin
45247e6fd9 test/https: cover multiple request over the same connection
Introduce two new tests:
- http/https_connection         # fail
- http/https_persist_connection # ok

Reported-by: liutao74748@163.com
2016-12-07 01:24:40 +03:00
Azat Khuzhin
e6ae069b48 test/http: sanity check for http_request_empty_done() 2016-12-07 01:24:40 +03:00
Azat Khuzhin
532a47ce1e test: fix building under openssl 1.1 (init functions has been deprecated)
Refs: #397
2016-12-07 01:14:16 +03:00
Azat Khuzhin
336f3b11e5 Fix _FILE_OFFSET_BITS redinition (solaris/autotools)
So firstly include our header (config.h) -- <evconfig-private.h>, and
only after it <sys/types.h> since latest has #ifdef guard, while our
config.h is not inteded for this.

And besides all this thing with LARGE_FILE is a abit awkward, since we
don't nefine _LP64/_LP32 anyway, and so we have next error actually (64bit VS
32bit):
==> solaris: In file included from ./util-internal.h:30:0,
==> solaris:                  from test/regress_ssl.c:49:
  ==> solaris: ./evconfig-private.h:29:0: warning: "_FILE_OFFSET_BITS" redefined
  ==> solaris:  #define _FILE_OFFSET_BITS 64
  ==> solaris:  ^
  ==> solaris: In file included from /usr/include/sys/types.h:17:0,
  ==> solaris:                  from test/regress_ssl.c:38:
  ==> solaris: /opt/csw/lib/gcc/i386-pc-solaris2.10/5.2.0/include-fixed/sys/feature_tests.h:196:0: note: this is the location of the previous definition
  ==> solaris:  #define _FILE_OFFSET_BITS 32
  ==> solaris:  ^

For cmake it commented in: 8b228e27f57300be61b57a41a2ec8666b726dc34
("Lot's of cmake updates")
2016-12-06 13:21:28 +03:00
Azat Khuzhin
253e7fa90c util-internal: fix __func__ redefinition (netbsd)
==> netbsd: In file included from ../listener.c:57:0:
==> netbsd: ../util-internal.h:58:0: warning: "__func__" redefined [enabled by default]
==> netbsd:  #define __func__ EVENT____func__
==> netbsd:  ^
==> netbsd: In file included from /usr/include/amd64/types.h:39:0,
==> netbsd:                  from /usr/include/sys/types.h:45,
==> netbsd:                  from ../listener.c:30:
==> netbsd: /usr/include/sys/cdefs.h:394:0: note: this is the location of the previous definition
==> netbsd:  #define __func__ __PRETTY_FUNCTION__
2016-12-06 12:54:33 +03:00
Azat Khuzhin
2c62062e12 Fix signedness differ for iov_base (solaris) 2016-12-06 12:54:33 +03:00
Philip Prindeville
6bf2061c4b C90 doesn't like declarations intermingled with statements
So move all of the declarations to the top of the offending function.

This patch includes both of issues (Fixes:), from @jeking3 and
@pprindeville

Fixes: #418
Fixes: nmathewson/Libevent#136
2016-12-06 09:56:28 +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
Thomas Bernard
e983712456 use ev_uint16_t instead of unsigned short for port
Like in `sockaddr_in` structure in /usr/include/netinet/in.h

@azat: convert all other users (bench, compat, ..) and tweak message
Fixes: #178
Fixes: #196
Refs: 6bf1ca78
Link: https://codereview.appspot.com/156040043/#msg4
2016-10-26 01:41:13 +03:00
Kurt Roeckx
3e9e0a0d46 Make it build using OpenSSL 1.1.0
Rebased (azat):
- tabs instead of whitespaces
- make openssl-compat.h safe for complex expressions
- do not call sk_SSL_COMP_free() in 1.1 (fixes double free)

TODO:
- clean methods_bufferevent

Closes: #397 (cherry-picked)
2016-10-16 19:05:24 +03:00
Adam Langley
f9803a6943 Switch from a 512 to 2048-bit RSA key.
The 512 bit key is too small to sign larger hashes. This can cause the
regression tests to fail depending on the defaults in libssl.
2016-10-13 16:12:07 -07: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
500b6b7577 test/http: do not run tests that based on backlog filling (freebsd)
I cannot find any other solution for now, so simply ignore them for now, we
should think about normal fix for this.

Refs: #388
2016-08-11 00:11:05 +03:00
Azat Khuzhin
4410e9dfb3 test/bufferevent/iocp: fix test name for "bufferevent_connect_fail_eventcb" 2016-08-10 12:07:58 +03:00
Azat Khuzhin
a9e8cd6738 test/ssl: use send()/recv()/EVUTIL_ERR_RW_RETRIABLE()/EVUTIL_SOCKET_ERROR() to fix win32
Fixes: https://ci.appveyor.com/project/azat/libevent/build/2.1.5.107/job/k70our1xdp0ym4dm#L1906
Fixes: ssl/bufferevent_connect_sleep
2016-08-09 15:47:58 +03:00
Azat Khuzhin
d5a2f2f97f test/https_basic: increase timeout for complete write (fixes win32)
Otherwise on win32 we got 2, but test is ok, some timings issue.

Introduced-in: c968eb3
Fixes: https://ci.appveyor.com/project/azat/libevent/build/2.1.5.107/job/k70our1xdp0ym4dm#L1906
2016-08-09 15:47:58 +03:00
Azat Khuzhin
a487706e10 test: fix building with --disable-thread-support under win32 2016-08-09 15:47:58 +03:00
Azat Khuzhin
bb09535bda autoconf: fix --disable-thread-support build under win32
Fixes: https://ci.appveyor.com/project/azat/libevent/build/job/gvud4tcqsd5bnarl
Fixes: https://ci.appveyor.com/project/azat/libevent/build/2.1.6.80/job/5frnb1c3n4quxxqy
Fixes: https://ci.appveyor.com/project/azat/libevent/build/2.1.6.80/job/3wdahbrew7setmoa
2016-08-09 15:47:58 +03:00
Azat Khuzhin
48dab7aa33 test/buffer: cover evbuffer_expand() for overflow
Refs: #306
Refs: #340
2016-06-26 01:59:42 +03:00
Azat Khuzhin
a69e4fadca buffer: Merge branch 'evbuffer-empty-chains-fixes-v4'
This fixes bug with empty-chains and
evbuffer_add_buffer()/evbuffer_remove_buffer().

* evbuffer-empty-chains-fixes-v4:
  buffer: evbuffer_add_buffer(): clean empty chains from destination buffer
  test/buffer: evbuffer_add_buffer() with empty chains
  test/buffer: evbuffer_remove_buffer() with empty chains (prepend)
  test/buffer: evbuffer_remove_buffer() with empty chains (evbuffer_add_buffer())

Reported-by: Eduardo Panisset <eduardo@anchorfree.com>
2016-06-19 13:24:18 +03:00
Eduardo Panisset
766194b35d test/be_filter: creating test case for data stuck with active watermarks
v2: fix whitespaces
    s/int/size_t/
    use tt_int_op()
    s/malloc/calloc (to avoid possible false-positive)
2016-06-19 13:19:01 +03:00
David Paschich
285188963d Fix bufferevent_pair to properly set BEV_EVENT_{READING,WRITING} on flush.
Here's some fun. From `bufferevent.h`:
  ```
  #define BEV_EVENT_READING	0x01	/**< error encountered while reading */
  #define BEV_EVENT_WRITING	0x02	/**< error encountered while writing */
  ```

And from `event.h`:
  ```
  /** Wait for a socket or FD to become readable */
  #define EV_READ		0x02
  /** Wait for a socket or FD to become writeable */
  #define EV_WRITE	0x04
  ```

Library users have to be very careful to get this right; it turns out, the
library itself got this wrong in the `bufferevent_pair` code. It appears that
in most of the code, only `BEV_EVENT_FINISHED` will indicate whether it's read
or write; on error or timeout, it appears that "both" is assumed and not set in
the callback. I read through all the other places where `BEV_EVENT_FINISHED` is
passed to an event callback; it appears that the pair code is the only spot
that got it wrong.

azat: add TT_FORK to avoid breaking clean env, and rebase commit message
(copied from #359)
Fixes: #359
2016-06-17 18:21:45 +03:00
Azat Khuzhin
a272bc4227 test/buffer: evbuffer_add_buffer() with empty chains
Reported-by: @EMPanisset
Link: https://github.com/libevent/libevent/issues/358#issuecomment-225345697
2016-06-17 17:40:40 +03:00
Azat Khuzhin
f0cfa146d5 test/buffer: evbuffer_remove_buffer() with empty chains (prepend)
Using:
- evbuffer_add()
- evbuffer_prepend_buffer()
- evbuffer_add_reference()
- evbuffer_remove_buffer()
2016-06-17 17:20:35 +03:00
Azat Khuzhin
2880ce6a03 test/buffer: evbuffer_remove_buffer() with empty chains (evbuffer_add_buffer())
Using:
- evbuffer_add()
- evbuffer_add_buffer() -- the one that has problem
- evbuffer_add_reference() -- the only one that allows empty chains to be added
- evbuffer_remove_buffer()
2016-06-17 17:20:35 +03:00
Azat Khuzhin
2a4bf29470 test/http: avoid using conditionals with omitted operands (fixes VS2015)
But we need to add VS2015 build on appveyor.

Fixes: #361
Reported-by: @nntrab
2016-06-17 17:04:37 +03:00
Azat Khuzhin
aabf1c2dd1 test/http: don't mix declarations and code (fixes -Wdeclaration-after-statement) 2016-06-17 16:07:15 +03:00
Azat Khuzhin
c08d90ba5a test/buffer: fix leak in test_evbuffer_prepend() 2016-06-17 16:06:12 +03:00
Azat Khuzhin
e7d1e3926b test/buffer: avoid errors with --no-fork (reinitialize static vars) 2016-06-17 15:44:13 +03:00
Azat Khuzhin
e77ff4187f test/buffer: cover n_add_for_cb when evbuffer_prepend() need to allocate buffer
Regression-for: 0abd0393eaf029e1ead8a09b479ea6830f7152ee ("Fix n_add_for_cb in
evbuffer_prepend() in case of new buffer required")
2016-04-21 02:15:08 +03:00
Azat Khuzhin
bd19a28ac4 test/tinytest_macros: add new one tt_nstr_op() 2016-04-21 02:15:08 +03:00
Azat Khuzhin
ae2881254a test/bufferevent: check that output_filter disabled during processing output
Regression-for: c031215d532c97f1d82efd672ecd622d31d3342d ("be_filter: actually
disable output_filter during processing output")
2016-04-18 13:39:03 +03:00
Azat Khuzhin
7d85651694 test/listener: regression for missing unlock in listener_read_cb()
P.S. it triggers even without pthread, but this makes checks more strict.

Refs: #341
2016-04-01 00:04:35 +03:00
Marcus Sundberg
d5ee739153 test/regress: add tests for evbuffer_add() breakage on empty last chain
The evbuffer/add* tests currenly break on 2.0.21, 2.0.22 and 2.1 HEAD
due to issue #335. The evbuffer/reference2 test breaks on 2.0.21 and
2.0.22 due to commit b18c04dd not being applied.
2016-03-26 20:51:46 +01:00
Azat Khuzhin
bddad71e51 test/http: fix running some tests sequential (with --no-fork)
After this patch
$ regress --no-fork +http/..

Passed without failures.
2016-03-25 11:32:33 +03:00
Azat Khuzhin
cbc3209d61 test/http: localize evhttp server structure 2016-03-25 11:20:11 +03:00
Azat Khuzhin
d7348bab60 test/dns: regression for empty hostname
Refs: #332
2016-03-25 00:33:43 +03:00
Azat Khuzhin
d49a65879f test/http: fix SERVER_TIMEOUT tests under win32
Seems that the hack with filling BACKLOG didn't work on win32, and hence we
stuck in write() waiting, not in connect()

And:
$ time regress http/cancel_server_timeout
- on linux: 10secs
- on win32: 2-5secs

I tried to debug this but you can't sniff TCP packages (wireshark/rawpcap) on
localhost in windows xp (according to [RAWPCAP] and my testing).

RAWPCAP: http://www.netresec.com/?page=RawCap
2016-03-24 21:01:16 +03:00
Azat Khuzhin
376f107318 test/http: add a helper for creating timedout/failed request 2016-03-24 20:28:20 +03:00
Azat Khuzhin
d02a2858fa test/http: adopt for C90 (mixed code and declarations) 2016-03-24 14:11:28 +03:00
Azat Khuzhin
0c343afea9 test/http: cover NS timed out during request cancellations separatelly 2016-03-24 14:00:44 +03:00
Azat Khuzhin
334340da51 test/http: request cancellation with resolving/{conn,write}-timeouts in progress
This patch adds 8 new tests:
- http/cancel
- http/cancel_by_host
- http/cancel_by_host_no_ns
- http/cancel_by_host_inactive_server
- http/cancel_inactive_server
- http/cancel_by_host_no_ns_inactive_server
- http/cancel_by_host_server_timeout
- http/cancel_server_timeout
- http/cancel_by_host_no_ns_server_timeout

This patches not 100% for http layer, but more for be_sock, but it was simpler
to add them here, plus it also shows some bugs with fd leaking in http layer.

Right now we have next picture (we can also play with timeouts/attempts for
evdns to make tests fail, IOW to track the failures even without valgrind):
$ valgrind --leak-check=full --show-reachable=yes --track-fds=yes --error-exitcode=1 regress --no-fork http/cancel..
http/cancel: OK
http/cancel_by_host: OK
http/cancel_by_host_no_ns: [msg] Nameserver 127.0.0.1:42489 has failed: request timed out.
[msg] All nameservers have failed
OK
http/cancel_by_host_inactive_server: OK
http/cancel_inactive_server: OK
http/cancel_by_host_no_ns_inactive_server: [msg] Nameserver 127.0.0.1:51370 has failed: request timed out.
[msg] All nameservers have failed
OK
http/cancel_by_host_server_timeout: OK
http/cancel_server_timeout: OK
http/cancel_by_host_no_ns_server_timeout: [msg] Nameserver 127.0.0.1:45054 has failed: request timed out.
[msg] All nameservers have failed
OK
9 tests ok.  (0 skipped)
==3202==
==3202== FILE DESCRIPTORS: 2309 open at exit.
...
==8403== HEAP SUMMARY:
==8403==     in use at exit: 1,104 bytes in 5 blocks
==8403==   total heap usage: 10,916 allocs, 10,911 frees, 1,458,818 bytes allocated
==8403==
==8403== 40 bytes in 1 blocks are indirectly lost in loss record 1 of 5
==8403==    at 0x4C2BBD5: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8403==    by 0x4AAD2D: event_mm_calloc_ (event.c:3459)
==8403==    by 0x498E48: evbuffer_add_cb (buffer.c:3309)
==8403==    by 0x4A0DE2: bufferevent_socket_new (bufferevent_sock.c:366)
==8403==    by 0x4BF8BA: evhttp_connection_base_bufferevent_new (http.c:2369)
==8403==    by 0x4BFA6A: evhttp_connection_base_new (http.c:2421)
==8403==    by 0x460CFC: http_cancel_test (regress_http.c:1413)
==8403==    by 0x490965: testcase_run_bare_ (tinytest.c:105)
==8403==    by 0x490C47: testcase_run_one (tinytest.c:252)
==8403==    by 0x491586: tinytest_main (tinytest.c:434)
==8403==    by 0x47DFCD: main (regress_main.c:461)
==8403==
==8403== 136 bytes in 1 blocks are indirectly lost in loss record 2 of 5
==8403==    at 0x4C2BBD5: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8403==    by 0x4AAD2D: event_mm_calloc_ (event.c:3459)
==8403==    by 0x491EDD: evbuffer_new (buffer.c:365)
==8403==    by 0x49A0AB: bufferevent_init_common_ (bufferevent.c:300)
==8403==    by 0x4A0D31: bufferevent_socket_new (bufferevent_sock.c:353)
==8403==    by 0x4BF8BA: evhttp_connection_base_bufferevent_new (http.c:2369)
==8403==    by 0x4BFA6A: evhttp_connection_base_new (http.c:2421)
==8403==    by 0x460CFC: http_cancel_test (regress_http.c:1413)
==8403==    by 0x490965: testcase_run_bare_ (tinytest.c:105)
==8403==    by 0x490C47: testcase_run_one (tinytest.c:252)
==8403==    by 0x491586: tinytest_main (tinytest.c:434)
==8403==    by 0x47DFCD: main (regress_main.c:461)
==8403==
==8403== 136 bytes in 1 blocks are indirectly lost in loss record 3 of 5
==8403==    at 0x4C2BBD5: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8403==    by 0x4AAD2D: event_mm_calloc_ (event.c:3459)
==8403==    by 0x491EDD: evbuffer_new (buffer.c:365)
==8403==    by 0x49A0E8: bufferevent_init_common_ (bufferevent.c:305)
==8403==    by 0x4A0D31: bufferevent_socket_new (bufferevent_sock.c:353)
==8403==    by 0x4BF8BA: evhttp_connection_base_bufferevent_new (http.c:2369)
==8403==    by 0x4BFA6A: evhttp_connection_base_new (http.c:2421)
==8403==    by 0x460CFC: http_cancel_test (regress_http.c:1413)
==8403==    by 0x490965: testcase_run_bare_ (tinytest.c:105)
==8403==    by 0x490C47: testcase_run_one (tinytest.c:252)
==8403==    by 0x491586: tinytest_main (tinytest.c:434)
==8403==    by 0x47DFCD: main (regress_main.c:461)
==8403==
==8403== 528 bytes in 1 blocks are indirectly lost in loss record 4 of 5
==8403==    at 0x4C2BBD5: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8403==    by 0x4AAD2D: event_mm_calloc_ (event.c:3459)
==8403==    by 0x4A0D02: bufferevent_socket_new (bufferevent_sock.c:350)
==8403==    by 0x4BF8BA: evhttp_connection_base_bufferevent_new (http.c:2369)
==8403==    by 0x4BFA6A: evhttp_connection_base_new (http.c:2421)
==8403==    by 0x460CFC: http_cancel_test (regress_http.c:1413)
==8403==    by 0x490965: testcase_run_bare_ (tinytest.c:105)
==8403==    by 0x490C47: testcase_run_one (tinytest.c:252)
==8403==    by 0x491586: tinytest_main (tinytest.c:434)
==8403==    by 0x47DFCD: main (regress_main.c:461)
==8403==
==8403== 1,104 (264 direct, 840 indirect) bytes in 1 blocks are definitely lost in loss record 5 of 5
==8403==    at 0x4C2BBD5: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8403==    by 0x4AAD2D: event_mm_calloc_ (event.c:3459)
==8403==    by 0x4D0326: evdns_getaddrinfo (evdns.c:4682)
==8403==    by 0x4B1213: evutil_getaddrinfo_async_ (evutil.c:1568)
==8403==    by 0x4A1255: bufferevent_socket_connect_hostname (bufferevent_sock.c:517)
==8403==    by 0x4C00B6: evhttp_connection_connect_ (http.c:2582)
==8403==    by 0x4C02B8: evhttp_make_request (http.c:2637)
==8403==    by 0x4614EC: http_cancel_test (regress_http.c:1496)
==8403==    by 0x490965: testcase_run_bare_ (tinytest.c:105)
==8403==    by 0x490C47: testcase_run_one (tinytest.c:252)
==8403==    by 0x491586: tinytest_main (tinytest.c:434)
==8403==    by 0x47DFCD: main (regress_main.c:461)
==8403==
==8403== LEAK SUMMARY:
==8403==    definitely lost: 264 bytes in 1 blocks
==8403==    indirectly lost: 840 bytes in 4 blocks
==8403==      possibly lost: 0 bytes in 0 blocks
==8403==    still reachable: 0 bytes in 0 blocks
==8403==         suppressed: 0 bytes in 0 blocks
2016-03-23 12:46:10 +03:00
Azat Khuzhin
927ab33f3b test/http: exit from the loop in the errorcb to wait cancellation
This will make cancellation tests more graceful, that said that error_cb can
not be called sometimes if you will break the loop in cancel.

Plus drop that define for function generations, since function body changed,
and it is not generic anymore, plus that macro didn't used by anyone else.
2016-03-23 12:11:29 +03:00
Azat Khuzhin
351207f400 regress_clean_dnsserver(): reset global port vars
This will fix some test chains with --no-fork.
2016-03-23 12:09:37 +03:00
Azat Khuzhin
3b581693ac test/http: read_on_write_error: fix it for win32
Fixes: https://ci.appveyor.com/project/nmathewson/libevent/build/2.1.5.216#L499 (win32)
2016-03-11 20:59:58 +03:00
Azat Khuzhin
5c2b4c19f1 test/http: separate coverage for EVHTTP_CON_READ_ON_WRITE_ERROR 2016-03-11 19:42:25 +03:00
Azat Khuzhin
31d8116313 test/http: cover "Expect: 100-continue" client-server interaction 2016-03-11 19:19:14 +03:00