1336 Commits

Author SHA1 Message Date
Azat Khuzhin
90846c30ff test: add --retries-delay (and set to 1 second by default)
In attemp to address failures of dns/tcp_* tests under windows [1].

  [1]: https://github.com/azat/libevent/runs/3644218468?check_suite_focus=true
2021-09-19 13:49:18 +03:00
Azat Khuzhin
d7d6af7578 test: add --retries argument 2021-09-19 13:47:32 +03:00
Azat Khuzhin
29492364a2 test/regress_http: mark data_length_constraints as retriable
CI: https://github.com/libevent/libevent/runs/3643914024?check_suite_focus=true
2021-09-19 12:56:24 +03:00
Azat Khuzhin
7855900c01 test/dns: mark TCP tests as retriable
CI: https://github.com/azat/libevent/runs/3643912296 # tcp_resolve_many_clients
CI: https://github.com/azat/libevent/runs/3643912192 # tcp_timeout
CI: https://github.com/azat/libevent/runs/3643912336 # tcp_resolve
CI: https://github.com/azat/libevent/runs/3643912174 # tcp_resolve_pipeline
2021-09-19 12:29:02 +03:00
Azat Khuzhin
6ad6afb646 test/regress: retry some signal rlated tests in darwin
CI: https://github.com/azat/libevent/runs/3643912290 # simplestsignal
CI: https://github.com/azat/libevent/runs/3643912296 # simplesignal
CI: https://github.com/azat/libevent/runs/3643912228 # multiplesignal
2021-09-19 12:26:14 +03:00
Azat Khuzhin
58606a62e2 test/regress_util: mark monotonic_prc as retriable
CI: https://github.com/azat/libevent/runs/3643966877
2021-09-19 12:21:39 +03:00
Azat Khuzhin
de53da2e3c test/regress_http: fix unix_socket test 2021-09-19 11:13:30 +03:00
Azat Khuzhin
95eadf0426 test/regress_http: disable max_connections/data_length_constraints under windows
CI: https://github.com/libevent/libevent/runs/3643554394
2021-09-19 10:56:52 +03:00
Azat Khuzhin
f1e9e4dad3 test: cleanup stalled socket after running http/unix_sock
Otherwise it breaks upload-artifacts:

    Run actions/upload-artifact@v1
    Uploading artifact 'ubuntu-18.04-cmake-NONE-build' from '/home/runner/work/libevent/libevent/build' for run #346
    Uploading 1095 files
    File error 'No such device or address' when uploading file '/home/runner/work/libevent/libevent/build/foo'.
    ...
    Error: No such device or address
    Error: Exit code 1 returned from process: file name '/home/runner/runners/2.282.1/bin/Runner.PluginHost', arguments 'action "GitHub.Runner.Plugins.Artifact.PublishArtifact, Runner.Plugins"'.
2021-09-19 01:47:42 +03:00
Azat Khuzhin
f89e86123c test: check return value of write()/send() in bufferevent_read_failed
This will also suppress:

    ../test/regress_bufferevent.c: In function ‘test_bufferevent_read_failed’: 1102
    ../test/regress_bufferevent.c:1395:2: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result] 1103
      write(data->pair[0], buf, strlen(buf));
2021-09-19 01:24:20 +03:00
Azat Khuzhin
04fcd7c6df test: mark util/monotonic_prc_fallback as retriable
Refs: #1193
2021-09-19 00:57:31 +03:00
Pierce Lopez
5303feff99 test: http_unix_socket_test: fix url could be freed uninitialized
> regress_http.c:2279:2: warning: variable 'uri' is used uninitialized
>     whenever 'if' condition is true
2021-09-17 10:33:55 -04:00
Pierce Lopez
4f73bf3a46 test: regress_http: skip unix socket parsing tests in windows
windows doesn't do unix sockets
2021-09-17 10:33:55 -04:00
Pierce Lopez
58d4e50d3c test: fix regress_http evhttp_bind_unixsocket() on macOS
needs to use evutil socket helper for SOCK_NONBLOCK / SOCK_CLOEXEC
2021-09-17 10:33:55 -04:00
Pierce Lopez
fabbf3b310 test: skip dns_initialize_nameservers if missing /etc/resolv.conf
some build systems run tests in minimal containers with no resolv.conf,
and the primary thing this test does is load the default /etc/resolv.conf
2021-09-14 01:19:36 -04:00
Azat Khuzhin
86292628e3 test: fix checking test args for http_parse_uri_test 2021-08-10 23:22:10 +03:00
Sean Young
f446229b22 http: support unix domain sockets
There are no standard for encoding a unix socket in an url. nginx uses:

    http://unix:/path/to/unix/socket:/httppath

The second colon is needed to delimit where the unix path ends and where
the rest of the url continues.

