Skip to content

Commit 7c20be3

Browse files
author
Joe Ellis
committed
Move Unix peer credentials tests to their own file
1 parent 40a8303 commit 7c20be3

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

library/std/src/sys/unix/ext/ucred.rs

-20
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,3 @@ pub mod impl_bsd {
8989
}
9090
}
9191
}
92-
93-
#[cfg(test)]
94-
mod test {
95-
use crate::os::unix::net::UnixStream;
96-
use libc::{getegid, geteuid};
97-
98-
#[test]
99-
fn test_socket_pair() {
100-
// Create two connected sockets and get their peer credentials. They should be equal.
101-
let (sock_a, sock_b) = UnixStream::pair().unwrap();
102-
let (cred_a, cred_b) = (sock_a.peer_cred().unwrap(), sock_b.peer_cred().unwrap());
103-
assert_eq!(cred_a, cred_b);
104-
105-
// Check that the UID and GIDs match up.
106-
let uid = unsafe { geteuid() };
107-
let gid = unsafe { getegid() };
108-
assert_eq!(cred_a.uid, uid);
109-
assert_eq!(cred_a.gid, gid);
110-
}
111-
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use crate::os::unix::net::UnixStream;
2+
use libc::{getegid, geteuid};
3+
4+
#[test]
5+
fn test_socket_pair() {
6+
// Create two connected sockets and get their peer credentials. They should be equal.
7+
let (sock_a, sock_b) = UnixStream::pair().unwrap();
8+
let (cred_a, cred_b) = (sock_a.peer_cred().unwrap(), sock_b.peer_cred().unwrap());
9+
assert_eq!(cred_a, cred_b);
10+
11+
// Check that the UID and GIDs match up.
12+
let uid = unsafe { geteuid() };
13+
let gid = unsafe { getegid() };
14+
assert_eq!(cred_a.uid, uid);
15+
assert_eq!(cred_a.gid, gid);
16+
}

0 commit comments

Comments
 (0)