mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
chroot: add more tests
This commit is contained in:
parent
adc4ecd856
commit
3654efe8e7
1 changed files with 26 additions and 7 deletions
|
@ -112,15 +112,34 @@ fn test_default_shell() {
|
||||||
at.mkdir(dir);
|
at.mkdir(dir);
|
||||||
|
|
||||||
let shell = std::env::var("SHELL").unwrap_or_else(|_| "/bin/sh".to_string());
|
let shell = std::env::var("SHELL").unwrap_or_else(|_| "/bin/sh".to_string());
|
||||||
let _expected = format!(
|
let expected = format!(
|
||||||
"chroot: failed to run command '{}': No such file or directory",
|
"chroot: failed to run command '{}': No such file or directory",
|
||||||
shell
|
shell
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: [2021-09; jhscheer] uncomment if/when #2692 gets merged
|
if let Ok(result) = run_ucmd_as_root(&ts, &[dir]) {
|
||||||
// if let Ok(result) = run_ucmd_as_root(&ts, &[dir]) {
|
result.stderr_contains(expected);
|
||||||
// result.stderr_contains(expected);
|
} else {
|
||||||
// } else {
|
print!("TEST SKIPPED");
|
||||||
// print!("TEST SKIPPED");
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_chroot() {
|
||||||
|
let ts = TestScenario::new(util_name!());
|
||||||
|
let at = &ts.fixtures;
|
||||||
|
|
||||||
|
let dir = "CHROOT_DIR";
|
||||||
|
at.mkdir(dir);
|
||||||
|
if let Ok(result) = run_ucmd_as_root(&ts, &[dir, "whoami"]) {
|
||||||
|
result.success().no_stderr().stdout_is("root");
|
||||||
|
} else {
|
||||||
|
print!("Test skipped; requires root user");
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Ok(result) = run_ucmd_as_root(&ts, &[dir, "pwd"]) {
|
||||||
|
result.success().no_stderr().stdout_is("/");
|
||||||
|
} else {
|
||||||
|
print!("Test skipped; requires root user");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue