File: tweak-tests.diff

package info (click to toggle)
rust-procfs 0.17.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 664 kB
  • sloc: makefile: 2
file content (191 lines) | stat: -rw-r--r-- 7,079 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
--- a/src/process/tests.rs
+++ b/src/process/tests.rs
@@ -51,7 +51,7 @@
     println!("tty: {:?}", myself.tty_nr());
     println!("flags: {:?}", myself.flags());
 
-    #[cfg(feature = "chrono")]
+    #[cfg(feature = "default")]
     println!("starttime: {:#?}", myself.starttime().get());
 
     let kernel = KernelVersion::current().unwrap();
@@ -122,6 +122,7 @@
 }
 
 #[test]
+#[ignore = "flaky, see https://github.com/eminence/procfs/issues/332"]
 fn test_all() {
     let is_wsl2 = KernelConfig::current()
         .ok()
@@ -145,7 +146,7 @@
         println!("{} {}", prc.pid(), stat.comm);
         stat.flags().unwrap();
         stat.state().unwrap();
-        #[cfg(feature = "chrono")]
+        #[cfg(feature = "default")]
         stat.starttime().get().unwrap();
 
         // if this process is defunct/zombie, don't try to read any of the below data
@@ -342,6 +343,7 @@
 }
 
 #[test]
+#[ignore = "flaky, see https://github.com/eminence/procfs/issues/332"]
 fn test_proc_fd_count_runsinglethread() {
     let myself = Process::myself().unwrap();
 
@@ -385,6 +387,8 @@
 
 #[test]
 fn test_proc_auxv() {
+    use std::convert::TryInto;
+
     let myself = Process::myself().unwrap();
     let auxv = myself.auxv().unwrap();
     println!("{:?}", auxv);
@@ -414,15 +418,15 @@
             }
             12 => {
                 println!("Effective UID: {}", v);
-                assert!(v > 0);
+                assert_eq!(v as u32, rustix::process::geteuid().as_raw());
             }
             13 => {
                 println!("Real GID: {}", v);
-                assert!(v > 0);
+                assert_eq!(v as u32, rustix::process::getgid().as_raw());
             }
             14 => {
                 println!("Effective GID: {}", v);
-                assert!(v > 0);
+                assert_eq!(v as u32, rustix::process::getegid().as_raw());
             }
             15 => {
                 println!("Platform string address: 0x{:x}", v);
@@ -458,7 +462,7 @@
         if k != 16 {
             // for reasons i do not understand, getauxval(AT_HWCAP) doesn't return the expected
             // value
-            assert_eq!(v, unsafe { libc::getauxval(k) });
+            assert_eq!(v, unsafe { libc::getauxval(k.try_into().unwrap()).into() });
         }
     }
 }
--- a/src/process/task.rs
+++ b/src/process/task.rs
@@ -120,6 +120,7 @@
     use std::sync::{Arc, Barrier};
 
     #[test]