Signed-off-by: Sean Young <sean@mess.org>
2021-08-10 23:22:10 +03:00
Alex Budovski
8f74b30c40 Replace gettimeofday with the portable wrapper
Otherwise the Win32 build fails.
2021-05-30 13:35:41 -05:00
Sergey Matveychuk
19b3fd0bf0 evdns: add ability to get CNAME
Add new flag (DNS_CNAME_CALLBACK) for
evdns_base_resolve_ipv4()/evdns_base_resolve_ipv6().

If set, you will get one more callback with type == DNS_CNAME and CNAME
in addrs argument.
2021-05-24 21:03:45 +03:00
Yi Fan Yu
dff8fd27ed test/regress.h: Increase default timeval tolerance 50 ms -> 100 ms
The default timeout tolerance is 50 ms,
which causes intermittent failure in many the
related tests in arm64 QEMU.

See: https://bugzilla.yoctoproject.org/show_bug.cgi?id=14163
(The root cause seems to be a heavy load)

Signed-off-by: Yi Fan Yu <yifan.yu@windriver.com>
2021-04-23 10:27:00 -04:00
fanquake
4c29b01c87
build: remove splice implementation fragments
Looks like a `splice` implementation was planned, but has clearly never
eventuated (the TODO comment is from ~12 years ago, in
8b5bd77415fb6634fadf08357676926fecf5f032). For now, it's probably better
to remove the unused code/correct the docs.
2021-03-28 10:57:11 +08:00
lilei
bc25889fb3 Check return value of evbuffer_remove() in bufferevent_read()
The conflict cast convertion between the return value of
bufferevent_read() and evbuffer_remove(), int(-1)->size_t(An undefined
maximum)

Add test case of bufferevent_read() should return 0 in case of
evbuffer_remove() returns -1

Fixes: #1132
2021-02-04 00:20:36 +03:00
Azat Khuzhin
f17eb6f509 test/regress_http: cover reading of chunked payload by server
This is an example with transfer-encoding by client via bufferevent for
the #1131
2021-01-19 01:23:42 +03:00
chux0519
617ba83874 evdns: add max-probe-timeout/probe-backoff-factor settings
I recently found that when the network status changed when calling
bufferevent_socket_connect_hostname (e.g. switching between several
WIFIs), all DNS servers would fail, and the timeout of probe would be
very long if there were many DNS requests. I want libevent to support
manual setting of MAX_PROBE_TIMEOUT and TIMEOUT_BACKOFF_FACTOR

So move hardcoded MAX_PROBE_TIMEOUT and TIMEOUT_BACKOFF_FACTOR into
struct, and allow changing them.
2021-01-12 10:56:13 +03:00
Azat Khuzhin
a490172d69 Introduce new BUFFEREVENT_SSL_BATCH_WRITE flag to avoid Nagle effect in SSL 2020-10-31 23:04:46 +03:00
Azat Khuzhin
e91c436388 http: add EVHTTP_URI_HOST_STRIP_BRACKETS
Refs: #1115
2020-10-27 02:13:21 +03:00
okhowang(王沛文)
53c6867520 test: fix windows error when mbedtls https 2020-09-16 10:04:36 +08:00
okhowang(王沛文)
2403ae578f test: add https with mbedtls 2020-09-14 19:49:08 +08:00
Berbe
c2a9ecffef
Fix: long -> enum evhttp_cmd_type type 2020-08-29 20:05:52 +02:00
Azat Khuzhin
2338f27e69 test/regress_dns: fix -Wmaybe-uninitialized
Was not noticed since it is reported only with optimization enabled, as
stated in gcc(1):

   The effectiveness of some warnings depends on optimizations also
   being enabled. For example -Wsuggest-final-types is more effective with
   link-time optimization and -Wmaybe-uninitialized does not warn at all
   unless optimization is enabled.

And interesting thing is that it is reported only for -O2, not for -O3,
that's why I did not catched it in both cmake env that I had:
- debug (it has -O0)
- release (it has -O3)

