diff options
author | Homu <homu@barosl.com> | 2016-03-22 06:12:49 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-03-22 06:12:49 +0900 |
commit | 8e6532853605e830eb95926ed0a1d43730ab43a2 (patch) | |
tree | 5b1002f4ad0336b5c936fbea97baece5339a9b12 | |
parent | 5e3c954596f12512ba8728c437345a529ec48b0a (diff) | |
parent | d98e5ac2abef643f9a9a983440f4863a95b2a0cb (diff) | |
download | nix-8e6532853605e830eb95926ed0a1d43730ab43a2.zip |
Auto merge of #327 - kamalmarhubi:allow-test_mount_failure, r=fiveop
mount: Do not treat unshare(2) failure as test failure
The mount test runner uses unprivileged user namespaces. Previously,
failure from `unshare(2)` to create the user namespace would fail the
test. This changes that to simply print an error and exit successfully.
Refs https://github.com/nix-rust/nix/pull/326
-rw-r--r-- | test/test_mount.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/test/test_mount.rs b/test/test_mount.rs index f2c2454f..b5ceb8d2 100644 --- a/test/test_mount.rs +++ b/test/test_mount.rs @@ -10,10 +10,10 @@ extern crate tempdir; #[cfg(target_os = "linux")] mod test_mount { use std::fs::{self, File}; - use std::io::{Read, Write}; + use std::io::{self, Read, Write}; use std::os::unix::fs::OpenOptionsExt; use std::os::unix::fs::PermissionsExt; - use std::process::Command; + use std::process::{self, Command}; use libc::{self, EACCES, EROFS}; @@ -174,8 +174,15 @@ exit 23"; let uid = unsafe { libc::getuid() }; unshare(CLONE_NEWNS | CLONE_NEWUSER).unwrap_or_else(|e| { - panic!("unshare failed: {}. Are unprivileged user namespaces available?", - e) + let stderr = io::stderr(); + let mut handle = stderr.lock(); + writeln!(handle, + "unshare failed: {}. Are unprivileged user namespaces available?", + e); + writeln!(handle, "mount is not being tested"); + // Exit with success because not all systems support unprivileged user namespaces, and + // that's not what we're testing for. + process::exit(0); }); // Map user as uid 1000. |