diff options
| author | Joe Ellis <joe.ellis@arm.com> | 2020-09-08 10:31:56 +0100 |
|---|---|---|
| committer | Joe Ellis <joe.ellis@arm.com> | 2020-09-14 10:31:56 +0100 |
| commit | 7c20be387b1d9447289c0ddd1cd3300bf3199b35 (patch) | |
| tree | 01d94718f62ddcc35af156c2229ebcd423459398 /library/std/src/sys | |
| parent | 40a830321d82ae1dcb97cd2b964ae52a4ebc9c6a (diff) | |
| download | rust-7c20be387b1d9447289c0ddd1cd3300bf3199b35.tar.gz rust-7c20be387b1d9447289c0ddd1cd3300bf3199b35.zip | |
Move Unix peer credentials tests to their own file
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/unix/ext/ucred.rs | 20 | ||||
| -rw-r--r-- | library/std/src/sys/unix/ext/ucred/tests.rs | 16 |
2 files changed, 16 insertions, 20 deletions
diff --git a/library/std/src/sys/unix/ext/ucred.rs b/library/std/src/sys/unix/ext/ucred.rs index 8cce968b35a..f7af9f5e96e 100644 --- a/library/std/src/sys/unix/ext/ucred.rs +++ b/library/std/src/sys/unix/ext/ucred.rs @@ -89,23 +89,3 @@ pub mod impl_bsd { } } } - -#[cfg(test)] -mod test { - use crate::os::unix::net::UnixStream; - use libc::{getegid, geteuid}; - - #[test] - fn test_socket_pair() { - // Create two connected sockets and get their peer credentials. They should be equal. - let (sock_a, sock_b) = UnixStream::pair().unwrap(); - let (cred_a, cred_b) = (sock_a.peer_cred().unwrap(), sock_b.peer_cred().unwrap()); - assert_eq!(cred_a, cred_b); - - // Check that the UID and GIDs match up. - let uid = unsafe { geteuid() }; - let gid = unsafe { getegid() }; - assert_eq!(cred_a.uid, uid); - assert_eq!(cred_a.gid, gid); - } -} diff --git a/library/std/src/sys/unix/ext/ucred/tests.rs b/library/std/src/sys/unix/ext/ucred/tests.rs new file mode 100644 index 00000000000..efe99467210 --- /dev/null +++ b/library/std/src/sys/unix/ext/ucred/tests.rs @@ -0,0 +1,16 @@ +use crate::os::unix::net::UnixStream; +use libc::{getegid, geteuid}; + +#[test] +fn test_socket_pair() { + // Create two connected sockets and get their peer credentials. They should be equal. + let (sock_a, sock_b) = UnixStream::pair().unwrap(); + let (cred_a, cred_b) = (sock_a.peer_cred().unwrap(), sock_b.peer_cred().unwrap()); + assert_eq!(cred_a, cred_b); + + // Check that the UID and GIDs match up. + let uid = unsafe { geteuid() }; + let gid = unsafe { getegid() }; + assert_eq!(cred_a.uid, uid); + assert_eq!(cred_a.gid, gid); +} |
