summaryrefslogtreecommitdiff
path: root/test/test_unistd.rs
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2020-12-08 19:37:50 -0700
committerAlan Somers <asomers@gmail.com>2020-12-08 19:37:50 -0700
commit1c757c78baca8bd53309b625acbe86814c1de74c (patch)
tree4a4890ac3085fe0f4d89eaab9d991b568c9d7062 /test/test_unistd.rs
parenta848ab555c99a8275342a920ae4e2d7ad809d518 (diff)
downloadnix-1c757c78baca8bd53309b625acbe86814c1de74c.zip
Fix a race in the test_unistd::test_fchown test
The test was assuming that once dropped, a temporary file's file descriptor would be invalid. But it might not be, because another file might be opened with the same file descriptor. Instead, use an obviously invalid file descriptor.
Diffstat (limited to 'test/test_unistd.rs')
-rw-r--r--test/test_unistd.rs5
1 files changed, 1 insertions, 4 deletions
diff --git a/test/test_unistd.rs b/test/test_unistd.rs
index 113bef62..632e1be4 100644
--- a/test/test_unistd.rs
+++ b/test/test_unistd.rs
@@ -19,7 +19,6 @@ 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::*;
#[cfg(not(target_os = "redox"))]
use std::path::Path;
@@ -466,9 +465,7 @@ fn test_fchown() {
fchown(fd, uid, gid).unwrap();
fchown(fd, uid, None).unwrap();
fchown(fd, None, gid).unwrap();
-
- mem::drop(path);
- fchown(fd, uid, gid).unwrap_err();
+ fchown(999999999, uid, gid).unwrap_err();
}
#[test]