summaryrefslogtreecommitdiff
path: root/test/sys/test_aio.rs
AgeCommit message (Collapse)Author
2022-11-25Clippy cleanup with the latest nightly.Alan Somers
2022-08-12Folloup for !1778, remove some of the less helpful error msgsMichael Baikov
2022-08-04fix clippy assertions_on_result_statesMichael Baikov
https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states
2022-06-24Fix all formating problems to pass CI formating testCostin-Robert Sin
Signed-off-by: Costin-Robert Sin <sin.costinrobert@gmail.com>
2022-05-14Rewrite the aio moduleAlan Somers
The existing AIO implementation has some problems: 1) The in_progress field is checked at runtime, not compile time. 2) The mutable field is checked at runtime, not compile time. 3) A downstream lio_listio user must store extra state to track whether the whole operation is partially, completely, or not at all submitted. 4) Nix does heap allocation itself, rather than allowing the caller to choose it. This can result in double (or triple, or quadruple) boxing. 5) There's no easy way to use lio_listio to submit multiple operations with a single syscall, but poll each individually. 6) The lio_listio usage is far from transparent and zero-cost. 7) No aio_readv or aio_writev support. 8) priority has type c_int; should be i32 9) aio_return should return a usize instead of an isize, since it only uses negative values to indicate errors, which Rust represents via the Result type. This rewrite solves several problems: 1) Unsolved. I don't think it can be solved without something like C++'s guaranteed type elision. It might require changing the signature of Future::poll too. 2) Solved. 3) Solved, by the new in_progress method and by removing the complicated lio_listio resubmit code. 4) Solved. 5) Solved. 6) Solved, by removing the lio_listo resubmit code. It can be reimplemented downstream if necessary. Or even in Nix, but it doesn't fit Nix's theme of zero-cost abstractions. 7) Solved. 8) Solved. 9) Solved. The rewrite includes functions that don't work on FreeBSD, so add CI testing for FreeBSD 14 too. By default only enable tests that will pass on FreeBSD 12.3. But run a CI job on FreeBSD 14 and set a flag that will enable such tests.
2021-11-27Avoid lock poisoning by using parking_lotRyan Zoeller
parking_lot provides synchronization primitives which aren't poisoned on panic. This makes it easier to determine which tests are failing, as a test failure no longer causes all subsequent tests using that mutex to fail.
2021-09-19Clippy cleanupAlan Somers
And this time, start running Clippy in CI
2021-07-07Collapse Error into ErrnoAlan Somers
Now that Nix's weird error types are eliminated, there's no reason not to simply use Errno as the Error type.
2021-07-07Overhaul Nix's error typesAlan Somers
For many of Nix's consumers it be convenient to easily convert a Nix error into a std::io::Error. That's currently not possible because of the InvalidPath, InvalidUtf8, and UnsupportedOperation types that have no equivalent in std::io::Error. However, very few of Nix's public APIs actually return those unusual errors. So a more useful API would be for Nix's standard error type to implement Into<std::io::Error>. This commit makes Error a simple NewType around Errno. For most functions it's a drop-in replacement. There are only three exceptions: * clearenv now returns a bespoke error type. It was the only Nix function whose error couldn't be cleanly mapped onto an Errno. * sys::signal::signal now returns Error(Errno::ENOTSUP) instead of Error::UnsupportedOperation when the user passes an incompatible argument to `handler`. * When a NixPath exceeds PATH_MAX, it will now return Error(Errno::ENAMETOOLONG) instead of Error::InvalidPath. In the latter two cases there is now some abiguity about whether the error code was generated by Nix or by the OS. But I think the ambiguity is worth it for the sake of being able to implement Into<io::Error>. This commit also introduces Error::Sys() as a migration aid. Previously that as an enum variant. Now it's a function, but it will work in many of the same contexts as the original. Fixes #1155
2021-06-12Reenable tests that only failed on Travis, since we no longer use it.Alan Somers
2021-05-30Adapt aio to the world of async/await, and fix some potential unsoundness.Alan Somers
* libc::aiocb must not be moved while the kernel has a pointer to it. This change enforces that requirement by using std::pin. * Split LioCbBuilder out of LioCb. struct LioCb relied on the (incorrect) assumption that a Vec's elements have a stable location in memory. That's not true; they can be moved during Vec::push. The solution is to use a Vec in the new Builder struct, but finalize it to a boxed slice (which doesn't support push) before allowing it to be submitted to the kernel. * Eliminate owned buffer types. mio-aio no longer uses owned buffers with nix::aio. There's little need for it in the world of async/await. I'm not aware of any other consumers. This substantially simplifies the code.
2020-12-14Ignore failures of test_aio_suspend on macosAlan Somers
On Cirrus-CI, this test frequently fails with EINVAL. The error goes away if I add a line of debugging, so it's probably a timing issue. But I can't debug it myself. Issue #1361
2020-12-08Fix unreliability in sys::test_aio::test_aio_suspendAlan Somers
On OSX, this test has begun to fail in CI on OSX. Presumably it's because aio_suspend was getting interrupted by a signal.
2020-05-31Convert the crate to edition 2018Alan Somers
2019-12-22Skip test_aio_cancel_all on muslAlan Somers
I suspect that the segfault is due to a stack overflow on musl's signal stack, but I can't reproduce the failure locally. Fixes #1169
2019-09-19Where relevant, replace equality checks in assert! with assert_eq!Xavier L'Heureux
`assert_eq!` gives more debug info when the test fails by default than `assert!`. This should help make debugging easier.
2019-09-03Skip the aio_suspend test on LinuxAlan Somers
On Travis (and only on Travis) this test crashes. It hits an internal assertion within glibc. It happens reliably with rustc 1.37.0. Ignore the test until Travis updates its images; then we'll try again. Issue #1099
2018-09-05Replace allow unused directive with _ prefixPascal Bach
2018-04-06Add LioCb::listio_resubmitAlan Somers
It helps deal with errors like EAGAIN, which can result in a subset of an LioCb's operations being queued. The test is only enabled on FreeBSD, because it requires intimate knowledge of AIO system limits.
2018-03-22Replace AioCb::from_bytes with more generic from_boxed_sliceAlan Somers
Supporting the bytes crate was unnecessarily specific. This change replaces from_bytes and from_bytes_mut with from_boxed_slice and from_boxed_mut_slice, which can work with anything that implements Borrow<[u8]> and BorrowMut<[u8]>, respectively.
2018-03-22Change sys::aio::lio_listio to sys::aio::LioCb::listioAlan Somers
The new LioCb structure allows us to control the exact arguments passed to lio_listio, guaranteeing that each call gets a unique storage location for the list argument. This prevents clients from misusing lio_listio in a way that causes events to get dropped from a kqueue Fixes #870
2018-01-15aio: more documentationAlan Somers
2018-01-15aio: Clippy cleanupAlan Somers
2018-01-15aio: use `Bytes` instead of `Rc<[u8]>`Alan Somers
It's not actually safe to read into an `Rc<[u8]>`. It only worked because of a coincidental `unsafe` block. Replace that type with `BytesMut` from the bytes crate. For consistency's sake, use `Bytes` for writing too, and completely remove methods relating to `Rc<[u8]>`. Note that the `AioCb` will actually own the `BytesMut` object. The caller must call `into_buffer` to get it back once the I/O is complete. Fixes #788
2018-01-15Add AioCb::from_ptr and AioCb::from_mut_ptrAlan Somers
2017-12-20Use '!' instead of '== false'Bryant Mairs
Reads a little bit easier
2017-12-20Use Rc::clone() instead of .clone()Bryant Mairs
Makes it more clear what's being cloned
2017-12-20Remove unnecessary referencesBryant Mairs
2017-12-20Remove 'static from variablesBryant Mairs
It's unclear why these were static in the first place.
2017-12-20Remove elided 'static lifetimeBryant Mairs
As of Rust 1.17 'static lifetimes are implied when declaring consts.
2017-12-20Use write_all instead of writeBryant Mairs
Several tests make the assumption that all data is written, which is not guaranteed with write(), so use write_all() instead.
2017-12-02Upgrade to Bitflags 1.0Bryant Mairs
The libc_bitflags! macro was replaced with a non-recursive one supporting only public structs. I could not figure out how to make the old macro work with the upgrade, so I reworked part of the bitflags! macro directly to suit our needs, much as the original recursive macro was made. There are no uses of this macro for non-public structs, so this is not a problem for internal code.
2017-10-07Merge #773bors[bot]
773: Add more accessors for AioCb r=asomers a=asomers
2017-10-05Fix variable does not need to be mutable warning for aio testSanchayan Maity
This fixes the following warning during run of cargo test warning: variable does not need to be mutable --> test/sys/test_aio.rs:16:13 | 16 | fn poll_aio(mut aiocb: &mut AioCb) -> Result<()> { | ^^^^^^^^^ | = note: #[warn(unused_mut)] on by default
2017-10-02Add more accessors for AioCbAlan Somers
2017-09-03Fixed error handling in `AioCb::{fsync,read,write}`Alan Somers
Previously, the `AioCb`'s `in_progress` field would erroneously be set to `true`, even if the syscall had an error Fixes #714
2017-09-03AioCb::Drop will now panic for in-progress AioCbAlan Somers
Printing a warning message to stderr isn't really appropriate, because there's no way to guarantee that stderr is even valid. Nor is aio_suspend necessarily an appropriate action to take.
2017-07-24Disable failing tests on mips64Bryant Mairs
These are assumed to be QEMU issues, as they also fail on mips.
2017-07-18Remove signalfd feature in favor of conditional compilationBryant Mairs
Note that this is now only available for Linux as support is missing in libc for Android (see rust-lang/libc#671). As part of this work the SIGUSR2 signal mutex was altered to be a general signal mutex. This is because all signal handling is shared across all threads in the Rust test harness, so if you alter one signal, depending on whether it's additive or may overwrite the mask for other signals, it could break the other ones. Instead of putting this on the user, just broaden the scope of the mutex so that any altering of signal handling needs to use it.
2017-07-16Fix thread safety issues in aio, chdir, and wait testsAlan Somers
They have four problems: * The chdir tests change the process's cwd, which is global. Protect them all with a mutex. * The wait tests will reap any subprocess, and several tests create subprocesses. Protect them all with a mutex so only one subprocess-creating test will run at a time. * When a multithreaded test forks, the child process can sometimes block in the stack unwinding code. It blocks on a mutex that was held by a different thread in the parent, but that thread doesn't exist in the child, so a deadlock results. Fix this by immediately calling std::process:exit in the child processes. * My previous attempt at thread safety in the aio tests didn't work, because anonymous MutexGuards drop immediately. Fix this by naming the SIGUSR2_MTX MutexGuards. Fixes #251
2017-06-06Fix x86_64 Linux/musl testsBryant Mairs
Seems that pretty much all aio tests fail on x64 musl builds.
2017-06-06Fix i686 Linux/musl buildsBryant Mairs
2017-06-06Skip failing MIPS testsBryant Mairs
2017-04-15Add AioCb::from_boxed_sliceAlan Somers
The existing AioCb constructors work for simple programs where everything is stored on the stack. But in more complicated programs the borrow checker can't prove that a buffer will outlive the AioCb that references it. Fix this problem by introducting AioCb::from_boxed_slice, which takes a reference-counted buffer. Fixes #575
2017-04-15tests should protect concurrent access to signal handlersAlan Somers
Adds a mutex to protect access to SIGUSR2 signal handlers by the AIO tests. Fixes #578
2017-02-24impl Debug for AioCb and SigevNotifyAlan Somers
Also, fix style bug in AIO tests
2017-02-05Implement Drop for AioCbAlan Somers
If an AioCb has any in-kernel state, AioCb.drop will print a warning and wait for it to complete.
2017-02-05Add runtime checks to AioCb methodsAlan Somers
Prevent immutable buffers from being used with aio_read or lio_listio with LIO_READ. AioCb.from_slice no longer needs to be unsafe.
2017-01-26Turn most aio functions into AioCb methodsAlan Somers
2017-01-25Add PhantomData to AioCb to track buffer's lifetimeAlan Somers