summaryrefslogtreecommitdiff
path: root/test/test_dir.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-03-21 23:24:39 +0000
committerGitHub <noreply@github.com>2021-03-21 23:24:39 +0000
commitfde9ebc6060ba7d5f0f49bafe82f332003ea9605 (patch)
tree09c410385c727ac6f9e9bfae71077901f5edfb6d /test/test_dir.rs
parent7b3129a194ecbf3e5f99f30ff26ab0e6fa7f183d (diff)
parentd444f1bcf20b29d0ec69e30046c71d005a2b9d72 (diff)
downloadnix-fde9ebc6060ba7d5f0f49bafe82f332003ea9605.zip
Merge #1394
1394: illumos and Solaris support r=asomers a=jasonbking Adds support for the illumos target as well as improvements in the existing Solaris support. Co-authored-by: Dominik Hassler <hadfl@omnios.org> Co-authored-by: Joshua M. Clulow <josh@sysmgr.org> Co-authored-by: Jason King <jason.brian.king@gmail.com>
Diffstat (limited to 'test/test_dir.rs')
-rw-r--r--test/test_dir.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/test/test_dir.rs b/test/test_dir.rs
index 505277e7..4d7f5f7a 100644
--- a/test/test_dir.rs
+++ b/test/test_dir.rs
@@ -4,13 +4,24 @@ use nix::sys::stat::Mode;
use std::fs::File;
use tempfile::tempdir;
+
+#[cfg(test)]
+fn flags() -> OFlag {
+ #[cfg(target_os = "illumos")]
+ let f = OFlag::O_RDONLY | OFlag::O_CLOEXEC;
+
+ #[cfg(not(target_os = "illumos"))]
+ let f = OFlag::O_RDONLY | OFlag::O_CLOEXEC | OFlag::O_DIRECTORY;
+
+ f
+}
+
#[test]
fn read() {
let tmp = tempdir().unwrap();
File::create(&tmp.path().join("foo")).unwrap();
::std::os::unix::fs::symlink("foo", tmp.path().join("bar")).unwrap();
- let mut dir = Dir::open(tmp.path(), OFlag::O_DIRECTORY | OFlag::O_RDONLY | OFlag::O_CLOEXEC,
- Mode::empty()).unwrap();
+ let mut dir = Dir::open(tmp.path(), flags(), Mode::empty()).unwrap();
let mut entries: Vec<_> = dir.iter().map(|e| e.unwrap()).collect();
entries.sort_by(|a, b| a.file_name().cmp(b.file_name()));
let entry_names: Vec<_> = entries
@@ -30,8 +41,7 @@ fn read() {
#[test]
fn rewind() {
let tmp = tempdir().unwrap();
- let mut dir = Dir::open(tmp.path(), OFlag::O_DIRECTORY | OFlag::O_RDONLY | OFlag::O_CLOEXEC,
- Mode::empty()).unwrap();
+ let mut dir = Dir::open(tmp.path(), flags(), Mode::empty()).unwrap();
let entries1: Vec<_> = dir.iter().map(|e| e.unwrap().file_name().to_owned()).collect();
let entries2: Vec<_> = dir.iter().map(|e| e.unwrap().file_name().to_owned()).collect();
let entries3: Vec<_> = dir.into_iter().map(|e| e.unwrap().file_name().to_owned()).collect();