summaryrefslogtreecommitdiff
path: root/test/sys/test_select.rs
diff options
context:
space:
mode:
authorJonas Schievink <jonasschievink@gmail.com>2017-07-21 00:46:56 +0200
committerJonas Schievink <jonasschievink@gmail.com>2017-08-11 17:59:42 +0200
commit885a1f751497c265a532a42a0c98829e32ae7f82 (patch)
tree1182c241bf23de333e2c4b9cf3b137ccbd664c6b /test/sys/test_select.rs
parent4e9dd256d37e697cb775384123e37b7e2852ac1b (diff)
downloadnix-885a1f751497c265a532a42a0c98829e32ae7f82.zip
Calculate `nfds` parameter for `select`
Doing this behind the scenes makes the API less error-prone and easier to use. It should also fix https://github.com/nix-rust/nix/issues/679#issuecomment-316838148
Diffstat (limited to 'test/sys/test_select.rs')
-rw-r--r--test/sys/test_select.rs59
1 files changed, 0 insertions, 59 deletions
diff --git a/test/sys/test_select.rs b/test/sys/test_select.rs
deleted file mode 100644
index d50c7d74..00000000
--- a/test/sys/test_select.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-use nix::sys::select::{FdSet, FD_SETSIZE, select};
-use nix::sys::time::{TimeVal, TimeValLike};
-use nix::unistd::{write, pipe};
-
-#[test]
-fn test_fdset() {
- let mut fd_set = FdSet::new();
-
- for i in 0..FD_SETSIZE {
- assert!(!fd_set.contains(i));
- }
-
- fd_set.insert(7);
-
- assert!(fd_set.contains(7));
-
- fd_set.remove(7);
-
- for i in 0..FD_SETSIZE {
- assert!(!fd_set.contains(i));
- }
-
- fd_set.insert(1);
- fd_set.insert(FD_SETSIZE / 2);
- fd_set.insert(FD_SETSIZE - 1);
-
- fd_set.clear();
-
- for i in 0..FD_SETSIZE {
- assert!(!fd_set.contains(i));
- }
-}
-
-// powerpc-unknown-linux-gnu currently fails on the first `assert_eq` because
-// `select()` returns a 0 instead of a 1. Since this test has only been run on
-// qemu, it's unclear if this is a OS or qemu bug. Just disable it on that arch
-// for now.
-// FIXME: Fix tests for powerpc and mips
-// FIXME: Add a link to an upstream qemu bug if there is one
-#[test]
-#[cfg_attr(any(target_arch = "powerpc", target_arch = "mips"), ignore)]
-fn test_select() {
- let (r1, w1) = pipe().unwrap();
- write(w1, b"hi!").unwrap();
- let (r2, _w2) = pipe().unwrap();
-
- let mut fd_set = FdSet::new();
- fd_set.insert(r1);
- fd_set.insert(r2);
-
- let mut timeout = TimeVal::seconds(10);
- assert_eq!(1, select(r2 + 1,
- Some(&mut fd_set),
- None,
- None,
- Some(&mut timeout)).unwrap());
- assert!(fd_set.contains(r1));
- assert!(!fd_set.contains(r2));
-}