sinf 0.1.0

Library for obtaining in-depth system information at both the hardware and software levels
Documentation
#![cfg(feature = "system")]

mod common;

// This test verifies that CPUs are not loaded by default.
#[test]
fn test_cpu() {
    let Some(mut s) = common::skip_unsupported(sinf::system::System::new()) else {
        return;
    };
    assert!(s.cpus().is_empty());

    s.refresh_cpu_all();
    assert!(!s.cpus().is_empty());

    let Some(s) = common::skip_unsupported(sinf::system::System::new_all()) else {
        return;
    };
    assert!(!s.cpus().is_empty());

    assert!(!s.cpus()[0].brand().chars().any(|c| c == '\0'));

    if !cfg!(target_os = "freebsd") {
        // This information is not currently retrieved on FreeBSD.
        assert!(s.cpus().iter().any(|c| !c.brand().is_empty()));
    }
    assert!(s.cpus().iter().any(|c| !c.vendor_id().is_empty()));
}

#[test]
fn test_physical_core_numbers() {
    if sinf::system::System::new().is_ok() {
        let count = sinf::system::System::physical_core_count();
        assert!(count.is_ok());
        assert!(count.unwrap() > 0);
    }
}

#[test]
fn test_too_rapid_cpu_refresh() {
    let Ok(mut s) = sinf::system::System::new() else {
        return;
    };
    assert!(s.cpus().is_empty());

    s.refresh_cpu_all();
    s.refresh_cpu_all();

    assert!(s.cpus().iter().any(|c| !c.usage().is_nan()));
}