summaryrefslogtreecommitdiff
path: root/test/test_unistd.rs
diff options
context:
space:
mode:
authorSteve Lau <stevelauc@outlook.com>2022-10-13 09:23:09 +0800
committerSteve Lau <stevelauc@outlook.com>2022-10-13 09:23:09 +0800
commit04e409b376615080e1d910e302b28b144dcbff71 (patch)
treeb2cdffd291499aeeac418e74f463555f915305aa /test/test_unistd.rs
parentb06b216f6e58e6e69d901b8f9fb836c43cd27323 (diff)
downloadnix-04e409b376615080e1d910e302b28b144dcbff71.zip
add eaccess on FreeBSD, DragonFly and Linux (musl and glibc)
Diffstat (limited to 'test/test_unistd.rs')
-rw-r--r--test/test_unistd.rs37
1 files changed, 33 insertions, 4 deletions
diff --git a/test/test_unistd.rs b/test/test_unistd.rs
index eee10103..8ad6340c 100644
--- a/test/test_unistd.rs
+++ b/test/test_unistd.rs
@@ -1310,7 +1310,7 @@ fn test_getpeereid_invalid_fd() {
}
#[test]
-#[cfg(not(any(target_os = "illumos", target_os = "redox")))]
+#[cfg(not(target_os = "redox"))]
fn test_faccessat_none_not_existing() {
use nix::fcntl::AtFlags;
let tempdir = tempfile::tempdir().unwrap();
@@ -1324,7 +1324,7 @@ fn test_faccessat_none_not_existing() {
}
#[test]
-#[cfg(not(any(target_os = "illumos", target_os = "redox")))]
+#[cfg(not(target_os = "redox"))]
fn test_faccessat_not_existing() {
use nix::fcntl::AtFlags;
let tempdir = tempfile::tempdir().unwrap();
@@ -1344,7 +1344,7 @@ fn test_faccessat_not_existing() {
}
#[test]
-#[cfg(not(any(target_os = "illumos", target_os = "redox")))]
+#[cfg(not(target_os = "redox"))]
fn test_faccessat_none_file_exists() {
use nix::fcntl::AtFlags;
let tempdir = tempfile::tempdir().unwrap();
@@ -1360,7 +1360,7 @@ fn test_faccessat_none_file_exists() {
}
#[test]
-#[cfg(not(any(target_os = "illumos", target_os = "redox")))]
+#[cfg(not(target_os = "redox"))]
fn test_faccessat_file_exists() {
use nix::fcntl::AtFlags;
let tempdir = tempfile::tempdir().unwrap();
@@ -1376,3 +1376,32 @@ fn test_faccessat_file_exists() {
)
.is_ok());
}
+
+#[test]
+#[cfg(any(
+ all(target_os = "linux", not(target_env = "uclibc")),
+ target_os = "freebsd",
+ target_os = "dragonfly"
+))]
+fn test_eaccess_not_existing() {
+ let tempdir = tempdir().unwrap();
+ let dir = tempdir.path().join("does_not_exist.txt");
+ assert_eq!(
+ eaccess(&dir, AccessFlags::F_OK).err().unwrap(),
+ Errno::ENOENT
+ );
+}
+
+#[test]
+#[cfg(any(
+ all(target_os = "linux", not(target_env = "uclibc")),
+ target_os = "freebsd",
+ target_os = "dragonfly"
+))]
+fn test_eaccess_file_exists() {
+ let tempdir = tempdir().unwrap();
+ let path = tempdir.path().join("does_exist.txt");
+ let _file = File::create(path.clone()).unwrap();
+ eaccess(&path, AccessFlags::R_OK | AccessFlags::W_OK)
+ .expect("assertion failed");
+}