Commit Graph

35 Commits

Author SHA1 Message Date
Andy Pan
44e61dab7e
kqueue: disallow ill-suited file descriptor kinds (#4513)
Follows up on https://github.com/libuv/libuv/pull/659.

Signed-off-by: Andy Pan <i@andypan.me>
2024-09-09 20:22:15 +02:00
Matheus Izvekov
8a499e1331
win: stop using deprecated names (#4253) 2023-12-22 12:30:48 +01:00
Pleuvens
011a1ac1a3
test: switch to new-style ASSERT_EQ macros (#4159)
Switch from old-style ASSERT macro to new-style ASSERT_EQ,... macros.

Using new-style macros makes it easier to debug test failures

Fixes: https://github.com/libuv/libuv/issues/2974
2023-10-06 19:50:15 +02:00
Trevor Norris
91a7e49846
test: silence more valgrind warnings (#3917)
Pass the loop to MAKE_VALGRIND_HAPPY() so it's explicit on which loop
needs to be cleaned up. Since it asserts on uv_loop_close(), need to
remove a couple of those that were being done before the call.

Cleanup where loop was assigned, so the entire test either uses loop or
uv_default_loop(). Not both.

Also take care of any reqs that may have been left uncleaned.
2023-03-12 14:59:00 +01:00
Ben Noordhuis
5102b2c093
unix: drop kfreebsd support (#3835)
Because kFreeBSD is dead. RIP.

Fixes: https://github.com/libuv/libuv/issues/3833
2022-11-28 22:45:28 +01:00
tjarlama
270d05189c
test: move to ASSERT_NULL and ASSERT_NOT_NULL test macros
Moving to new style test macros will make debugging easier in case
of test failure and improve redability. This commit will replace all
ASSERT macros matching the statement:
`ASSERT(identifier (== or !=) value);`
to:
`ASSERT_(NOT_)NULL(identifier);`

Refs: https://github.com/libuv/libuv/issues/2974
PR-URL: https://github.com/libuv/libuv/pull/3081
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-02-14 10:05:46 +01:00
Xu Meng
f52786b4ba
test: skip poll_duplex and poll_unidirectional on PASE
Issuing a shutdown() on IBM i PASE with parameter SHUT_WR
also sends a normal close sequence to the partner program.
This leads to timing issues and ECONNRESET failures in the
test poll_duplex and poll_unidirectional.

https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_74/apis/shutdn.htm

PR-URL: https://github.com/libuv/libuv/pull/2782
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-04-20 09:45:26 -04:00
Ben Noordhuis
af3330b723 test: handle EINTR, fix EOF check in poll test
The test had two bugs:

1. It didn't handle EINTR when calling send() and recv().

2. It checked `errno` on EOF but that's only set when the return value
   is less than zero.

PR-URL: https://github.com/libuv/libuv/pull/2713
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-02-29 09:37:56 +01:00
Andrew Paprocki
bdf9a96afa
test,sunos: disable UV_DISCONNECT handling
Solaris does not support the non-standard Linux `POLLRDHUP` event, so
disable the code awaiting the disconnects to exit the loop.  Without
this, the `poll_duplex` and `poll_unidirectional` tests will hang and
timeout.

PR-URL: https://github.com/libuv/libuv/pull/2200
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-16 13:20:31 -04:00
Santiago Gimeno
9051126b56
test,freebsd: fix flaky poll tests
On FreeBSD `close()` can fail with `ECONNRESET` if the socket was
shutdown by the peer before all pending data was delivered.

PR-URL: https://github.com/libuv/libuv/pull/1780
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-03-31 16:59:41 -04:00
Kamil Rytarowski
7824370ff8
netbsd: disable poll_bad_fdtype on NetBSD
Follow other BSDs and disable the failing poll_bad_fdtype test on
NetBSD.

PR-URL: https://github.com/libuv/libuv/pull/1574
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-10-02 09:23:22 -04:00
Brad King
621655352c test: skip self-connecting tests on cygwin
The cygwin runtime library fails to connect a socket client to a
listening server within the same thread.  Test cases that use
this approach hang while waiting for the connection to complete.
This can be reproduced independent of libuv in a simple example
using both socket/bind/listen and socket/connect in a single
thread.

Avoid this problem in our test suite by skipping such tests on cygwin.

PR-URL: https://github.com/libuv/libuv/pull/1312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-05-21 16:12:30 +02:00
Brad King
6398251aff cygwin: implement support for cygwin and msys2
Cygwin and MSYS2 are POSIX layers implemented on top of Windows.
Use our POSIX `poll(2)` implementation of our poll abstraction.
For most other components we already have dedicated sources
implementing them in terms of APIs available on Cygwin or
providing non-implementations of components not supported.

This leaves only three components that need Cygwin-specific
implementations:

* uv_uptime: implement using sysinfo
* uv_resident_set_memory: add a placeholder returning UV_ENOSYS
* uv_cpu_info: add a placeholder returning UV_ENOSYS

Update our test suite to account for features not available
due to Cygwin platform limitations or our placeholders.

PR-URL: https://github.com/libuv/libuv/pull/1312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-05-21 16:12:21 +02:00
Santiago Gimeno
c355c8b1a6
test: fix tests on OpenBSD
It fixes `process_title`, `poll_bad_fdtype` and `poll_nested_kqueue`
tests.

Fixes: https://github.com/libuv/libuv/issues/1216
PR-URL: https://github.com/libuv/libuv/pull/1218
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-02-07 17:47:17 +01:00
Jeffrey Clark
0a4b51fcb4 build: GNU/kFreeBSD support
autotools support only, gvp does not support kfreebsd detection.

PR-URL: https://github.com/libuv/libuv/pull/960
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-08-20 08:55:30 +02:00
John Barboza
1cff5b7557 zos: add support for new platform
- zos: disable test cases not applicable
- zos: build options
- zos: semaphore implementation
- zos: use compare and swap builtins
- zos: struct rusage not the same as other platforms
- zos: backlog<=0 produces undefined behaviour
    Will redefine backlog in the following way
    * if backlog == 0, set it to 1
    * if backlog < 0, set it to SOMAXCONN
- zos: define IMAXBEL as empty flag and implement uv__tty_make_raw
- zos: use udp multicast operations from aix
- zos: ESC in ebcdic
- zos: use LIBPATH for dynamic linker path
- zos: uv_udp_set_ttl only works for ipv6
- zos: increase pthread stack size by factor of 4
- zos: return ENODEV instead of ENXIO errors for setsockopt
- zos: use uv_cond_init the same way as aix
- test: enable oob test for zos
- zos: return EINVAL for zos error code EOPNOTSUPP

PR-URL: https://github.com/libuv/libuv/pull/937
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-08-19 01:34:29 +02:00
Ben Noordhuis
c5c419f7c8 unix: allow nesting of kqueue fds in uv_poll_start
kqueue file descriptors don't support ioctl(FIONBIO) (or any other ioctl
for that matter) so retry using fcntl(F_GETFL) + fcntl(F_SETFL) when we
receive a ENOTTY error.

Fixes: https://github.com/libuv/libuv/issues/883
PR-URL: https://github.com/libuv/libuv/pull/885
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-05-24 17:12:31 +02:00
Imran Iqbal
337e9fd0f5 test: fix POLLHDRUP related failures for AIX
`POLLHDRUP` is not implemented on AIX. Therefore `UV_DISCONNECT` will
never be set on `events`. This causes the socket to never be closed and
the tests to be stuck inside `pollset_poll` indefinitely, resulting in a
timeout.

This fixes the following tests:
- poll_duplex
- poll_unidirectional

Updated docs to let end users know that `UV_DISCONNECT` can be set, but
is unsupported on AIX.

Fixes: https://github.com/libuv/libuv/issues/844
PR-URL: https://github.com/libuv/libuv/pull/857
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-05-05 23:23:28 +02:00
Santiago Gimeno
c7c8e916b8 poll: add UV_DISCONNECT event
It allows detecting the remote socket closing the connection. It's
emitted when `EPOLLRDHUP`(Linux), `EV_EOF`(BSD), `POLLRDHUP`(Solaris,
AIX) and `AFD_POLL_DISCONNECT`(Windows) events are received.

PR-URL: https://github.com/libuv/libuv/pull/691
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-03-15 23:39:49 +01:00
Imran Iqbal
213e681acf test: fix poll_bad_fdtype for AIX
PR-URL: https://github.com/libuv/libuv/pull/757
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-03-10 09:50:33 -05:00
Ben Noordhuis
a0b56059cf unix: report errors for unpollable fds
Libuv would abort() when trying to watch a file descriptor that is
not compatible with epoll-style polling; file descriptors referring
to on-disk files fall into this category.

File descriptors that libuv creates itself are not an issue but
external ones that come in through the uv_poll_init() API are.

Make uv_poll_init() check whether the file descriptor is accepted by
the underlying system call and return an error when it's not.

Fixes: https://github.com/libuv/libuv/issues/658
PR-URL: https://github.com/libuv/libuv/pull/659
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-01-21 17:57:00 +01:00
Saúl Ibarra Corretgé
01544d861b Revert "stream: squelch ECONNRESET error if already closed"
This reverts commit 05a003a3f7.

This commit triggerd "test-tls-hello-parser-failure" failure in io.js.
See the reference below for a more thorough explanation.

Refs: https://github.com/nodejs/io.js/pull/2310
PR-URL: https://github.com/libuv/libuv/pull/475
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-07 14:19:08 +02:00
Santiago Gimeno
05a003a3f7 stream: squelch ECONNRESET error if already closed
Add new UV__POLLRDHUP event to be emitted when EPOLLRDHUP(in Linux) or
EV_EOF(in BSD / OSX) is detected and only if UV_READABLE is set.

When a read returns ECONNRESET after a UV__POLLRDHUP event, emit EOF instead
of the error.

Add tcp-squelch-connreset test. Not to be run on Windows as it returns
ECONNRESET error.

Fixes in test-poll and test-tcp-open so they pass after these changes.

PR-URL: https://github.com/libuv/libuv/pull/403
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-07-10 09:25:01 +02:00
Saúl Ibarra Corretgé
b30a3e677b unix, windows: set non-block mode in uv_poll_init
libuv requires that the socket/fd is in non-blocking mode, so do it
internally so the user doesn't need to write platform specific code to
do so.

This also makes the API consistent with uv_{tcp,udp,pipe}_open, since
it's not required to pass the fd in non-blocking mode there either.

PR-URL: https://github.com/libuv/libuv/pull/136
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-16 10:41:00 +01:00
Saúl Ibarra Corretgé
db2a9072bc unix, windows: removed unused status parameter
async, timer, prepare, idle and check handles don't need the status
parameter.
2014-03-17 21:42:36 +01:00
Ben Noordhuis
d7115f0677 unix, windows: make uv_is_*() always return 0 or 1
Ensure that the following API functions always return either 0 or 1:

  * uv_is_active()
  * uv_is_closing()
  * uv_is_readable()
  * uv_is_writable()
2013-09-12 13:30:06 +02:00
Ben Noordhuis
8184076879 include: uv_ip[46]_addr now takes sockaddr_in*
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.

Fixes #684.
2013-09-01 08:02:07 +02:00
Ben Noordhuis
4ba03ddd56 unix, windows: rename uv_run2 to uv_run
This changes the prototype of uv_run() from:

  int uv_run(uv_loop_t* loop);

To:

  int uv_run(uv_loop_t* loop, uv_run_mode mode);

Where `mode` is UV_RUN_DEFAULT, UV_RUN_ONCE or UV_RUN_NOWAIT.

Fixes #683.
2013-01-16 23:35:29 +01:00
Ben Noordhuis
7ff6f29b85 test, bench: ANSI-fy function prototypes
Replace `void f()` with `void f(void)`; the former means "a function
that takes any number of arguments, including none" while the latter
is what is actually intended: a function taking no arguments.

The first form also isn't strictly conforming ANSI/ISO C.
2013-01-06 22:31:48 +01:00
Ben Noordhuis
894a8523cb test: fix signed/unsigned comparison warnings 2012-11-02 14:32:14 +01:00
Bert Belder
47eb03490a test: move loop cleanup code to the individual tests 2012-10-17 01:24:49 +02:00
Bert Belder
4a07b8b7bd test-poll: make spurious wakeup detection slightly less strict 2012-06-02 21:12:10 +02:00
Bert Belder
9759c20e90 test: verify that closing an active poll handle doesn't hang 2012-06-01 18:39:47 +02:00
Bert Belder
b9504f7987 Rename uv_platform_socket_t to uv_os_sock_t 2012-05-03 16:05:05 +02:00
Bert Belder
beaf750700 Test: add tests for uv_poll 2012-05-03 15:52:57 +02:00