While autoconf has -O2.
2020-08-29 01:15:20 +03:00
Azat Khuzhin
eeeed1e1bb test/dns: fix initialize_nameservers when there is ipv6 in /etc/resolv.conf
Fixes: #1060
2020-07-28 01:19:55 +03:00
Azat Khuzhin
53e53b018b test/regress_buffer.c: fix -Wbad-function-cast (in some specific env)
Fixes: #1054
2020-07-23 00:22:45 +03:00
Azat Khuzhin
1bfbbdf2b4 test: rename ssl/* -> openssl/* 2020-07-22 23:10:26 +03:00
okhowang(王沛文)
028385f685 fix build system and add test and cleanup code 2020-07-22 22:53:23 +03:00
Azat Khuzhin
90bcf2d660 test: fix leak in dns/getaddrinfo_cancel_stress
Some requests may get response (evutil_addrinfo) from gaic_server_cb,
in case of cancel_event (10000ms) will not be fast enough.
2020-07-05 12:16:52 +03:00
Azat Khuzhin
ba19b356bf test: fix UB in evbuffer/empty_reference_prepend_buffer
UBSAN reports:
  test/regress_buffer.c:2360:2: runtime error: null pointer passed as argument 1, which is declared to never be null
  /usr/include/string.h:140:33: note: nonnull attribute specified here
2020-07-05 11:46:22 +03:00
Azat Khuzhin
7b9ba3b717 test: really disable bufferevent_pair_release_lock under ASAN (and fix gcc) 2020-07-05 11:19:10 +03:00
Azat Khuzhin
e2f938c04f test-closed: fix leak 2020-07-05 11:08:05 +03:00
Azat Khuzhin
0ac3cfc0b7 test: add getaddrinfo(AI_ADDRCONFIG) test (off by default) 2020-06-26 11:32:59 +03:00
Azat Khuzhin
ec94a6bb3f test: fix memory leaks for https (add BEV_OPT_CLOSE_ON_FREE)
- http/https_filter_basic
- http/https_filter_chunk_out
2020-06-25 22:57:53 +03:00
Azat Khuzhin
cdbb2373f4 test: "fix" (with a quirk) leak in ssl/bufferevent_wm (w/o defer callbacks) 2020-06-25 22:57:40 +03:00
Azat Khuzhin
3b13a64789 test: disable bufferevent/bufferevent_pair_release_lock under ASAN (too tricky)
And cannot be suppressed with suppressions due to setup routines.
2020-06-25 22:57:40 +03:00
Azat Khuzhin
6754740f15 test: detect test failures if atexit handler calls _exit(!0) (sanitizers)
tinytest uses another way of detecting test failures, it uses pipe
between child and parent, and if the test function in child returns OK
it writes OK flag into pipe, and reads it in parent.

However sanitizers uses atexit handlers to detect leaks, and this will
not detect failures in case of exit() will be called from the atexit
handlers, fix this by checking status after waitpid().
2020-06-25 22:57:40 +03:00
Azat Khuzhin
a0c642ac04 buffer: do not pass NULL to memcpy() from evbuffer_pullup()
UBSAN reports:

  evbuffer/remove_buffer_with_empty3: ../buffer.c:1443:3: runtime error: null pointer passed as argument 2, which is declared to never be null
      #0 0x7ffff6cd0410 in evbuffer_pullup ../buffer.c:1443
      #1 0x5555556d68b9 in test_evbuffer_remove_buffer_with_empty3 ../test/regress_buffer.c:408
      #2 0x5555557b95ee in testcase_run_bare_ ../test/tinytest.c:173
      #3 0x5555557ba048 in testcase_run_one ../test/tinytest.c:333
      #4 0x5555557bc0f8 in tinytest_main ../test/tinytest.c:527
      #5 0x555555787702 in main ../test/regress_main.c:528
      #6 0x7ffff606c001 in __libc_start_main (/usr/lib/libc.so.6+0x27001)
      #7 0x55555569436d in _start (/src/le/libevent/.cmake-debug/bin/regress+0x14036d)
2020-06-25 10:15:01 +03:00
Azat Khuzhin
6f152befb4 test: do not pass NULL to memcmp() in evbuffer_datacmp() helper
Fixes:
  runtime error: null pointer passed as argument 2, which is declared to never be null
2020-06-25 09:59:35 +03:00
Azat Khuzhin
37dbb35080 http: fix undefined-shift in EVUTIL_IS*_ helpers
evutil.c:2559:1: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
    #0 0x4f2be0 in EVUTIL_ISXDIGIT_ libevent/evutil.c:2559:1
    #1 0x4bd689 in regname_ok libevent/http.c:4838:7
    #2 0x4bc16b in parse_authority libevent/http.c:4958:9
    #3 0x4bb8b5 in evhttp_uri_parse_with_flags libevent/http.c:5103:7
    #4 0x4bb762 in evhttp_uri_parse libevent/http.c:5050:9
    #5 0x4b8f41 in evhttp_parse_query_impl libevent/http.c:3505:9
    #6 0x4b8ed7 in evhttp_parse_query libevent/http.c:3569:9

Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23291
Report: https://oss-fuzz.com/testcase-detail/5670743106125824
2020-06-25 09:51:20 +03:00
Azat Khuzhin
2aaa7358a1 test/regress_http: remove second ARRAY_SIZE macros 2020-06-02 10:12:20 +03:00
Azat Khuzhin
8b5a4d61f6 test/regress_testutils: use inet_addr() 2020-06-02 10:01:31 +03:00
Azat Khuzhin
271c5aaa81 test/regress_dns: use tt_int_op() over tt_assert() in assert_request_results() 2020-06-02 10:00:38 +03:00
seleznevae
83c58d4985 evdns: Add support for setting maximum UDP DNS message size.
Added new option `edns-udp-size` for evdns_base which allows
to control maximum allowed size of UDP DNS messages. This
maximum size is passed to the DNS server via edns mechanism.
2020-05-31 19:59:49 +03:00