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

chroot: set exit codes to 125, 126 or 127 for errors from chroot itself

This commit is contained in:
Terts Diepraam 2022-09-07 19:01:14 +02:00
parent e40f175bb6
commit 51bd8a2ba8
3 changed files with 27 additions and 9 deletions

View file

@ -9,7 +9,9 @@ fn test_invalid_arg() {
#[test]
fn test_missing_operand() {
let result = new_ucmd!().run();
let result = new_ucmd!().fails();
result.code_is(125);
assert!(result
.stderr_str()
@ -27,7 +29,7 @@ fn test_enter_chroot_fails() {
at.mkdir("jail");
let result = ucmd.arg("jail").fails();
result.code_is(125);
assert!(result
.stderr_str()
.starts_with("chroot: cannot chroot to 'jail': Operation not permitted (os error 1)"));
@ -41,7 +43,8 @@ fn test_no_such_directory() {
ucmd.arg("a")
.fails()
.stderr_is("chroot: cannot change root directory to 'a': no such directory");
.stderr_is("chroot: cannot change root directory to 'a': no such directory")
.code_is(125);
}
#[test]
@ -51,7 +54,7 @@ fn test_invalid_user_spec() {
at.mkdir("a");
let result = ucmd.arg("a").arg("--userspec=ARABA:").fails();
result.code_is(125);
assert!(result.stderr_str().starts_with("chroot: invalid userspec"));
}
@ -91,7 +94,9 @@ fn test_preference_of_userspec() {
.arg("-G")
.arg("ABC,DEF")
.arg(format!("--userspec={}:{}", username, group_name))
.run();
.fails();
result.code_is(125);
println!("result.stdout = {}", result.stdout_str());
println!("result.stderr = {}", result.stderr_str());