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

chmod: fix reference option

Reference option must have a file path.
Fix C interface using CString.
Better error message if the file doesn't exist.
This commit is contained in:
Luca Ottaviano 2016-03-10 20:34:49 +01:00
parent 8d278913c2
commit 5dc0a55630
2 changed files with 18 additions and 4 deletions

View file

@ -8,6 +8,8 @@ use common::util::*;
static UTIL_NAME: &'static str = "chmod";
static TEST_FILE: &'static str = "file";
static REFERENCE_FILE: &'static str = "reference";
static REFERENCE_PERMS: mode_t = 0o247;
struct TestCase {
args: Vec<&'static str>,
@ -27,6 +29,7 @@ fn run_tests(tests: Vec<TestCase>) {
let (at, mut ucmd) = testing(UTIL_NAME);
mkfile(&at.plus_as_string(TEST_FILE), test.before);
mkfile(&at.plus_as_string(REFERENCE_FILE), REFERENCE_PERMS);
let perms = at.metadata(TEST_FILE).permissions().mode();
if perms != test.before{
panic!(format!("{}: expected: {:o} got: {:o}", "setting permissions failed", test.after, perms));
@ -87,3 +90,11 @@ fn test_chmod_ugo_copy() {
};
run_tests(tests);
}
#[test]
fn test_chmod_reference_file() {
let tests = vec!{
TestCase{args: vec!{"--reference", REFERENCE_FILE, TEST_FILE}, before: 0o070, after: 0o247},
};
run_tests(tests);
}