Commit graph

35 commits

Author SHA1 Message Date
Jonathan Brouwer
dab350a3ed
Remove timing assertion from oneshot::send_before_recv_timeout 2026-02-15 12:32:17 +01:00
Zalathar
6970849fee Disable flaky test oneshot::recv_timeout_before_send 2026-02-05 12:38:23 +11:00
Connor Tsui
b481ecd8b5
add oneshot tests
Tests inspired by tests in the `oneshot` third-party crate.
2026-01-05 09:47:20 +11:00
usamoi
141342c34f stabilize lazy_get 2025-12-15 18:57:33 +08:00
Connor Tsui
c1153b08ff
move condvar test from mutex to condvar test file
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-10-31 15:53:39 -04:00
Connor Tsui
3d5a40809c
update nonpoison::Condvar to take guards by reference
Since non-poisoning `Condvar` take non-poisoing `Mutex`es when
`wait`ing, we do not need to take by ownership since a poison error
cannot occur while we wait.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-10-31 15:53:33 -04:00
Connor Tsui
7069400c47
revert combined nonpoison/poison tests for condvar
Setup for writing different tests for the `nonpoison::Condvar` since it
will have a different API.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-10-31 15:31:53 -04:00
bors
c7a635f33c Auto merge of #147910 - joboet:wait_timeout-spurious-test, r=ChrisDenton
handle spurious returns of `wait_timeout` in test

Fixes https://github.com/rust-lang/rust/issues/147885
Closes https://github.com/rust-lang/rust/pull/147871

`wait_timeout` is allowed to spuriously return, hence the `timeout_nanoseconds` must not assume that the wakeup resulted from a `notify_all()`.
2025-10-20 22:04:39 +00:00
joboet
76dfdd4e70
handle spurious returns of wait_timeout in test 2025-10-20 17:53:49 +02:00
Matthias Krüger
8d6356b8d8
Rollup merge of #143191 - connortsui20:stabilize-rwlock-downgrade, r=tgross35
Stabilize `rwlock_downgrade` library feature

Tracking Issue: https://github.com/rust-lang/rust/issues/128203

Method to be stabilized:

```rust
impl<'a, T: ?Sized> RwLockWriteGuard<'a, T> {
    pub fn downgrade(s: Self) -> RwLockReadGuard<'a, T> {}
}
```

~~I would like to point out that my documentation comment is longer than ideal, but at the same time I don't really know how else to show why `downgrade` is actually necessary (instead of just unlocking and relocking). If anyone has ideas for making this more concise that would be great!~~ I have made the documentation a bit more clear.

Stabilization report: https://github.com/rust-lang/rust/issues/128203#issuecomment-3016682463
2025-10-15 23:41:00 +02:00
joboet
8a145efc70
std: improve handling of timed condition variable waits on macOS 2025-10-14 11:57:50 +02:00
EFanZh
ba42380142 Implement non-poisoning Mutex::with_mut, RwLock::with and RwLock::with_mut
ACP: https://github.com/rust-lang/libs-team/issues/497.
2025-10-04 17:16:00 +08:00
Connor Tsui
6354c51d2b
update doc comment
Co-authored-by: Ralf Jung <post@ralfj.de>
2025-09-11 13:08:44 -04:00
Connor Tsui
18d0dcbc8e
fix config for poison macro test
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-09-11 12:35:26 -04:00
Georg Semmler
30fd32eca5
Make the compile test use a const instead 2025-09-09 17:14:38 +02:00
Georg Semmler
20d02258fc
Make Barrier RefUnwindSafe again
This commit manually implements `RefUnwindSafe` for
`std::sync::Barrier` to fix 146087. This is a fix for a regression
indroduced by e95db591a4
2025-09-09 17:13:38 +02:00
Stuart Cook
eda6dc9283
Rollup merge of #144651 - connortsui20:nonpoison_condvar, r=joboet
Implementation: `#[feature(nonpoison_condvar)]`

Tracking Issue: https://github.com/rust-lang/rust/issues/134645

This PR continues the effort made in https://github.com/rust-lang/rust/pull/144022 by adding the implementation of `nonpoison::condvar`.

Many of the changes here are similar to the changes made to implement `nonpoison::mutex`.

There are two other changes here. The first is that the `Barrier` implementation is migrated to use the `nonpoison::Condvar` instead of the `poison` variant. The second (which might be subject to some discussion) is that `WaitTimeoutResult` is moved up to `mod.rs`, as both `condvar` variants need that type (and I do not know if there is a better place to put it now).

### Related PRs

