]> git.proxmox.com Git - rustc.git/blob - vendor/rustix/tests/process/id.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / vendor / rustix / tests / process / id.rs
1 use rustix::process;
2
3 #[test]
4 fn test_getuid() {
5 assert_eq!(process::getuid(), process::getuid());
6 unsafe {
7 assert_eq!(process::getuid().as_raw(), libc::getuid());
8 assert_eq!(process::getuid().is_root(), libc::getuid() == 0);
9 }
10 }
11
12 #[test]
13 fn test_getgid() {
14 assert_eq!(process::getgid(), process::getgid());
15 unsafe {
16 assert_eq!(process::getgid().as_raw(), libc::getgid());
17 assert_eq!(process::getgid().is_root(), libc::getgid() == 0);
18 }
19 }
20
21 #[test]
22 fn test_geteuid() {
23 assert_eq!(process::geteuid(), process::geteuid());
24 unsafe {
25 assert_eq!(process::geteuid().as_raw(), libc::geteuid());
26 assert_eq!(process::geteuid().is_root(), libc::geteuid() == 0);
27 }
28 }
29
30 #[test]
31 fn test_getegid() {
32 assert_eq!(process::getegid(), process::getegid());
33 unsafe {
34 assert_eq!(process::getegid().as_raw(), libc::getegid());
35 assert_eq!(process::getegid().is_root(), libc::getegid() == 0);
36 }
37 }
38
39 #[test]
40 fn test_getpid() {
41 assert_eq!(process::getpid(), process::getpid());
42 unsafe {
43 assert_eq!(
44 process::getpid().as_raw_nonzero().get() as libc::pid_t,
45 libc::getpid()
46 );
47 assert_eq!(process::getpid().is_init(), libc::getpid() == 1);
48 }
49 }
50
51 #[test]
52 fn test_getppid() {
53 assert_eq!(process::getppid(), process::getppid());
54 unsafe {
55 assert_eq!(
56 process::Pid::as_raw(process::getppid()) as libc::pid_t,
57 libc::getppid()
58 );
59 if let Some(ppid) = process::getppid() {
60 assert_eq!(ppid.is_init(), libc::getppid() == 1);
61 } else {
62 assert_eq!(libc::getppid(), 0);
63 }
64 }
65 }