From b259964a773154bb743cab8ffaaa97729042e312 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sat, 24 Jun 2017 14:20:48 -0600 Subject: Add sysconf(3), pathconf(2), and fpathconf(2) --- test/test_unistd.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test') 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()) +} -- cgit v1.2.3