-
Notifications
You must be signed in to change notification settings - Fork 681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement mkfifoat #1133
Implement mkfifoat #1133
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,58 @@ fn test_mkfifo_directory() { | |
assert!(mkfifo(&env::temp_dir(), Mode::S_IRUSR).is_err()); | ||
} | ||
|
||
#[test] | ||
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))] | ||
fn test_mkfifoat_none() { | ||
let tempdir = tempfile::tempdir().unwrap(); | ||
let mkfifoat_fifo = tempdir.path().join("mkfifoat_fifo"); | ||
|
||
mkfifoat(None, &mkfifoat_fifo, Mode::S_IRUSR).unwrap(); | ||
|
||
let stats = stat::stat(&mkfifoat_fifo).unwrap(); | ||
let typ = stat::SFlag::from_bits_truncate(stats.st_mode); | ||
assert_eq!(typ, SFlag::S_IFIFO); | ||
} | ||
|
||
#[test] | ||
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))] | ||
fn test_mkfifoat() { | ||
let tempdir = tempfile::tempdir().unwrap(); | ||
let dirfd = open(tempdir.path(), OFlag::empty(), Mode::empty()).unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part should really be a separate test case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
let mkfifoat_name = "mkfifoat_name"; | ||
|
||
mkfifoat(Some(dirfd), mkfifoat_name, Mode::S_IRUSR).unwrap(); | ||
|
||
let stats = stat::fstatat(dirfd, mkfifoat_name, fcntl::AtFlags::empty()).unwrap(); | ||
let typ = stat::SFlag::from_bits_truncate(stats.st_mode); | ||
assert_eq!(typ, SFlag::S_IFIFO); | ||
} | ||
|
||
#[test] | ||
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))] | ||
fn test_mkfifoat_directory_none() { | ||
// mkfifoat should fail if a directory is given | ||
assert_eq!( | ||
mkfifoat(None, &env::temp_dir(), Mode::S_IRUSR).is_ok(), | ||
false | ||
); | ||
} | ||
|
||
#[test] | ||
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))] | ||
fn test_mkfifoat_directory() { | ||
// mkfifoat should fail if a directory is given | ||
let tempdir = tempfile::tempdir().unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part should be a separate test case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
let dirfd = open(tempdir.path(), OFlag::empty(), Mode::empty()).unwrap(); | ||
let mkfifoat_dir = "mkfifoat_dir"; | ||
stat::mkdirat(dirfd, mkfifoat_dir, Mode::S_IRUSR).unwrap(); | ||
|
||
assert_eq!( | ||
mkfifoat(Some(dirfd), mkfifoat_dir, Mode::S_IRUSR).is_ok(), | ||
false | ||
); | ||
} | ||
|
||
#[test] | ||
fn test_getpid() { | ||
let pid: ::libc::pid_t = getpid().into(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one blank line, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed