diff options
author | Philipp Keller <philipp.keller@gmail.com> | 2016-09-03 22:57:58 +0200 |
---|---|---|
committer | Philipp Keller <philipp.keller@gmail.com> | 2016-09-03 22:57:58 +0200 |
commit | b03d4e5ff22e0f8988dc8655c1e7dfcc3fe29f66 (patch) | |
tree | 17dbff2d2c9e99003e63c57400950d3258141b1f | |
parent | ac642737967525226dc36f43e6e99d58328d5c6c (diff) | |
download | nix-b03d4e5ff22e0f8988dc8655c1e7dfcc3fe29f66.zip |
added test for getcwd, still not complete (needs to check also longer directory names, need to be created with mkdir first which doesn't exist yet)
-rw-r--r-- | test/test_unistd.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/test/test_unistd.rs b/test/test_unistd.rs index 48891bc3..2b6182b6 100644 --- a/test/test_unistd.rs +++ b/test/test_unistd.rs @@ -1,3 +1,5 @@ +extern crate tempdir; + use nix::unistd::*; use nix::unistd::ForkResult::*; use nix::sys::wait::*; @@ -5,11 +7,10 @@ use std::ffi::CString; use std::io::{Write, Read}; use tempfile::tempfile; +use tempdir::TempDir; use libc::off_t; use std::os::unix::prelude::*; - - #[test] fn test_fork_and_waitpid() { let pid = fork(); @@ -121,7 +122,16 @@ macro_rules! execve_test_factory( #[test] fn test_getcwd() { - println!("{}", getcwd().unwrap().display()); + // workaround for the fact that on os x TmpDir::new returns /var/folders/... but upon + // chdir into that directory getcwd returns /private/var/folders/... + let base = if cfg!(target_os = "macos") { + "/private/tmp/" + } else { + "/tmp/" + }; + let tmp_dir = TempDir::new_in(base, "test_getcwd").expect("create temp dir").into_path(); + assert!(chdir(tmp_dir.as_path()).is_ok()); + assert_eq!(getcwd().unwrap(), tmp_dir); } #[test] |