summaryrefslogtreecommitdiff
path: root/test/test_unistd.rs
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2017-06-24 14:20:48 -0600
committerAlan Somers <asomers@gmail.com>2017-07-15 09:34:32 -0600
commitb259964a773154bb743cab8ffaaa97729042e312 (patch)
treef8d1259450493c0f4cd9b11057f768a780e98aa9 /test/test_unistd.rs
parente12ff7725e6911ad3ed2112bbc21a21643ee40da (diff)
downloadnix-b259964a773154bb743cab8ffaaa97729042e312.zip
Add sysconf(3), pathconf(2), and fpathconf(2)
Diffstat (limited to 'test/test_unistd.rs')
-rw-r--r--test/test_unistd.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/test_unistd.rs b/test/test_unistd.rs
index 76ab442a..82c6aa68 100644
--- a/test/test_unistd.rs
+++ b/test/test_unistd.rs
@@ -217,3 +217,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())
+}