summaryrefslogtreecommitdiffstats
path: root/vendor/sysinfo/src/lib.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:21 +0000
commit4e8199b572f2035b7749cba276ece3a26630d23e (patch)
treef09feeed6a0fe39d027b1908aa63ea6b35e4b631 /vendor/sysinfo/src/lib.rs
parentAdding upstream version 1.66.0+dfsg1. (diff)
downloadrustc-4e8199b572f2035b7749cba276ece3a26630d23e.tar.xz
rustc-4e8199b572f2035b7749cba276ece3a26630d23e.zip
Adding upstream version 1.67.1+dfsg1.upstream/1.67.1+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/sysinfo/src/lib.rs')
-rw-r--r--vendor/sysinfo/src/lib.rs50
1 files changed, 47 insertions, 3 deletions
diff --git a/vendor/sysinfo/src/lib.rs b/vendor/sysinfo/src/lib.rs
index 977de23a3..0800d2562 100644
--- a/vendor/sysinfo/src/lib.rs
+++ b/vendor/sysinfo/src/lib.rs
@@ -7,6 +7,7 @@
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::non_send_fields_in_send_ty)]
#![allow(renamed_and_removed_lints)]
+#![allow(clippy::assertions_on_constants)]
#![allow(unknown_lints)]
#[macro_use]
@@ -328,9 +329,10 @@ mod test {
#[test]
fn check_system_info() {
+ let s = System::new();
+
// We don't want to test on unsupported systems.
if System::IS_SUPPORTED {
- let s = System::new();
assert!(!s.name().expect("Failed to get system name").is_empty());
assert!(!s
@@ -345,6 +347,8 @@ mod test {
.expect("Failed to get long OS version")
.is_empty());
}
+
+ assert!(!s.distribution_id().is_empty());
}
#[test]
@@ -429,7 +433,6 @@ mod test {
// Ensure that the CPUs frequency isn't retrieved until we ask for it.
#[test]
- #[cfg(not(target_os = "freebsd"))] // In a VM, it'll fail.
fn check_cpu_frequency() {
if !System::IS_SUPPORTED {
return;
@@ -441,7 +444,48 @@ mod test {
}
s.refresh_cpu();
for proc_ in s.cpus() {
- assert_ne!(proc_.frequency(), 0);
+ assert_eq!(proc_.frequency(), 0);
+ }
+ // In a VM, it'll fail.
+ if std::env::var("APPLE_CI").is_err() && std::env::var("FREEBSD_CI").is_err() {
+ s.refresh_cpu_specifics(CpuRefreshKind::everything());
+ for proc_ in s.cpus() {
+ assert_ne!(proc_.frequency(), 0);
+ }
+ }
+ }
+
+ // In case `Process::updated` is misused, `System::refresh_processes` might remove them
+ // so this test ensures that it doesn't happen.
+ #[test]
+ fn check_refresh_process_update() {
+ if !System::IS_SUPPORTED {
+ return;
}
+ let mut s = System::new_all();
+ let total = s.processes().len() as isize;
+ s.refresh_processes();
+ let new_total = s.processes().len() as isize;
+ // There should be almost no difference in the processes count.
+ assert!(
+ (new_total - total).abs() <= 5,
+ "{} <= 5",
+ (new_total - total).abs()
+ );
+ }
+
+ // We ensure that the `Process` cmd information is retrieved as expected.
+ #[test]
+ fn check_cmd_line() {
+ if !System::IS_SUPPORTED {
+ return;
+ }
+ let mut sys = System::new();
+ sys.refresh_processes_specifics(ProcessRefreshKind::new());
+
+ assert!(sys
+ .processes()
+ .iter()
+ .any(|(_, process)| !process.cmd().is_empty()));
}
}