diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2017-07-15 15:36:23 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2017-07-15 15:36:23 +0000 |
commit | f84a008559d4f8ce0a79652ad0c515e7139a272c (patch) | |
tree | 83e0872d9678ab981a384d7247a76bf33d5bcbb6 /test | |
parent | da49f2aa5265bcf667469d5ab5ac8253d53da7d7 (diff) | |
parent | b259964a773154bb743cab8ffaaa97729042e312 (diff) | |
download | nix-f84a008559d4f8ce0a79652ad0c515e7139a272c.zip |
Merge #630
630: Add wrappers for sysconf(3), pathconf(2), and fpathconf(2) r=asomers
Diffstat (limited to 'test')
-rw-r--r-- | test/test_unistd.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/test_unistd.rs b/test/test_unistd.rs index 22aa5da8..051ea3d1 100644 --- a/test/test_unistd.rs +++ b/test/test_unistd.rs @@ -220,3 +220,35 @@ execve_test_factory!(test_execve, execve, b"/bin/sh", b"/system/bin/sh"); #[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(feature = "execvpe")] execve_test_factory!(test_execvpe, execvpe, b"sh", b"sh"); + +#[test] +fn test_fpathconf_limited() { + let f = tempfile().unwrap(); + // AFAIK, PATH_MAX is limited on all platforms, so it makes a good test + let path_max = fpathconf(f.as_raw_fd(), PathconfVar::PATH_MAX); + assert!(path_max.expect("fpathconf failed").expect("PATH_MAX is unlimited") > 0); +} + +#[test] +fn test_pathconf_limited() { + // AFAIK, PATH_MAX is limited on all platforms, so it makes a good test + let path_max = pathconf(".", PathconfVar::PATH_MAX); + assert!(path_max.expect("pathconf failed").expect("PATH_MAX is unlimited") > 0); +} + +#[test] +fn test_sysconf_limited() { + // AFAIK, OPEN_MAX is limited on all platforms, so it makes a good test + let open_max = sysconf(SysconfVar::OPEN_MAX); + assert!(open_max.expect("sysconf failed").expect("OPEN_MAX is unlimited") > 0); +} + +#[cfg(target_os = "freebsd")] +#[test] +fn test_sysconf_unsupported() { + // I know of no sysconf variables that are unsupported everywhere, but + // _XOPEN_CRYPT is unsupported on FreeBSD 11.0, which is one of the platforms + // we test. + let open_max = sysconf(SysconfVar::_XOPEN_CRYPT); + assert!(open_max.expect("sysconf failed").is_none()) +} |