printenv: add a test for non-utf-8 var

Like in : 5d4abd88e9
This commit is contained in:
Sylvestre Ledru
2025-12-25 16:31:25 +01:00
parent 6a3b559fa6
commit 50085d7a0e
+13
View File
@@ -117,3 +117,16 @@ fn test_non_utf8_value() {
);
result.stdout_is_bytes(b"/tmp/lib.so\xff\n");
}
#[test]
#[cfg(unix)]
fn test_non_utf8_env_vars() {
use std::ffi::OsString;
use std::os::unix::ffi::OsStringExt;
let non_utf8_value = OsString::from_vec(b"hello\x80world".to_vec());
new_ucmd!()
.env("NON_UTF8_VAR", &non_utf8_value)
.succeeds()
.stdout_contains_bytes(b"NON_UTF8_VAR=hello\x80world");
}