1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

chroot: implement --skip-chdir

This commit is contained in:
Sylvestre Ledru 2022-09-20 22:29:30 +02:00
parent 3654efe8e7
commit 2e26e1d2bd
3 changed files with 50 additions and 7 deletions

View file

@ -1,4 +1,4 @@
// spell-checker:ignore (words) araba newroot userspec
// spell-checker:ignore (words) araba newroot userspec chdir
use crate::common::util::*;
@ -143,3 +143,22 @@ fn test_chroot() {
print!("Test skipped; requires root user");
}
}
#[test]
fn test_chroot_skip_chdir() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
let dir = "CHROOT_DIR";
at.mkdir(dir);
let env_cd = std::env::current_dir().unwrap();
if let Ok(result) = run_ucmd_as_root(&ts, &[dir, "--skip-chdir", "pwd"]) {
// Should return the same path
assert_eq!(
result.success().no_stderr().stdout_str(),
env_cd.to_str().unwrap()
);
} else {
print!("Test skipped; requires root user");
}
}