mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07: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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user