2020-05-25 17:05:26 +00:00
|
|
|
use crate::common::util::*;
|
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";
|
2017-04-01 12:38:56 +00:00
|
|
|
static TEST_DIR6: &'static str = "mkdir_test6";
|
|
|
|
static TEST_FILE7: &'static str = "mkdir_test7";
|
2015-11-16 05:25:01 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_mkdir_mkdir() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!().arg(TEST_DIR1).succeeds();
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_mkdir_dup_dir() {
|
2016-08-23 11:52:43 +00:00
|
|
|
let scene = TestScenario::new(util_name!());
|
2016-08-13 21:59:21 +00:00
|
|
|
scene.ucmd().arg(TEST_DIR2).succeeds();
|
2017-04-01 12:38:56 +00:00
|
|
|
scene.ucmd().arg(TEST_DIR2).fails();
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_mkdir_mode() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!().arg("-m").arg("755").arg(TEST_DIR3).succeeds();
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_mkdir_parent() {
|
2016-12-23 13:27:32 +00:00
|
|
|
let scene = TestScenario::new(util_name!());
|
|
|
|
scene.ucmd().arg("-p").arg(TEST_DIR4).succeeds();
|
|
|
|
scene.ucmd().arg("-p").arg(TEST_DIR4).succeeds();
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_mkdir_no_parent() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!().arg(TEST_DIR5).fails();
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
2017-04-01 12:38:56 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_mkdir_dup_dir_parent() {
|
|
|
|
let scene = TestScenario::new(util_name!());
|
|
|
|
scene.ucmd().arg(TEST_DIR6).succeeds();
|
|
|
|
scene.ucmd().arg("-p").arg(TEST_DIR6).succeeds();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_mkdir_dup_file() {
|
|
|
|
let scene = TestScenario::new(util_name!());
|
|
|
|
scene.fixtures.touch(TEST_FILE7);
|
|
|
|
scene.ucmd().arg(TEST_FILE7).fails();
|
2018-05-01 11:42:11 +00:00
|
|
|
|
2017-04-01 12:38:56 +00:00
|
|
|
// mkdir should fail for a file even if -p is specified.
|
|
|
|
scene.ucmd().arg("-p").arg(TEST_FILE7).fails();
|
|
|
|
}
|