mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 06:42:42 +00:00
tests: disable some chgrp tests when part of the root group
Some tests failed when run using Docker because they assumed the user would never be root. This is more of a band-aid solution. An actual fix would be to test see if something like these tests were to succeed when the user is root.
This commit is contained in:
parent
8ece01d0ef
commit
d8e738c49b
5 changed files with 298 additions and 249 deletions
456
Cargo.lock
generated
456
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -252,6 +252,7 @@ unindent = "0.1.0"
|
||||||
lazy_static = "0.2.2"
|
lazy_static = "0.2.2"
|
||||||
|
|
||||||
[target.'cfg(unix)'.dev-dependencies]
|
[target.'cfg(unix)'.dev-dependencies]
|
||||||
|
rust-users = { git = "https://github.com/Arcterus/rust-users" }
|
||||||
unix_socket = "0.5.0"
|
unix_socket = "0.5.0"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
|
@ -18,8 +18,11 @@ mod platform {
|
||||||
fn main() {
|
fn main() {
|
||||||
mkmain::main();
|
mkmain::main();
|
||||||
|
|
||||||
|
let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("Could not find manifest dir");
|
||||||
|
let profile = env::var("PROFILE").expect("Could not determine profile");
|
||||||
|
|
||||||
let out_dir = env::var("OUT_DIR").unwrap();
|
let out_dir = env::var("OUT_DIR").unwrap();
|
||||||
let libstdbuf = format!("{}/../../{}/{}/deps/liblibstdbuf{}", env::var("CARGO_MANIFEST_DIR").unwrap(), env::var("CARGO_TARGET_DIR").unwrap_or("target".to_string()), env::var("PROFILE").unwrap(), platform::DYLIB_EXT);
|
let libstdbuf = format!("{}/../../{}/{}/deps/liblibstdbuf{}", manifest_dir, env::var("CARGO_TARGET_DIR").unwrap_or("target".to_string()), profile, platform::DYLIB_EXT);
|
||||||
|
|
||||||
fs::copy(libstdbuf, Path::new(&out_dir).join("libstdbuf.so")).unwrap();
|
fs::copy(libstdbuf, Path::new(&out_dir).join("libstdbuf.so")).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
use rust_users::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_option() {
|
fn test_invalid_option() {
|
||||||
|
@ -14,23 +14,26 @@ static DIR: &'static str = "/tmp";
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_group() {
|
fn test_invalid_group() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("nosuchgroup")
|
.arg("__nosuchgroup__")
|
||||||
.arg("/")
|
.arg("/")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("chgrp: invalid group: nosuchgroup");
|
.stderr_is("chgrp: invalid group: __nosuchgroup__");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_1() {
|
fn test_1() {
|
||||||
|
if get_effective_gid() != 0 {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("bin")
|
.arg("bin")
|
||||||
.arg(DIR)
|
.arg(DIR)
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("chgrp: changing group of '/tmp': Operation not permitted (os error 1)");
|
.stderr_is("chgrp: changing group of '/tmp': Operation not permitted (os error 1)");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fail_silently() {
|
fn test_fail_silently() {
|
||||||
|
if get_effective_gid() != 0 {
|
||||||
for opt in &["-f", "--silent", "--quiet"] {
|
for opt in &["-f", "--silent", "--quiet"] {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg(opt)
|
.arg(opt)
|
||||||
|
@ -40,6 +43,7 @@ fn test_fail_silently() {
|
||||||
.fails_silently();
|
.fails_silently();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_preserve_root() {
|
fn test_preserve_root() {
|
||||||
|
@ -94,6 +98,7 @@ fn test_preserve_root_symlink() {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
fn test_reference() {
|
fn test_reference() {
|
||||||
|
if get_effective_gid() != 0 {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("-v")
|
.arg("-v")
|
||||||
.arg("--reference=/etc/passwd")
|
.arg("--reference=/etc/passwd")
|
||||||
|
@ -102,6 +107,7 @@ fn test_reference() {
|
||||||
.stderr_is("chgrp: changing group of '/etc': Operation not permitted (os error 1)\n")
|
.stderr_is("chgrp: changing group of '/etc': Operation not permitted (os error 1)\n")
|
||||||
.stdout_is("failed to change group of /etc from root to root\n");
|
.stdout_is("failed to change group of /etc from root to root\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
@ -116,6 +122,7 @@ fn test_reference() {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
fn test_big_p() {
|
fn test_big_p() {
|
||||||
|
if get_effective_gid() != 0 {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("-RP")
|
.arg("-RP")
|
||||||
.arg("bin")
|
.arg("bin")
|
||||||
|
@ -123,10 +130,12 @@ fn test_big_p() {
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("chgrp: changing group of '/proc/self/cwd': Operation not permitted (os error 1)\n");
|
.stderr_is("chgrp: changing group of '/proc/self/cwd': Operation not permitted (os error 1)\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
fn test_big_h() {
|
fn test_big_h() {
|
||||||
|
if get_effective_gid() != 0 {
|
||||||
assert!(new_ucmd!()
|
assert!(new_ucmd!()
|
||||||
.arg("-RH")
|
.arg("-RH")
|
||||||
.arg("bin")
|
.arg("bin")
|
||||||
|
@ -136,3 +145,4 @@ fn test_big_h() {
|
||||||
.lines()
|
.lines()
|
||||||
.fold(0, |acc, _| acc + 1) > 1);
|
.fold(0, |acc, _| acc + 1) > 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@ mod common;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
extern crate rust_users;
|
||||||
|
|
||||||
// For conditional compilation
|
// For conditional compilation
|
||||||
macro_rules! unix_only {
|
macro_rules! unix_only {
|
||||||
($($fea:expr, $m:ident);+) => {
|
($($fea:expr, $m:ident);+) => {
|
||||||
|
|
Loading…
Reference in a new issue