1305 Commits

Author SHA1 Message Date
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
Azat Khuzhin
ed469abbac test/http: *lingering tests shouldn't have "Expect: 100-continue" 2016-03-11 19:19:14 +03:00
Azat Khuzhin
04fc82f7ad test: use EVUTIL_SHUT_WR 2016-03-11 01:28:43 +03:00
Azat Khuzhin
3166765903 test/http: avoid huge stack allocations to fix win32 builds
Since according to [DOC] default stack size is 1MB, so let's use dynamic
allocations instead of changing defaults.

DOC: https://msdn.microsoft.com/en-us/library/8cxs58a6.aspx
Not-fixes: http/data_length_constraints
Fixes: http/lingering_close
Fixes: http/non_lingering_close
Fixes: https://ci.appveyor.com/project/nmathewson/libevent/build/2.1.5.213
2016-03-10 20:01:55 +03:00
Azat Khuzhin
e122ca1eed test: http/lingering_close: cover EVHTTP_SERVER_LINGERING_CLOSE 2016-03-09 18:52:52 +03:00
Azat Khuzhin
f41e1b016f test: http/non_lingering_close: cover ~EVHTTP_SERVER_LINGERING_CLOSE 2016-03-09 18:52:52 +03:00
Azat Khuzhin
addf2b90ae test: http/*: update expected HTTP codes for body exceeds max_body_size 2016-03-09 18:52:52 +03:00
Azat Khuzhin
d38a723974 test: http/data_length_constrains: set EVHTTP_CON_READ_ON_WRITE_ERROR 2016-03-09 18:52:52 +03:00
Azat Khuzhin
0792e1e7a7 test: increase buffer size for http/data_length_constraints to trigger EPIPE
With greater buffer it can't be written with one writev(2), and hence we can
trigger more tricky cases, like calling writecb/readcb more then once.

Refs: #321
2016-03-09 01:12:50 +03:00
Azat Khuzhin
f062bbe3f9 test/tinytest_demo: include <windows.h> for win32 to fix tdm-gcc
From: @gvanem
Fixes: #325
2016-02-24 14:12:55 +03:00
Trond Norbye
73d0360e83 test/regress_ssl: Fix compile problems for win32
Windows doesn't have unistd.h, but have the required
functionality in io.h.

azat: use ev_ssize_t instead of ssize_t
2016-02-15 23:29:10 +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
Mark Ellzey
a264da8671 Revert "The Windows socket type is defined as SOCKET." 2015-12-20 00:57:50 -08:00
billsegall
ded8086656 Provide a mechanism for building the library on Windows with different compiler flags. Add a batch file that builds it for the M[DT][d] options and performs a hunt and gather of the different output libraries. 2015-12-17 21:27:37 +10:00
Azat Khuzhin
0b9d43249b test/dns: check exit code of evdns_getaddrinfo()
By some reason all autotools builds failed:
CI: https://travis-ci.org/libevent/libevent/builds/93125954
2015-11-25 17:30:31 +03:00
Azat Khuzhin
4ad348310c test/dns: cover evdns_getaddrinfo() and evdns_base_free() with @fail_requests 2015-11-25 13:09:02 +03:00
Azat Khuzhin
d6c6fb4200 test/dns: cover @fail_requests for evdns_base_free() 2015-11-25 13:09:02 +03:00
Azat Khuzhin
123d372864 test/dns: more graceful coverage of @fail_requests
In case when evdns_base_free() called with @fail_requests, we can potentially
have leaks, but we can avoid them if we will run event loop once again to
trigger defer cbs, so let's do this, instead of magical decrements (and also
this will give an example how to avoid leaks for evdns).
2015-11-25 13:09:01 +03:00
Azat Khuzhin
da0ea7ae77 test/ssl: cover busy-loop (i.e. {read,write}-blocked-on-{write,read} stuff)
This covers SSL_ERROR_WANT_READ/SSL_ERROR_WANT_WRITE error codes from ssl,
under which we must block read/write to avoid busy looping, and hence extra CPU
usage.
This test introduces custom BIO that will count read/write and validates
counters, with patches for be_openssl that drops handling
SSL/SSL_ERROR_WANT_READ there are more then 43K reads, so 100 is pretty ok.
2015-11-18 15:40:47 +03:00
Azat Khuzhin
23c77b6054 test/http: write_during_read for https 2015-11-18 15:40:47 +03:00
Azat Khuzhin
7ea26f71b8 test/http: connection_fail for https 2015-11-18 15:40:47 +03:00
Azat Khuzhin
ac04968311 test/http: stream_out for https 2015-11-18 15:40:47 +03:00
Azat Khuzhin
a71ffb9d1b test/http: chunk_out for https 2015-11-18 15:39:08 +03:00
Azat Khuzhin
3160716f26 test/regress: fix ssl-less builds (need to make this prettier)
CI: https://travis-ci.org/libevent/libevent/jobs/89590839
2015-11-06 10:21:04 +03:00
Azat Khuzhin
1ede3262cc test/http: allow dirty shutdown for ssl to fix https_incomplete 2015-11-06 09:43:25 +03:00