- `nonpoison_rwlock` implementation: https://github.com/rust-lang/rust/pull/144648
- `nonpoison_once` implementation: https://github.com/rust-lang/rust/pull/144653
2025-08-30 20:29:06 +10:00
Jacob Pratt
d5340c26fa
Rollup merge of #145307 - connortsui20:lazylock-poison-msg, r=Amanieu
Fix `LazyLock` poison panic message

Fixes the issue raised in https://github.com/rust-lang/rust/pull/144872#issuecomment-3151100248

r? ```@Amanieu```
2025-08-23 23:58:35 -04:00
Connor Tsui
b2380d2bcc
add nonpoison and poison condvar tests
Adds tests for the `nonpoison::Mutex` variant by using a macro to
duplicate the existing `poison` tests.

Note that all of the tests here are adapted from the existing `poison`
tests.

Also steals the `test_mutex_arc_condvar` test from `mutex.rs`.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-08-23 09:20:44 -04:00
Connor Tsui
780319a75b
stabilize unstable rwlock_downgrade feature
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-08-23 09:01:38 -04:00
Connor Tsui
06eb782c4e
modify LazyLock poison panic message
Fixes an issue where if the underlying `Once` panics because it is
poisoned, the panic displays the wrong message.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-08-22 14:59:34 -04:00
Connor Tsui
ad499d076a
add nonpoison and poison rwlock tests
Adds tests for the `nonpoison::RwLock` variant by using a macro to
duplicate the existing `poison` tests.

Note that all of the tests here are adapted from the existing `poison`
tests.
2025-08-09 08:41:27 +02:00
Connor Tsui
d8a0df075d
reorganize rwlock tests
This commit simply helps discern the actual changes needed to test both
poison and nonpoison `rwlock`s.
2025-08-09 08:41:27 +02:00
Connor Tsui
d073d297b6
add extra drop, panic, and unwind tests 2025-07-29 10:44:36 +02:00
Connor Tsui
3eb722e655
add nonpoison and poison mutex tests
Adds tests for the `nonpoison::Mutex` variant by using a macro to
duplicate the existing `poison` tests.

Note that all of the tests here are adapted from the existing `poison`
tests.
2025-07-29 10:36:26 +02:00
Connor Tsui
f34fb05923
reorder mutex tests
This commit simply helps discern the actual changes needed to test both
poison and nonpoison locks.
2025-07-29 10:33:05 +02:00
Jubilee Young
66e056a3a7 library: Increase timeout on mpmc test to reduce flakes
This recently spuriously failed in a rollup, so I think we can afford to
increase the base timeout and the amount of time slept for to provide
a much wider margin for the timeout to be reached.
2025-06-17 16:10:37 -07:00
Josh Triplett
889f7cbffa Avoid a gratuitous 10s wait in a stress test
`stress_recv_timeout_two_threads`, in the mpmc and mpsc testsuites,
is a stress test of the `recv_timeout` function. This test processes and
ignores timeouts, and just ensures that every sent value gets received.
As such, the exact length of the timeouts is not critical, only that
the timeout and sleep durations ensure that at least one timeout
occurred.

The current tests have 100 iterations, half of which sleep for 200ms,
causing the test to take 10s. This represents around 2/3rds of the
*total* runtime of the `library/std` testsuite.

Reduce this to 50 iterations where half of them sleep for 10ms, causing
the test to take 0.25s.

Add a check that at least one timeout occurred.
2025-06-08 20:22:07 -07:00
Zachary S
d2068be4a0 Rename (Mapped)(RwLock|Mutex)Guard::try_map to filter_map.
1. analogous to std::cell::Ref(Mut)::filter_map.
2. doesn't imply `Try` genericizability.
2025-04-30 19:43:24 -05:00
Glyn Normington
1376810d44 Basic tests of MPMC receiver cloning
Ref: https://github.com/rust-lang/rust/issues/126840#issuecomment-2802321146
2025-04-15 02:37:57 +01:00
Paul Menage
9e5c942286 Mark some std tests as requiring panic = "unwind"
This allows these test modules to pass on builds/targets without
unwinding support, where `panic = "abort"` - the ignored tests are for
functionality that's not supported on those targets.
2025-03-10 08:31:06 -07:00
Eric Huss
b7c975b22e library: Update rand to 0.9.0 2025-02-13 12:20:55 -08:00
bjorn3
cc7e3a6228 Remove stabilized feature gate 2025-02-02 18:28:08 +00:00
bjorn3
52907d713a Fix for SGX 2025-01-26 10:28:05 +00:00
bjorn3
b8ae372e48 Move std::sync unit tests to integration tests
This removes two minor OnceLock tests which test private methods. The
rest of the tests should be more than enough to catch mistakes in those
private methods. Also makes ReentrantLock::try_lock public. And finally
it makes the mpmc tests actually run.
2025-01-26 10:28:05 +00:00