11 Commits

Author SHA1 Message Date
Alex Saveau 58f99947bf Run a round of clippy to fix CI
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-11-06 11:40:46 -08: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
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
Alan Somers a09b1c8ac6 Clippy cleanup
And this time, start running Clippy in CI
2021-09-19 07:58:15 -06:00
Ryan Zoeller 7ab6731cf6 Print function name and missing capability when skipping tests 2021-08-22 21:27:33 -05:00
Alan Somers 6511d02414 Overhaul Nix's error types
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-07-07 20:49:28 -06: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
Alan Somers 1ae5dd8b16 Convert the crate to edition 2018 2020-05-31 19:07:15 -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 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
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