summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test.rs3
-rw-r--r--test/test_unistd.rs14
2 files changed, 17 insertions, 0 deletions
diff --git a/test/test.rs b/test/test.rs
index 1b73c4ff..f4942d3d 100644
--- a/test/test.rs
+++ b/test/test.rs
@@ -43,6 +43,9 @@ lazy_static! {
/// Any test that changes the process's current working directory must grab
/// this mutex
pub static ref CWD_MTX: Mutex<()> = Mutex::new(());
+ /// Any test that changes the process's supplementary groups must grab this
+ /// mutex
+ pub static ref GROUPS_MTX: Mutex<()> = Mutex::new(());
/// Any test that creates child processes must grab this mutex, regardless
/// of what it does with those children.
pub static ref FORK_MTX: Mutex<()> = Mutex::new(());
diff --git a/test/test_unistd.rs b/test/test_unistd.rs
index 73e8b8ab..2bb432d0 100644
--- a/test/test_unistd.rs
+++ b/test/test_unistd.rs
@@ -128,9 +128,16 @@ mod linux_android {
fn test_setgroups() {
// Skip this test when not run as root as `setgroups()` requires root.
if !Uid::current().is_root() {
+ use std::io;
+ let stderr = io::stderr();
+ let mut handle = stderr.lock();
+ writeln!(handle, "test_setgroups requires root privileges. Skipping test.").unwrap();
return
}
+ #[allow(unused_variables)]
+ let m = ::GROUPS_MTX.lock().expect("Mutex got poisoned by another test");
+
// Save the existing groups
let old_groups = getgroups().unwrap();
@@ -152,9 +159,16 @@ fn test_initgroups() {
// Skip this test when not run as root as `initgroups()` and `setgroups()`
// require root.
if !Uid::current().is_root() {
+ use std::io;
+ let stderr = io::stderr();
+ let mut handle = stderr.lock();
+ writeln!(handle, "test_initgroups requires root privileges. Skipping test.").unwrap();
return
}
+ #[allow(unused_variables)]
+ let m = ::GROUPS_MTX.lock().expect("Mutex got poisoned by another test");
+
// Save the existing groups
let old_groups = getgroups().unwrap();