summaryrefslogtreecommitdiff
path: root/test/test_unistd.rs
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_unistd.rs')
-rw-r--r--test/test_unistd.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test_unistd.rs b/test/test_unistd.rs
index 0a41b65f..183d8337 100644
--- a/test/test_unistd.rs
+++ b/test/test_unistd.rs
@@ -17,6 +17,7 @@ use std::ffi::CString;
use std::fs::DirBuilder;
use std::fs::{self, File};
use std::io::Write;
+use std::mem;
use std::os::unix::prelude::*;
use tempfile::{tempdir, tempfile};
use libc::{_exit, off_t};
@@ -410,6 +411,23 @@ fn test_chown() {
}
#[test]
+fn test_fchown() {
+ // Testing for anything other than our own UID/GID is hard.
+ let uid = Some(getuid());
+ let gid = Some(getgid());
+
+ let path = tempfile().unwrap();
+ let fd = path.as_raw_fd();
+
+ fchown(fd, uid, gid).unwrap();
+ fchown(fd, uid, None).unwrap();
+ fchown(fd, None, gid).unwrap();
+
+ mem::drop(path);
+ fchown(fd, uid, gid).unwrap_err();
+}
+
+#[test]
#[cfg(not(target_os = "redox"))]
fn test_fchownat() {
let _dr = crate::DirRestore::new();