about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2022-12-11 19:22:55 +0100
committerRalf Jung <post@ralfj.de>2022-12-12 11:00:47 +0100
commita66780bc3fb87b33b31e39cb4a3e34de1a80deaa (patch)
tree59ec9bc5a5450d7bb2f3f6aec527a6a935aa78db
parentc19ca083ee79ffa49404b88f2172936fac831e25 (diff)
More host/target path conversion tests:
- test that the tmpdir Miri tests see is absolute and a directory
- test that current_dir returns an absolute path
-rw-r--r--src/tools/miri/tests/pass/shims/env/current_dir.rs3
-rw-r--r--src/tools/miri/tests/pass/shims/fs.rs7
2 files changed, 9 insertions, 1 deletions
diff --git a/src/tools/miri/tests/pass/shims/env/current_dir.rs b/src/tools/miri/tests/pass/shims/env/current_dir.rs
index 069b462ab37..ca90912eabc 100644
--- a/src/tools/miri/tests/pass/shims/env/current_dir.rs
+++ b/src/tools/miri/tests/pass/shims/env/current_dir.rs
@@ -3,8 +3,9 @@ use std::env;
 use std::io::ErrorKind;
 
 fn main() {
-    // Test that `getcwd` is available
+    // Test that `getcwd` is available and an absolute path
     let cwd = env::current_dir().unwrap();
+    assert!(cwd.is_absolute(), "cwd {:?} is not absolute", cwd);
     // Test that changing dir to `..` actually sets the current directory to the parent of `cwd`.
     // The only exception here is if `cwd` is the root directory, then changing directory must
     // keep the current directory equal to `cwd`.
diff --git a/src/tools/miri/tests/pass/shims/fs.rs b/src/tools/miri/tests/pass/shims/fs.rs
index 901a2ab1028..e3ebbc8c8d2 100644
--- a/src/tools/miri/tests/pass/shims/fs.rs
+++ b/src/tools/miri/tests/pass/shims/fs.rs
@@ -28,6 +28,7 @@ fn main() {
     test_directory();
     test_canonicalize();
     test_from_raw_os_error();
+    test_path_conversion();
 }
 
 fn tmp() -> PathBuf {
@@ -74,6 +75,12 @@ fn prepare_with_content(filename: &str, content: &[u8]) -> PathBuf {
     path
 }
 
+fn test_path_conversion() {
+    let tmp = tmp();
+    assert!(tmp.is_absolute(), "{:?} is not absolute", tmp);
+    assert!(tmp.is_dir(), "{:?} is not a directory", tmp);
+}
+
 fn test_file() {
     let bytes = b"Hello, World!\n";
     let path = prepare("miri_test_fs_file.txt");