+    #[ignore = "flaky, see https://github.com/eminence/procfs/issues/332"]
     #[cfg(not(tarpaulin))] // this test is unstable under tarpaulin, and i'm yet sure why
                            // When this test runs in CI, run it single-threaded
     fn test_task_runsinglethread() {
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -574,7 +574,11 @@
         assert!(diff <= 1);
 
         let cpuinfo = CpuInfo::current().unwrap();
-        assert_eq!(cpuinfo.num_cores(), stat.cpu_time.len());
+        // Some systems (particularly arm) only have a single entry in /proc/cpuinfo,
+        // despite having Multiple cores.
+        if cpuinfo.num_cores() != 1 {
+            assert_eq!(cpuinfo.num_cores(), stat.cpu_time.len());
+        }
 
         // the sum of each individual CPU should be equal to the total cpu entry
         // note: on big machines with 128 cores, it seems that the differences can be rather high,
@@ -680,8 +684,9 @@
         let info = CpuInfo::current().unwrap();
         println!("{:#?}", info.flags(0));
         for num in 0..info.num_cores() {
-            info.model_name(num).unwrap();
-            info.vendor_id(num).unwrap();
+            // Vendor/model information is not availble on all architectures.
+            info.model_name(num);
+            info.vendor_id(num);
             // May not be available on some old kernels:
             info.physical_id(num);
         }
@@ -721,6 +726,7 @@
     #[allow(clippy::cognitive_complexity)]
     #[allow(clippy::blocks_in_if_conditions)]
     #[test]
+    #[cfg(not(target_arch = "s390x"))]
     fn test_meminfo() {
         // TRAVIS
         // we don't have access to the kernel_config on travis, so skip that test there
@@ -839,7 +845,11 @@
             assert!(meminfo.commit_limit.is_none());
         }
 
-        if kernel >= KernelVersion::new(2, 6, 32)
+        if kernel >= KernelVersion::new(2, 6, 32) && config.is_none() {
+            // the kernel is new enough to support MEMORY_FAILURE, but we were
+            // not able to read the config, so we don't know if it's enabled
+            // or not.
+        } else if kernel >= KernelVersion::new(2, 6, 32)
             && config.as_ref().map_or(
                 std::path::Path::new("/proc/kpagecgroup").exists(),
                 |KernelConfig(cfg)| cfg.contains_key("CONFIG_MEMORY_FAILURE"),
@@ -873,8 +883,11 @@
             assert!(meminfo.shmem_pmd_mapped.is_none());
         }
 
-        if kernel >= KernelVersion::new(3, 1, 0)
-            && config
+        if kernel >= KernelVersion::new(3, 1, 0) && config.is_none() {
+            // the kernel is new enough to support CMA, but we were not
+            // able to read the config, so we don't know if it's enabled
+            // or not.
+        } else if kernel >= KernelVersion::new(3, 1, 0) && config
                 .as_ref()
                 .map_or(true, |KernelConfig(cfg)| cfg.contains_key("CONFIG_CMA"))
         {
@@ -885,7 +898,10 @@
             assert!(meminfo.cma_free.is_none());
         }
 
-        if config
+        if config.is_none() {
+            // we do not know if huge pages are enabled, since we
+            // cannot read the kernel configuration.
+        } else if config
             .as_ref()
             .map_or(true, |KernelConfig(cfg)| cfg.contains_key("CONFIG_HUGETLB_PAGE"))
         {
@@ -898,7 +914,10 @@
             assert!(meminfo.hugepagesize.is_none());
         }
 
-        if kernel >= KernelVersion::new(2, 6, 17)
+        if kernel >= KernelVersion::new(2, 6, 17) && config.is_none() {
+            // we do not know if huge pages are enabled, since we
+            // cannot read the kernel configuration.
+        } else if kernel >= KernelVersion::new(2, 6, 17)
             && config
                 .as_ref()
                 .map_or(true, |KernelConfig(cfg)| cfg.contains_key("CONFIG_HUGETLB_PAGE"))
@@ -908,7 +927,10 @@
             assert!(meminfo.hugepages_rsvd.is_none());
         }
 
-        if kernel >= KernelVersion::new(2, 6, 24)
+        if kernel >= KernelVersion::new(2, 6, 24) && config.is_none() {
+            // we do not know if huge pages are enabled, since we
+            // cannot read the kernel configuration.
+        } else if kernel >= KernelVersion::new(2, 6, 24)
             && config
                 .as_ref()
                 .map_or(true, |KernelConfig(cfg)| cfg.contains_key("CONFIG_HUGETLB_PAGE"))
--- a/src/sys/kernel/random.rs
+++ b/src/sys/kernel/random.rs
@@ -81,6 +81,7 @@
     }
 
     #[test]
+    #[ignore = "wants rw procfs"]
     fn test_write_wakeup_threshold() {
         let old_threshold = read_wakeup_threshold().unwrap();