summaryrefslogtreecommitdiff
path: root/test/test_unistd.rs
diff options
context:
space:
mode:
authorPhilipp Keller <philipp.keller@gmail.com>2016-09-06 22:18:19 +0200
committerPhilipp Keller <philipp.keller@gmail.com>2016-09-06 22:18:19 +0200
commit50693c11b02f11e13687ee48f5a1e0131542d7f8 (patch)
treec5718a1c02d0dd2dacf731b3b5a4bc926cd879f4 /test/test_unistd.rs
parentc0a578539a4ad6b1f8ad48b8e26fbacc0d55852d (diff)
downloadnix-50693c11b02f11e13687ee48f5a1e0131542d7f8.zip
added documentation for getcwd and mkdir, changed test so that it compares against std::env::current_dir
Diffstat (limited to 'test/test_unistd.rs')
-rw-r--r--test/test_unistd.rs17
1 files changed, 5 insertions, 12 deletions
diff --git a/test/test_unistd.rs b/test/test_unistd.rs
index 06a9cd99..8e03c165 100644
--- a/test/test_unistd.rs
+++ b/test/test_unistd.rs
@@ -6,12 +6,12 @@ use nix::sys::wait::*;
use nix::sys::stat;
use std::iter;
use std::ffi::CString;
-
use std::io::{Write, Read};
+use std::os::unix::prelude::*;
+use std::env::current_dir;
use tempfile::tempfile;
use tempdir::TempDir;
use libc::off_t;
-use std::os::unix::prelude::*;
#[test]
fn test_fork_and_waitpid() {
@@ -124,16 +124,9 @@ macro_rules! execve_test_factory(
#[test]
fn test_getcwd() {
- // 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 mut tmp_dir = TempDir::new_in(base, "test_getcwd").unwrap().into_path();
+ let mut tmp_dir = TempDir::new("test_getcwd").unwrap().into_path();
assert!(chdir(tmp_dir.as_path()).is_ok());
- assert_eq!(getcwd().unwrap(), tmp_dir);
+ assert_eq!(getcwd().unwrap(), current_dir().unwrap());
// make path 500 chars longer so that buffer doubling in getcwd kicks in.
// Note: One path cannot be longer than 255 bytes (NAME_MAX)
@@ -144,7 +137,7 @@ fn test_getcwd() {
assert!(mkdir(tmp_dir.as_path(), stat::S_IRWXU).is_ok());
}
assert!(chdir(tmp_dir.as_path()).is_ok());
- assert_eq!(getcwd().unwrap(), tmp_dir);
+ assert_eq!(getcwd().unwrap(), current_dir().unwrap());
}
#[test]