|
|
@@ -1,6 +1,7 @@
|
|
1
|
1
|
#[cfg(test)]
|
|
2
|
2
|
mod tests {
|
|
3
|
3
|
use pstree::Process;
|
|
|
4
|
+ use pstree::print;
|
|
4
|
5
|
|
|
5
|
6
|
#[test]
|
|
6
|
7
|
#[should_panic]
|
|
|
@@ -20,7 +21,7 @@ mod tests {
|
|
20
|
21
|
|
|
21
|
22
|
#[test]
|
|
22
|
23
|
fn hasparent_yes() {
|
|
23
|
|
-
|
|
|
24
|
+ assert_eq!(true, Process::has_parent(&Process::me()));
|
|
24
|
25
|
}
|
|
25
|
26
|
|
|
26
|
27
|
#[test]
|
|
|
@@ -28,4 +29,37 @@ mod tests {
|
|
28
|
29
|
fn parent_not_existing() {
|
|
29
|
30
|
Process::parent(&Process::new(1));
|
|
30
|
31
|
}
|
|
|
32
|
+
|
|
|
33
|
+ #[test]
|
|
|
34
|
+ fn parent_existing() {
|
|
|
35
|
+ Process::parent(&Process::me());
|
|
|
36
|
+ }
|
|
|
37
|
+
|
|
|
38
|
+ #[test]
|
|
|
39
|
+ fn hasparent_with_pid_not_existing() {
|
|
|
40
|
+ assert_eq!(false, Process::has_parent_with_pid(&Process::me(), -1000));
|
|
|
41
|
+ }
|
|
|
42
|
+
|
|
|
43
|
+ #[test]
|
|
|
44
|
+ fn hasparent_with_pid_existing() {
|
|
|
45
|
+ assert_eq!(true, Process::me().has_parent_with_pid(1));
|
|
|
46
|
+ }
|
|
|
47
|
+
|
|
|
48
|
+ #[test]
|
|
|
49
|
+ fn print_not_existing() {
|
|
|
50
|
+ assert_eq!(false, print(-1000));
|
|
|
51
|
+ }
|
|
|
52
|
+
|
|
|
53
|
+ #[test]
|
|
|
54
|
+ fn print_existing() {
|
|
|
55
|
+ assert_eq!(true, print(1));
|
|
|
56
|
+ }
|
|
|
57
|
+
|
|
|
58
|
+ #[test]
|
|
|
59
|
+ fn print_recursive_existing_pid() {
|
|
|
60
|
+ let prc = Process::new(1);
|
|
|
61
|
+ let mut str = String::new();
|
|
|
62
|
+ prc.print_recursive(1, &mut str);
|
|
|
63
|
+ assert_eq!("systemd(1)", str);
|
|
|
64
|
+ }
|
|
31
|
65
|
}
|