Commit Graph

76 Commits

Author SHA1 Message Date
SteveLauC
c0d8ad4df4
refactor: move tests to the test dir (#2257)
* refactor: move tests to the test dir

* try fixing it

* try fixing it

* fix Redox and FreeBSD

* document it
2023-12-11 22:29:22 +00:00
SteveLauC
6961f0fabd
refactor: cfg for test/* (#2230)
* refactor: cfg for test/*

* one more netbsdlike

* more cfg
2023-12-09 16:15:41 +00:00
David CARLIER
2ab5558e08
fix, mostly, solaris build. (#2248)
With few exceptions as newer interfaces like preadv/pwritev unsupported
only on solaris.
2023-12-08 19:29:11 +00:00
David CARLIER
da451400ea
sys::sendfile adding solaris' sendfilev wrapper proposal. (#2207) 2023-12-04 06:28:48 +00:00
Alan Somers
2afff8194c
Add more cfg aliases (#2205)
* Add more cfg aliases

Add cfg aliases for linux_android, bsd, and freebsdlike.  Use them in
many places, though not everywhere they could theoretically be used.

Fixes #2188

* Use apple_targets in build.rs

Co-authored-by: SteveLauC <stevelauc@outlook.com>

* whitespace

Co-authored-by: SteveLauC <stevelauc@outlook.com>

* Define a "solarish" target alias.

* Describe cfg aliases in CONVENTIONS.md

* solarish in line 803

* solarish in line 845

* fix fmt

---------

Co-authored-by: SteveLauC <stevelauc@outlook.com>
2023-11-25 06:32:06 +00:00
Luís Cruz
49283c9031
Add apple tvos support (#2169) 2023-11-09 01:00:20 +00:00
Alan Somers
d59d2353e4
Eliminate the lazy_static dev dependency (#2107)
It's no longer needed, because for several versions now AtomicBool::new
and parking_lot::Mutex::new are const functions.

Fixes #1791
2023-08-27 21:34:26 +00:00
Steve Lau
f5dffcc7f0 refactor: take AsFd by value 2022-12-09 11:02:30 +08:00
Steve Lau
8f52bc97c9 feat: I/O safety for 'sys/termios' & 'pty' 2022-12-08 14:04:22 +08:00
Ryan Zoeller
3dc163e780 Add sched_getaffinity and sched_setaffinity on FreeBSD 2022-08-25 18:42:20 -05:00
Costin-Robert Sin
3e6cb639f0 Fix all formating problems to pass CI formating test
Signed-off-by: Costin-Robert Sin <sin.costinrobert@gmail.com>
2022-06-24 00:35:52 +03:00
Al Hoang
d02e27476c add haiku support
* enabled as much functionality and defines that match
  updated libc definitions for haiku
2022-05-14 18:45:18 -05:00
Ryan Zoeller
4d5c090fcf Add sendfile(2) for DragonFly 2022-01-03 04:05:09 -06:00
Brian L. Troutwine
77febe0e6b
Introduce timer_* support
This commit adds support for the signal timer mechanism in POSIX, the
mirror to timerfd on Linux.

Resolves #1424

Signed-off-by: Brian L. Troutwine <brian@troutwine.us>
2021-12-30 20:40:48 -08:00
Ryan Zoeller
1fbdd29d45 Enable sched_get/setaffinity on DragonFly BSD 2021-12-22 13:56:16 -06:00
Ryan Zoeller
09bddc3676 Avoid lock poisoning by using parking_lot
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-11-27 13:50:29 -06:00
LMJW
cd004aa861 Add getrlimit and setrlimit
This work is a continutation on previou contribution by @kpcyrd and @j1ah0ng.
2021-08-01 10:23:00 +10:00
Alan Somers
48c7a07c42 Add nmount for FreeBSD. 2021-06-13 20:13:32 -06:00
Amanda Tait
5846ae2afd
Add fuchsia support
Allow nix to compile on Fuchsia by conditionally avoiding libc
functionality that does not exist for Fuchsia.
2020-12-19 14:17:42 -05:00
Alan Somers
bf7a5fd606 Switch all builds from Travis to Cirrus
Travis has been super-slow lately (> 6 hours per build).  Cirrus is much
faster: about 20 minutes.  Cirrus also has slightly better test
coverage, mainly because it doesn't use SECCOMP.

Also,

* Fix the Redox CI build.  The old Travis configuration didn't actually
  build for Redox, so we never noticed that Redox can't be built with a
  stable compiler.  Thanks to @coolreader18 for finding this.

* Disable the udp_offload tests on cross-tested platforms.  These tests
  are failing with ENOPROTOOPT in Cirrus-CI.  I suspect it's due to a
  lack of support in QEMU.  These tests were skipped on Travis because
  its kernel was too old.

* Fix require_kernel_version on Cirrus-CI.  Cirrus reports the Linux
  kernel version as 4.19.112+, which the semver crate can't handle.

* Fix test_setfsuid on Cirrus.  When run on Cirrus, it seems like the
  file in /tmp gets deleted as soon as it's closed.  Probably an
  overzealous temporary file cleaner.  Use /var/tmp, because no
  temporary file cleaner should run in there.

* Skip mount tests on Cirrus.  They fail for an unknown reason.
Issue #1351

* Skip the AF_ALG tests on Cirrus-CI
Issue #1352
2020-12-06 22:35:30 -07:00
Ritesh Khadgaray
853603a54e update require_kernel_version to handle "_" in version string
test code breaks on fedora 33
```
$ cargo test
failures:

---- sys::test_socket::recvfrom::udp_offload::gro stdout ----
thread 'sys::test_socket::recvfrom::udp_offload::gro' panicked at 'called `Result::unwrap()` on an `Err` value: ParseError("Extra junk after valid version: _64")', test/sys/test_socket.rs:292:13
```

this is due underscore in release string( arch/x86_64), which is not supported by semver.
```
$ uname -r
5.8.14-300.fc33.x86_64
```

Replace the underscore with hypen to provide a consistent sematic.
2020-10-16 13:18:09 -07:00
Daniil Bondarev
91effece13 Added clock_gettime, clock_getres, clock_settime, clock_getcpuclockid 2020-09-28 00:11:27 -07:00
Alan Somers
d970e8e4b2 Factor out common code from the various skip macros 2020-07-03 10:47:29 -06:00
Alan Somers
1ae5dd8b16 Convert the crate to edition 2018 2020-05-31 19:07:15 -06:00
Xavier L'Heureux
106927af9e
Fix test and remove group & user for redox
- Make sure all tests pass the CI
 - Redox does not (yet) have passwd functions, so remove it
2020-05-17 21:06:22 -04:00
Xavier L'Heureux
5229c443fe
Add wait, fdatasync, poll and pause for Redox 2020-05-17 21:05:46 -04:00
Xavier L'Heureux
92e63f61cd
Remove warnings when compiling for Redox 2020-05-17 21:05:46 -04:00
Xavier L'Heureux
e94c139a47
Remove more unsupported functions and make it possible to run tests 2020-05-17 21:05:45 -04:00
Alan Somers
92c5cfe8d3 Fix an "unused macro" warning on non-Linux platforms 2020-05-02 10:25:34 -06:00
Gleb Pomykalov
b1b64ee4a7 Support UDP GSO and GRO on linux 2020-04-25 23:45:50 +03:00
Alan Somers
8aacca9fe3 Remove the last use of mem::uninitialized
Replace it with mem::zeroed.  It isn't perfect, but it's better than it
was.

Issue #1115
2019-12-01 07:53:29 -07:00
Thibaut Ackermann
18c20381b0 Implement sched::sched_getaffinity()
sched_getaffinity(2) get a process's CPU affinity mask
2019-11-21 08:36:53 +01:00
Alan Somers
7e2b4028fa Fix test breakage in Seccomp mode.
Travis is now using Seccomp, and Docker's default Seccomp policy
disables execveat (though, weirdly, not fexecve).  It also prohibits any
operations on AF_ALG sockets.

While I'm here, replace close/dup with dup2, which is more reliable.

Also, drop the fork mutex earlier.  This way all of the exeve tests will
run, even if one fails.

https://docs.docker.com/engine/security/seccomp/
2019-09-19 17:25:09 -06:00
Alan Somers
adcfaf5802 Require CAP_SYS_PTRACE for certain tests
process_vm_readv requires it, and I'm not exactly sure which other
things do too.
2019-09-19 17:25:08 -06:00
Alan Somers
2373ac817f Temporarily allow deprecated items
This fixes the tests on Rust 1.38.0.  We'll fix them for real after
release 0.15.0.

Issue #1096
2019-07-13 15:06:01 -06:00
Alan Somers
d26749e33a Fix some bugs with multithreaded tests:
* kmod tests must run exclusively, because they load and unload a module
  with a constant name.
* A few tests were doing some variant of chdir, but weren't taking the
  CWD_MTX.
* The kmod tests read files by path relative to CWD, so they need the
  CWD_MTX.  But they don't need it exclusively, so convert the CWD_MTX
  into an RwLock.
* Tests that do change the cwd need to change it back when they're done.
2019-06-06 08:54:51 -06:00
Alan Somers
129485cfa3 Fix multiple problems with the test_acct test
* On Linux, it requires the CAP_SYS_PACCT capability.
* Reenable the test on FreeBSD, because our FreeBSD CI environment is no
  longer jailed (since we switched from BuildBot to CirrusCI), but check
  at runtime whether the process is jailed.
* test_acct needs the FORK_MTX because it uses Command::new .
* Fix a race condition.  acct(2) isn't synchronous.  It starts a kernel
  thread but does not wait for it to become ready.  Fix it by running
  the test command within the polling loop.
2019-06-06 08:54:18 -06:00
Alan Somers
d39bdbdd9c Fix kmod tests on in Linux containers
It's not sufficient to check for root privileges, because a
containerized process may have root's euid but still lack important
capabilities.  Fix these tests by checking for the CAP_SYS_MOD
capability.
2019-06-06 08:51:54 -06:00
Alan Somers
913f8f4748 Fix the is_so_mark_functional test in Linux containers
It's not sufficient to check for root privileges.  In a container, the
euid may be root even though the user lacks some capabilities.  Replace
this test's root check with a check for the CAP_NET_ADMIN capability
instead.
2019-06-06 08:51:54 -06:00
Pascal Bach
a7fea44fe3 Add wrapper for linux kernel module loading
- init_module and finit_module to load kernel modules
- delete_module to unload kernel modules

Signed-off-by: Pascal Bach <pascal.bach@nextrem.ch>
2018-09-05 22:01:40 +02:00
Pascal Bach
81088abb3e Refactor skip_if_not_root into macro
This macro can be used in tests to skip the test if it requires root to sucssfully run.
2018-09-05 21:59:45 +02:00
Scott Lamb
f9ebcb7c00 new dir module
This is a lower-level interface than `std::fs::ReadDir`. Notable differences:

   * can be opened from a file descriptor (as returned by `openat`, perhaps
     before knowing if the path represents a file or directory). Uses
     `fdopendir` for this, available on all Unix platforms as of
     rust-lang/libc#1018.

   * implements `AsRawFd`, so it can be passed to `fstat`, `openat`, etc.

   * can be iterated through multiple times without closing and reopening the
     file descriptor. Each iteration rewinds when finished.

   * returns entries for `.` (current directory) and `..` (parent directory).

   * returns entries' names as a `CStr` (no allocation or conversion beyond
     whatever libc does).
2018-09-03 17:04:57 -07:00
Igor Gnatenko
ecad72a18e
deps: update tempfile to 3
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2018-09-01 11:39:36 +02:00
Andrew Morrow
325c43c6d5 Implement sendfile on FreeBSD and Darwin 2018-05-28 21:39:20 -06:00
bors[bot]
9e6e42297a Merge #820
820: Change AioCb to primarily use Bytes instead of Rc<[u8]> r=Susurrus a=asomers

`Rc<[u8]>` isn't a very good buffer type to use for aio.  For one thing, it lacks interior mutability.  For another, a single `Rc<[u8]>` can't be carved up into smaller buffers of the same type.  `Bytes` and `BytesMut` fix both problems.  This PR removes the ability to construct an `AioCb` from `Rc<[u8]>` and adds the ability to construct one from `Bytes`, `BytesMut`, or raw pointers (for consumers who need even more flexibility).  At this stage, the PR has the following warts:

1. A hack is necessary to force small `Bytes` buffers to allocate on the heap.  I plan to fix this with an enhancement to the bytes crate.
2. The `AioCb::buffer` method is necessary due to a deficiency in the tokio-core crate.  Once I fix that, then only `AioCb::into_buffer`will need to be public.
2018-01-21 16:46:23 +00:00
Alan Somers
631e3f30f6 aio: use Bytes instead of Rc<[u8]>
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-15 21:50:01 -07:00
Alan Somers
739957ffd8 Expose mqueue functions for all supported OSes 2018-01-10 21:04:00 -07:00
Bryant Mairs
68859b9c18 Add backticks to types in doccomments 2017-12-20 07:05:04 -08:00
Bryant Mairs
4013fa4848 Remove nix-test subcrate
This was doing testing for errno constants and a few other
types that is no longer necessary now that these types are
all tested within the libc project itself.
2017-12-05 07:48:38 -08:00
Jamie Hewland
a7ebd89b42 groups tests: Add groups mutex and print message when tests skipped
Fix groups mutex name
2017-11-12 10:56:58 +02:00