Commit Graph

9 Commits

Author SHA1 Message Date
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
Ben Noordhuis
84525b26fe
test: remove timing-sensitive check (#3899)
Remove expectations around uv_cond_timedwait() maximum sleep time.

The OpenBSD buildbot sleeps more than 5x longer than requested. It no
longer makes sense to expect some reasonable upper bound because at that
point we've moved well beyond reasonable.

Fixes: https://github.com/libuv/libuv/issues/3896
2023-02-07 11:15:59 -05:00
Jameson Nash
c5593b51dc warnings: fix code that emits compiler warnings
PR-URL: https://github.com/libuv/libuv/pull/2066
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-11-29 11:21:44 -05:00
Jamie Davis
bb1a49e9f2
test: increase upper bound in condvar_5
Problem:
Upper bound on thread wakeup was set to 1.5 * (requested timeout).
On MacOS wakeup delay factors of 1.75 have been reported.

Solution:
Increase the bound to 5 * (requested timeout).

Refs: https://github.com/libuv/libuv/issues/1910
PR-URL: https://github.com/libuv/libuv/pull/1990
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-09-19 09:27:24 -04:00
Jamie Davis
f401e67b60
test: make test-condvar call uv_cond_wait
Problem:
The condvar tests could pass without uv_cond_wait
(or uv_cond_timedwait) ever being invoked.

Solution:
Introduce semaphores to enforce ordering.
Now there will always be a thread waiting on the condition
when a signal() occurs.

Gotchas:
1. On Windows, waiting for a timeout may return earlier
than requested, depending on the granularity of timer ticks.
2. Timeout bounds are tuned based on our CI machines.

Bonuses:
1. I added additional test cases to complete the test matrix.

2. It seemed to me that several of the condvar tests were redundant,
because they used timing to probabilistically explore cases where there
would be "missed connections" (signal without a waiter).
Because it was not clear to me what the purpose of such tests were,
I have removed them.

Fixes: https://github.com/libuv/libuv/issues/1714
PR-URL: https://github.com/libuv/libuv/pull/1718
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-07-06 23:02:46 +02:00
Jamie Davis
693c217f80 test: check uv_cond_timedwait more carefully
Problem:
The "timeout" functionality of uv_cond_timedwait was not being tested.
The test (condvar_3) would use a worker that signaled the condition.

Solution:
Introduce a new condvar test case to ensure that the timeout also works.

PR-URL: https://github.com/libuv/libuv/pull/1713
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: John Barboza <jbarboza@ca.ibm.com>
2018-02-01 23:26:08 +01:00
Katsutoshi Horie
ca0b657891 test: fix deadlocks in uv_cond_wait
Calling uv_cond_wait without uv_cond_signal/uv_cond_broadcast may
cause deadlock. This commit avoids this situation as well as tests
these functions.

PR-URL: https://github.com/libuv/libuv/pull/728
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-03-03 09:29:39 +01:00
Ben Noordhuis
3ee4d3f183 unix, windows: return error codes directly
This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.

A code snippet like this one:

    if (uv_foo(loop) < 0) {
      uv_err_t err = uv_last_error(loop);
      fprintf(stderr, "%s\n", uv_strerror(err));
    }

Should be rewritten like this:

    int err = uv_foo(loop);
    if (err < 0)
      fprintf(stderr, "%s\n", uv_strerror(err));

The rationale for this change is that it should make creating bindings
for other languages a lot easier: dealing with struct return values is
painful with most FFIs and often downright buggy.
2013-07-07 09:51:00 +02:00
Hiroaki Nakamura
976c8a4387 Add support for condition variables on all platforms 2012-10-05 13:03:55 +02:00