2015-11-16 05:25:01 +00:00
|
|
|
use common::util::*;
|
|
|
|
|
|
|
|
static UTIL_NAME: &'static str = "mkdir";
|
2016-07-29 21:26:32 +00:00
|
|
|
fn new_ucmd() -> UCommand {
|
|
|
|
TestScenario::new(UTIL_NAME).ucmd()
|
|
|
|
}
|
2015-11-16 05:25:01 +00:00
|
|
|
|
|
|
|
static TEST_DIR1: &'static str = "mkdir_test1";
|
|
|
|
static TEST_DIR2: &'static str = "mkdir_test2";
|
|
|
|
static TEST_DIR3: &'static str = "mkdir_test3";
|
|
|
|
static TEST_DIR4: &'static str = "mkdir_test4/mkdir_test4_1";
|
|
|
|
static TEST_DIR5: &'static str = "mkdir_test5/mkdir_test5_1";
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_mkdir_mkdir() {
|
2016-07-29 21:26:32 +00:00
|
|
|
let exit_success = new_ucmd()
|
|
|
|
.arg(TEST_DIR1).run().success;
|
2015-11-16 05:25:01 +00:00
|
|
|
assert_eq!(exit_success, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_mkdir_dup_dir() {
|
2016-07-29 21:26:32 +00:00
|
|
|
let scene = TestScenario::new(UTIL_NAME);
|
|
|
|
let exit_success = scene.ucmd().arg(TEST_DIR2).run().success;
|
|
|
|
let exit_success2 = scene.ucmd().arg(TEST_DIR2).run().success;
|
2015-11-16 05:25:01 +00:00
|
|
|
assert!(exit_success);
|
|
|
|
assert!(!exit_success2);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_mkdir_mode() {
|
2016-07-29 21:26:32 +00:00
|
|
|
let exit_success = new_ucmd()
|
|
|
|
.arg("-m")
|
2015-11-16 05:25:01 +00:00
|
|
|
.arg("755")
|
|
|
|
.arg(TEST_DIR3)
|
|
|
|
.run()
|
|
|
|
.success;
|
|
|
|
assert!(exit_success);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_mkdir_parent() {
|
2016-07-29 21:26:32 +00:00
|
|
|
let exit_success = new_ucmd()
|
|
|
|
.arg("-p").arg(TEST_DIR4).run().success;
|
2015-11-16 05:25:01 +00:00
|
|
|
assert!(exit_success);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_mkdir_no_parent() {
|
2016-07-29 21:26:32 +00:00
|
|
|
let exit_success = new_ucmd()
|
|
|
|
.arg(TEST_DIR5).run().success;
|
2015-11-16 05:25:01 +00:00
|
|
|
assert!(!exit_success);
|
|
|
|
}
|