Skip to content

Commit

Permalink
quartz crystal pulse fix and exclude app name
Browse files Browse the repository at this point in the history
  • Loading branch information
Arpan3323 committed Oct 4, 2024
1 parent 3494c84 commit 470d981
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
42 changes: 32 additions & 10 deletions src/system_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,18 @@ pub mod process_data
sys.refresh_all();
for (pid, process)in sys.processes()
{
let curr_proc = Process {
name: process.name().to_string(),
pid: pid.to_owned(),
status: process.status().to_string(),
memory_usage: process.memory() / 1000000,
cpu_usage: process.cpu_usage() / cpu_num,
};
all_procs.push(curr_proc);
if process.name().to_string() != "system-observer" &&
process.name().to_string() != "system_observer"
{
let curr_proc = Process {
name: process.name().to_string(),
pid: pid.to_owned(),
status: process.status().to_string(),
memory_usage: process.memory() / 1000000,
cpu_usage: process.cpu_usage() / cpu_num,
};
all_procs.push(curr_proc);
}
}

//all_procs.sort_by(|a,b|b.cmp(a));
Expand Down Expand Up @@ -101,9 +105,8 @@ pub mod cpu_data
}

//avg
if avg_cpu_util > 0.0 && num_cpu > 0 && avg_freq > 0
if num_cpu > 0 && avg_freq > 0
{
avg_cpu_util /= num_cpu as f32;
avg_freq /= num_cpu as u64;
}

Expand Down Expand Up @@ -173,3 +176,22 @@ pub mod network_data
}

}

#[cfg(test)]
mod tests {
/*
* Happy path tests: starts with 0
* Sad path tests: starts with 1
* Evil path tests: start with 9
*/
#[test]
fn test101_exclude_app_name() {
use crate::system_info::process_data::Processes;
let result = Processes::new();
for proc in result.all_procs
{
assert_ne!(proc.name, "system_observer");
assert_ne!(proc.name, "system-observer");
}
}
}
10 changes: 7 additions & 3 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,18 +406,22 @@ impl <'a> Widget for &'a NetworkScreen

#[cfg(test)]
mod tests {

/*
* Happy path tests: starts with 0
* Sad path tests: starts with 1
* Evil path tests: start with 9
*/
#[test]
fn test001_tab_widget_init() {
use crate::ui::*;
use crate::ui::TabWidget;
let result = TabWidget::new();
assert!(result.tabs.len() == 3, "length TabWidget tabs is incorrect!");
assert!(result.selcted_tab == 0, "TabWidget selected_tab is incorrect!");
}

#[test]
fn test002_cpu_screen_init() {
use crate::ui::*;
use crate::ui::CpuScreen;
let result = CpuScreen::new();
assert!(std::mem::size_of_val(&result) != 0, "CpuScreen data not initializes");
}
Expand Down

0 comments on commit 470d981

Please sign in to comment.