浏览代码

Merge branch 'hw4' of github.com:htwg-syslab-bsys-ws17/bsys-ws17-template into hw4

Joshua Rutschmann 8 年前
父节点
当前提交
2542e9588e
共有 1 个文件被更改,包括 13 次插入9 次删除
  1. 13
    9
      hw4/task1/src/unit_test_readproc.rs

+ 13
- 9
hw4/task1/src/unit_test_readproc.rs 查看文件

1
 #[cfg(test)]
1
 #[cfg(test)]
2
 mod tests {
2
 mod tests {
3
     use procinfo::pid::{status, status_self};
3
     use procinfo::pid::{status, status_self};
4
-    use {self_pids, get_pid_command, get_thread_count, get_ownprocess_mem, get_task_total};
4
+    use {get_ownprocess_mem, get_pid_command, get_task_total, get_thread_count, self_pids};
5
 
5
 
6
 
6
 
7
     fn sol_self_pids() -> (i32, i32) {
7
     fn sol_self_pids() -> (i32, i32) {
11
         }
11
         }
12
     }
12
     }
13
 
13
 
14
+    fn name_of_init() -> String {
15
+        status(1).unwrap().command
16
+    }
17
+
18
+    #[test]
19
+    fn test_name_of_init() {
20
+        let status = status(1).unwrap();
21
+        assert_eq!(name_of_init(), status.command);
22
+    }
23
+
14
     #[test]
24
     #[test]
15
     fn test0_ppid() {
25
     fn test0_ppid() {
16
         assert_eq!(sol_self_pids(), self_pids().unwrap());
26
         assert_eq!(sol_self_pids(), self_pids().unwrap());
26
 
36
 
27
     #[test]
37
     #[test]
28
     fn test2_command() {
38
     fn test2_command() {
29
-        assert_eq!(Ok("systemd".to_string()), get_pid_command(1));
39
+        assert_eq!(Ok(name_of_init()), get_pid_command(1));
30
     }
40
     }
31
 
41
 
32
 
42
 
33
     #[test]
43
     #[test]
34
-    fn test3_systemd_command() {
35
-        let status = status(1).unwrap();
36
-        assert_eq!("systemd".to_string(), status.command);
37
-    }
38
-
39
-    #[test]
40
-    fn test4_systemd_threads() {
44
+    fn test3_systemd_threads() {
41
         let status = status(1).unwrap();
45
         let status = status(1).unwrap();
42
         assert_eq!(get_thread_count(1), Ok(status.threads));
46
         assert_eq!(get_thread_count(1), Ok(status.threads));
43
     }
47
     }

正在加载...
取消
保存