kperf_sys/
lib.rs

1pub mod constants;
2pub mod functions;
3pub mod structs;
4
5#[cfg(test)]
6mod tests {
7    use crate::{constants::*, functions::*, structs::*};
8    use std::ptr::{null, null_mut};
9    const LIBRARY_PATH: &str = "/System/Library/PrivateFrameworks/kperf.framework/kperf";
10
11    #[test]
12    fn test_running_function() {
13        let pmu_version = unsafe { kpc_pmu_version() };
14    }
15
16    #[test]
17    fn test_pmu_version() {
18        let pmu_version = unsafe { kpc_pmu_version() };
19        assert_ne!(
20            pmu_version, 0,
21            "A PMU version of zero means an error, try to run this program in sudo"
22        );
23    }
24
25    #[test]
26    fn test_create_kpep_db() {
27        unsafe {
28            let mut db_ptr: *mut kpep_db = null_mut();
29            // let mut name: &[c_char; 12] = b"test_rust_db";
30            // let name = CStr::from_bytes_until_nul().unwrap();
31            // let name_ptr: *const c_char = name.as_ptr() as *const c_char;
32            let result = kpep_db_create(null(), &mut db_ptr);
33            println!("db creation result: {}", result);
34        }
35    }
36}