From 64fb7a746262e890076949cfdd394b47e9b9ac84 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Tue, 22 Jul 2025 17:24:13 +0800 Subject: [PATCH] test_mkdir: Add a test for non-Unicode directory name Similar to the first part of GNU test df/problematic-chars. --- tests/by-util/test_mkdir.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/by-util/test_mkdir.rs b/tests/by-util/test_mkdir.rs index 56b4297ca..d70d50ce0 100644 --- a/tests/by-util/test_mkdir.rs +++ b/tests/by-util/test_mkdir.rs @@ -34,6 +34,18 @@ fn test_mkdir_mkdir() { new_ucmd!().arg("test_dir").succeeds(); } +#[cfg(feature = "test_risky_names")] +#[test] +fn test_mkdir_non_unicode() { + let (at, mut ucmd) = at_and_ucmd!(); + + let target = uucore::os_str_from_bytes(b"some-\xc0-dir-\xf3") + .expect("Only unix platforms can test non-unicode names"); + ucmd.arg(&target).succeeds(); + + assert!(at.dir_exists(target)); +} + #[test] fn test_mkdir_verbose() { let expected = "mkdir: created directory 'test_dir'\n";