1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

tests: Add test for du threshold feature

This commit is contained in:
Anup Mahindre 2021-06-12 19:30:48 +05:30
parent d6181ce7d4
commit fa12b46c51

View file

@ -80,19 +80,22 @@ fn _du_basics_subdir(s: &str) {
#[test] #[test]
fn test_du_invalid_size() { fn test_du_invalid_size() {
new_ucmd!() let args = &["block-size", "threshold"];
.arg("--block-size=1fb4t") for s in args {
.arg("/tmp") new_ucmd!()
.fails() .arg(format!("--{}=1fb4t", s))
.code_is(1) .arg("/tmp")
.stderr_only("du: invalid --block-size argument '1fb4t'"); .fails()
#[cfg(not(target_pointer_width = "128"))] .code_is(1)
new_ucmd!() .stderr_only(format!("du: invalid --{} argument '1fb4t'", s));
.arg("--block-size=1Y") #[cfg(not(target_pointer_width = "128"))]
.arg("/tmp") new_ucmd!()
.fails() .arg(format!("--{}=1Y", s))
.code_is(1) .arg("/tmp")
.stderr_only("du: --block-size argument '1Y' too large"); .fails()
.code_is(1)
.stderr_only(format!("du: --{} argument '1Y' too large", s));
}
} }
#[test] #[test]
@ -351,3 +354,24 @@ fn test_du_one_file_system() {
} }
_du_basics_subdir(result.stdout_str()); _du_basics_subdir(result.stdout_str());
} }
#[test]
fn test_du_threshold() {
let scene = TestScenario::new(util_name!());
let threshold = if cfg!(windows) { "7K" } else { "10K" };
scene
.ucmd()
.arg(format!("--threshold={}", threshold))
.succeeds()
.stdout_contains("links")
.stdout_does_not_contain("deeper");
scene
.ucmd()
.arg(format!("--threshold=-{}", threshold))
.succeeds()
.stdout_does_not_contain("links")
.stdout_contains("deeper");
}