1
0
mirror of https://github.com/libuv/libuv synced 2025-03-28 21:13:16 +00:00

66 Commits

Author SHA1 Message Date
Edigleysson Silva (Edy)
5bb19f35ea
test: run android tests on ci (#4517) 2024-09-17 21:30:24 +02:00
Pleuvens
d8669609d8
test: switch from ASSERT_* to ASSERT_PTR_* (#4163)
Also introduce a new ASSERT_PTR_LT macro.
2023-10-12 20:47:44 +02: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
b60f08e782 test: add ASSERT_OK (#3957)
The majority of uses for ASSERT_EQ are to check if the return value is
0. So make a macro specifically for this and make things easier to read.
2023-04-24 15:29:14 -06:00
Ben Noordhuis
cb5da59226
test: don't use static buffer for formatting (#3953)
Don't use a static buffer to hold human-readable "big" numbers.

The buffer isn't big enough for benchmarks like fs_stat that print a
large number of them. Have the caller pass in a buffer instead.
2023-04-14 16:54:28 +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
James McCoy
2638237e1f
build: add CI for OpenBSD and FreeBSD (#3548)
Fixes: https://github.com/libuv/libuv/issues/3510
2023-01-21 13:52:36 +01:00
Santiago Gimeno
96637d032f win,test: change format of TEST_PIPENAME's
So `WaitNamedPipe()` doesn't fail. Increase the number of clients in
`pipe_connect_multiple` so `CreateFile()` returns `ERROR_PIPE_BUSY` and
the codepath leading to `WaitNamedPipe()` is exercised.
2022-11-11 10:44:34 +01:00
daomingq
e900006642
thread: add support for affinity (#3774)
Backported thread affinity feature and related dependency commits
from master. It will add support for those APIs: uv_cpumask_size,
uv_thread_setaffinity, uv_thread_getaffinity.
The supported platforms are Linux, Freebsd, and Windows.
Empty implementations (returning UV_ENOTSUP) on non-supported platforms
(such as OS X and AIX).
2022-10-21 09:18:10 -04:00
Ben Noordhuis
495ffca2c2
win: remove stdint-msvc2008.h (#3673)
Support for VS 2008 was removed two years ago in commit a779fccfd so
this file can safely be deleted.
2022-07-15 10:39:14 +02:00
Jameson Nash
6564ccc900
asan: fix some tests (#3323)
Previously they were just being run incorrectly, but nothing wrong with
the test itself. We were also interpreting an ASAN failure as TEST_SKIP,
so test failures would not actually be reported as CI failures.
2021-10-10 00:57:43 +02:00
Ondřej Surý
285a5ea819
test: fix test-udp-send-unreachable
To properly handle sending UDP packet to unreachable address.

PR-URL: https://github.com/libuv/libuv/pull/2872
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-02-17 10:30:13 +01:00
Jameson Nash
dde98158b5 test: ensure reliable floating point comparison
Without `volatile`, the x87 hardware may re-organize the comparison math
and end up with the wrong answer.

Fixes: one bullet point item of
    https://github.com/libuv/libuv/issues/2655 and the tests from
    https://github.com/libuv/libuv/pull/849 in certain build configurations
PR-URL: https://github.com/libuv/libuv/pull/2747
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-11-28 10:48:40 -05:00
Ben Noordhuis
8d5af5e70e fs: fix utime/futime timestamp rounding errors
`uv_fs_utime()` and `uv_fs_futime()` receive the timestamp as
a `double` and then convert it to `struct timeval` or `struct timespec`
where necessary but the calculation for the sub-second part exhibited
rounding errors for dates in the deep past or the far-flung future,
causing the timestamps to be off by sometimes over half a second on
unix, or to be reinterpreted as unsigned and end up off by more than
just sign but many also decades.

Fixes: https://github.com/nodejs/node/issues/32369 (partially)
PR-URL: https://github.com/libuv/libuv/pull/2747
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-11-28 10:48:18 -05:00
tjarlama
904b1c9b47
test: avoid double evaluation in ASSERT_BASE macro
Passing expression as an argument to a function-like macro will replace
all occurrence of the arguments with expressions during preprocessing.
This result in multiple evaluation of the same expression and can
slow-down the program or even change program state. Here ASSERT_BASE
macro gets an expression involving a and b as first argument and macro
definition has a print statement with a and b, which means there is
double evaluation of a and b when the expression evaluates to false. To
avoid double evaluation temporary variables are created to store results
of a and b.

Since the expression argument is dropped from ASSERT_BASE, the macro no
longer works for string assertions. So a new macro, ASSERT_BASE_STR, is
introduced to deal with strings. ASSERT_BASE can still work with
pointers.

Fixes: https://github.com/libuv/libuv/issues/2916
PR-URL: https://github.com/libuv/libuv/pull/2926
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-12 13:13:02 -04:00
Ben Noordhuis
72fe3543fe unix,win: add uv_library_shutdown()
Make it possible to explicitly tell libuv to release any resources
it's still holding onto (memory, threads, file descriptors, etc.)

Before this commit, cleanup was performed in various destructors.
This commit centralizes the cleanup logic, enabling the addition of
`uv_library_shutdown()`, but maintains the current observable behavior
of cleaning up when libuv is unloaded by means of `dlclose(3)`.

Fixes: https://github.com/libuv/libuv/issues/2763
PR-URL: https://github.com/libuv/libuv/pull/2764
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-04-22 12:24:36 +02:00
Santiago Gimeno
53caf044e3
test: add a bunch of ASSERT macros
To make the debugging of test issues easier.

The following integer macros are added:

`ASSERT_EQ(a, b)`, `ASSERT_GE(a, b)`, `ASSERT_GT(a, b)`,
`ASSERT_LE(a, b)`, `ASSERT_LT(a, b)` and `ASSERT_NE(a, b)`.

And its corresponding unsigned integer macros:

`ASSERT_UINT64_EQ(a, b)`, `ASSERT_UINT64_GE(a, b)`,
`ASSERT_UINT64_GT(a, b)`, `ASSERT_UINT64_LE(a, b)`,
`ASSERT_UINT64_LT(a, b)` and `ASSERT_UINT64_NE(a, b)`.

Also these macros for `NULL` and pointer checks:

`ASSERT_NULL(a)`, `ASSERT_NOT_NULL(a)`, `ASSERT_PTR_EQ(a, b)` and
`ASSERT_PTR_NE(a, b)`.

And finally these macros for strings and buffers:

`ASSERT_STR_EQ(a, b)`/`ASSERT_STR_NEQ(a, b)` that use the `strcmp()`
call.
`ASSERT_MEM_EQ(a, b)`/`ASSERT_MEM_NEQ(a, b)` and
`ASSERT_MEM_HEX_EQ(a, b)`/`ASSERT_MEM_HEX_NEQ(a, b)` that use the
`memcmp()` call. The former, prints the data in string format and the
latter in hex format.

These macros are used in the following way:
```c
ASSERT_EQ(UV_EINVAL, uv_loop_close(&loop));
```

With a sample output that would be as follows:
```
Assertion failed in test/test-loop-close.c on line 44: `UV_EINVAL == uv_loop_close(&loop)` (-22 == -16)
```

To view multiples examples if their use, the `test-ipc.c` file has been
modified to use these macros.

The `_ISOC99_SOURCE` is defined to support `inttypes.h` in `z/OS`.

PR-URL: https://github.com/libuv/libuv/pull/2739
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-03-27 14:51:49 +01:00
Xu Meng
5b12c313e1 test: skip some test cases on IBMi
On IBMi, uv_uptime() and uv_fs_event_init() return UV_ENOSYS.
Set NO_FS_EVENTS on IBMi.

PR-URL: https://github.com/libuv/libuv/pull/2573
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-16 15:33:04 +01:00
cjihrig
8c73eee23f
unix,win: add uv_sleep()
This commit exposes the uv_sleep() function that previously
only existed in the test runner.

PR-URL: https://github.com/libuv/libuv/pull/2548
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-11-25 12:13:39 -05:00
Nhan Khong
faa800605e
test: fix gcc 8 warnings for tests
In test-ipc.c, remove unnecessarily casting uv_stream_s to
uv_pipe_s that makes gcc complain about stric-aliasing
(-Wstrict-aliasing).

In test-queue-foreach-delete.c, using C99 variadic macros
to fix a gcc 8 warnings (-Wcast-function-type).

PR-URL: https://github.com/libuv/libuv/pull/2344
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-08-06 12:01:15 -04:00
Andrew Paprocki
f62240b2d1
sunos: disable __attribute__((unused))
The Studio compiler prints out a warning when this attribute is used
because it does not support it (at least as of the latest 12.6 version):
https://docs.oracle.com/cd/E77782_01/html/E77788/gjzke.html#scrolltoc

PR-URL: https://github.com/libuv/libuv/pull/2200
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-16 13:20:40 -04:00
Ben Noordhuis
143da93e2d test,unix: fix race in test runner
The test runner inserted a 250 ms delay to give helper processes time to
settle. That's intrinsically race-y and caused tests to intermittently
fail on platforms like AIX.

Instead of a fixed delay, pass a file descriptor to the helper process
and wait until it closes the descriptor. That way we know for sure the
process has started.

Incidentally, this change reduces the running time of the test suite
from 112 to 26 seconds on my machine.

Fixes: https://github.com/libuv/libuv/issues/2041
PR-URL: https://github.com/libuv/libuv/pull/2056
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-30 20:44:16 +01:00
Ben Noordhuis
47dcc07cf7 win: move stdint-msvc2008.h to include/uv/
Move it so that include/ contains uv.h and nothing more.

PR-URL: https://github.com/libuv/libuv/pull/1850
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-06-14 18:40:09 +02:00
John Barboza
b01de7341f
zos: implement uv_fs_event* functions
This commit uses the Register File Interest feature on z/OS
to enable users to monitor file system events.
The poll call is used to check for file descriptors as well
as a message queue that z/OS will report file system events
on. The last item on the list used by poll will contain the
message queue id instead of a file descriptor.

Limitation:
Writes to a directory (that is, file creation and deletion)
do not generate a change message for a registered directory.

PR-URL: https://github.com/libuv/libuv/pull/1311
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-12-15 11:04:16 +01: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
580f032737 cygwin: disable non-functional ipc handle send
On Cygwin `recvmsg` always sets `msg_controllen` to zero on a
message received from a named pipe.  Therefore we cannot use
`sendmsg` to send handles for ipc.  Return failure early from
this code path as `ENOSYS`.

Skip tests requiring this feature since it is not available.

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:28 +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
Brad King
f4f1f57e7c test: factor out fsevents skip explanation
Factor out a dedicated test macro for use on platforms that
do not support fsevents instead of duplicating the os390
platform condition and explanation text.

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:08 +02:00
Ben Noordhuis
7e7e221260 test: remove unused RETURN_TODO macro
PR-URL: https://github.com/libuv/libuv/pull/898
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-06-10 10:08:15 +02:00
Nan Xiang
12548de1b5 test: assume no IPv6 if interfaces cannot be listed
PR-URL: https://github.com/libuv/libuv/pull/724
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-02-16 08:47:21 +01:00
Nan Xiang
b6650dff56 test: use uv_loop_close and assert its result
uv_loop_delete is considered deprecated.

PR-URL: https://github.com/libuv/libuv/pull/696
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-02-01 09:15:41 +01:00
Jeremy Whitlock
eb3f48ebaf win: do not read more from stream than available
On Windows the pipe implementation could read more from a stream than
was available and it would create an assertion failure.  This change
will make it so we read the minimum of the available data or the length
of the data.

To test this, I took the existing ipc_send_recv_tcp test and updated it
to do two writes and two read on each side of the pipe since that was the
reproduction recipe used by the reporter.  This approach reproduced the
issue on Windows and the committed fix resolved the issue.

Fixes: https://github.com/libuv/libuv/issues/505
PR-URL: https://github.com/libuv/libuv/pull/549
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-12-08 09:28:15 +01:00
Peter Jas
a59085e140 win: use the MSVC provided snprintf where possible
PR-URL: https://github.com/libuv/libuv/pull/532
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-09-29 09:01:33 +02:00
Peter Jas
514c0b3d06 windows: MSVC 2015 has C99 inline
Prior to MSVC 2015, the standard C99 `inline` keyword was missing,
added a compiler version check and disabled the inline replacement for
MSVC >= 2015 in test/task.h.

Refs: https://github.com/libuv/libuv/pull/341
PR-URL: https://github.com/libuv/libuv/pull/369
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-06-15 10:16:52 +02:00
Rui Abreu Ferreira
18b857b9bd windows: MSVC 2015 has snprintf()
Prior to MSVC 2015, there was no standard compliant snprintf(), added a
compiler version check and disabled the snprintf() replacement for MSVC >=
2015 in test/task.h.

PR-URL: https://github.com/libuv/libuv/pull/341
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-05-19 11:23:24 +02:00
Rui Abreu Ferreira
4a7c1268e0 windows: define snprintf replacement as inline instead of static
The MSVC compiler does not accept static methods defined in headers,
when linking against a shared library. The snprintf replacement
function used for windows, is now an inline function.

PR-URL: https://github.com/libuv/libuv/pull/329
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-04-30 10:09:50 +02:00
Saúl Ibarra Corretgé
cdc10a907a test: remove LOG and LOGF variadic macros
Initial patch by @simar7, thanks!

PR-URL: https://github.com/libuv/libuv/pull/313
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-04-12 18:44:34 +02:00
Ben Noordhuis
a09e77e180 test: skip ipv6 tests when ipv6 is not supported
To verify on Linux, run `sudo sysctl net.ipv6.conf.all.disable_ipv6=1`
before the test suite.

Fixes: https://github.com/libuv/libuv/issues/10
PR-URL: https://github.com/libuv/libuv/pull/92
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2014-12-29 17:14:48 +01:00
Saúl Ibarra Corretgé
96f164e52b test: silence some Clang warnings
They only show up on OSX for some reason, though.

PR-URL: https://github.com/libuv/libuv/pull/67
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2014-12-13 20:57:14 +01:00
Saúl Ibarra Corretgé
0e59136823 test: fix compiation warning
-Wunused-function would kick in because of the close_loop function,
but there tests and benchmarks which actually don't use any loop.
2014-03-03 21:49:34 +01:00
Saúl Ibarra Corretgé
e4f28adce4 test: make sure all handles in the loop are closed 2014-02-28 09:33:30 +01:00
Saúl Ibarra Corretgé
5ac214c712 unix, windows: add uv_pipe_getsockname 2014-02-23 20:25:20 +01:00
Fedor Indutny
86b5c1ef1c test: test fsevents error reporting
Create a lot of `FSEventStream`s to make `FSEventStreamStart()` fail.
Fetch the error code and verify that it is correct.
2013-11-13 18:18:56 +04:00
Sean Farrell
ee434b3069 test: remove replacement snprintf for mingw
Mingw has a proper definition of snprintf.
2013-10-25 13:01:31 +02:00
Ben Noordhuis
fd082901f1 test: add windows-only snprintf() function
Should fix the build after 96f32a2 inadvertently broke it.

There is no snprintf() on Windows because, hey, it's a C99 addition
and the people from Redmond, WA are still firmly stuck in 1989.
2013-08-05 14:14:02 +02:00
Ben Noordhuis
ddd7e04fd6 build: switch to autotools
Switch to the build tool everyone loves to hate.  The Makefile has
served us well over the years but it's been acquiring more and more
features that autotools gives us for free, like easy static+shared
library building, sane install targets, and so on.

This commit drops MinGW support.  If there is demand for it, we'll
re-add it.
2013-07-02 01:21:16 +02:00
Ben Noordhuis
ede83188f3 test: don't use S_IREAD and S_IWRITE
They're BSD-isms and obsolete ones at that. Replace with S_IRUSR and
S_IWUSR. Alias as _S_IREAD and _S_IWRITE on Windows because the '90s
never ended in Redmond, WA.
2013-05-31 12:50:19 +02:00
Miroslav Bajtoš
2c21050956 test: add RETURN_SKIP and RETURN_TODO macros
Added two new flags to identify tests that are intentionally ignored
(usually because we don't want to implement the tested functionality
on current platform) and test serving as TODO list (usually indicating
that the tested functionality should be implemented on current plaform
in the near future.)
2013-05-08 15:43:54 -07: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
saghul
61ecb3415d win: support compilation with Visual Studio 2008 2012-10-23 22:55:25 +02:00