summaryrefslogtreecommitdiffstats
path: root/tests/by-util/test_ls.rs
diff options
context:
space:
mode:
authorDaniel Hofstetter <daniel.hofstetter@42dh.com>2023-12-23 17:24:54 +0100
committerDaniel Hofstetter <daniel.hofstetter@42dh.com>2023-12-24 16:35:49 +0100
commit270ac90cc13cf446cdccd884e3b9e4de4aec5842 (patch)
tree99aa20f31a2bd4b88f44f1346c52f2f495b79aa7 /tests/by-util/test_ls.rs
parent12ade877863c52de0be8201a193de299884dd77f (diff)
ls: set correct block size when -k is provided
Diffstat (limited to 'tests/by-util/test_ls.rs')
-rw-r--r--tests/by-util/test_ls.rs50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs
index a7744063f..5da8912e3 100644
--- a/tests/by-util/test_ls.rs
+++ b/tests/by-util/test_ls.rs
@@ -3890,6 +3890,56 @@ fn test_posixly_correct_and_block_size_env_vars() {
.stdout_contains(" 1024 ");
}
+#[cfg(all(unix, feature = "dd"))]
+#[test]
+fn test_posixly_correct_and_block_size_env_vars_with_k() {
+ let scene = TestScenario::new(util_name!());
+
+ scene
+ .ccmd("dd")
+ .arg("if=/dev/zero")
+ .arg("of=file")
+ .arg("bs=1024")
+ .arg("count=1")
+ .succeeds();
+
+ scene
+ .ucmd()
+ .arg("-l")
+ .arg("-k")
+ .env("POSIXLY_CORRECT", "some_value")
+ .succeeds()
+ .stdout_contains_line("total 4")
+ .stdout_contains(" 1024 ");
+
+ scene
+ .ucmd()
+ .arg("-l")
+ .arg("-k")
+ .env("LS_BLOCK_SIZE", "512")
+ .succeeds()
+ .stdout_contains_line("total 4")
+ .stdout_contains(" 2 ");
+
+ scene
+ .ucmd()
+ .arg("-l")
+ .arg("-k")
+ .env("BLOCK_SIZE", "512")
+ .succeeds()
+ .stdout_contains_line("total 4")
+ .stdout_contains(" 2 ");
+
+ scene
+ .ucmd()
+ .arg("-l")
+ .arg("-k")
+ .env("BLOCKSIZE", "512")
+ .succeeds()
+ .stdout_contains_line("total 4")
+ .stdout_contains(" 1024 ");
+}
+
#[test]
fn test_ls_invalid_block_size() {
new_ucmd!()