From b5a7cf591411cfc0f6c6d5cc6f11b1100b9df656 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Mon, 20 Feb 2023 12:04:44 -0500 Subject: [PATCH] Add pt_oc tests and auto-update json (test) fn --- backend/Cargo.toml | 1 + backend/src/settings/steam_deck/oc_limits.rs | 19 ++ pt_oc.json | 193 ++++++++++++------- 3 files changed, 148 insertions(+), 65 deletions(-) diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 364f29d..2deb631 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -37,6 +37,7 @@ decky = ["usdpl-back/decky"] crankshaft = ["usdpl-back/crankshaft"] encrypt = ["usdpl-back/encrypt"] online = ["ureq"] +dev_stuff = [] [profile.release] debug = false diff --git a/backend/src/settings/steam_deck/oc_limits.rs b/backend/src/settings/steam_deck/oc_limits.rs index 3e64bf6..21ca5f1 100644 --- a/backend/src/settings/steam_deck/oc_limits.rs +++ b/backend/src/settings/steam_deck/oc_limits.rs @@ -127,3 +127,22 @@ impl Default for GpuLimits { fn oc_limits_filepath() -> std::path::PathBuf { crate::utility::settings_dir().join(OC_LIMITS_FILEPATH) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn load_pt_oc() { + let mut file = std::fs::File::open("../pt_oc.json").unwrap(); + let settings: OverclockLimits = serde_json::from_reader(&mut file).unwrap(); + assert!(settings.cpus.cpus.len() == 8); + } + + #[cfg(feature = "dev_stuff")] + #[test] + fn emit_default_pt_oc() { + let mut file = std::fs::File::create("../pt_oc.json").unwrap(); + serde_json::to_writer_pretty(&mut file, &OverclockLimits::default()).unwrap(); + } +} diff --git a/pt_oc.json b/pt_oc.json index 36dba50..19665b0 100644 --- a/pt_oc.json +++ b/pt_oc.json @@ -1,68 +1,131 @@ { - "battery": { - "charge_rate": {"min": 250, "max": 2500} - }, - "cpus": { - "cpus": [ - { - "clock_min": {"min": 1400, "max": 3500}, - "clock_max": {"min": 500, "max": 3500}, - "clock_step": 100, - "skip_resume_reclock": false - }, - { - "clock_min": {"min": 1400, "max": 3500}, - "clock_max": {"min": 500, "max": 3500}, - "clock_step": 100, - "skip_resume_reclock": false - }, - { - "clock_min": {"min": 1400, "max": 3500}, - "clock_max": {"min": 500, "max": 3500}, - "clock_step": 100, - "skip_resume_reclock": false - }, - { - "clock_min": {"min": 1400, "max": 3500}, - "clock_max": {"min": 500, "max": 3500}, - "clock_step": 100, - "skip_resume_reclock": false - }, - { - "clock_min": {"min": 1400, "max": 3500}, - "clock_max": {"min": 500, "max": 3500}, - "clock_step": 100, - "skip_resume_reclock": false - }, - { - "clock_min": {"min": 1400, "max": 3500}, - "clock_max": {"min": 500, "max": 3500}, - "clock_step": 100, - "skip_resume_reclock": false - }, - { - "clock_min": {"min": 1400, "max": 3500}, - "clock_max": {"min": 500, "max": 3500}, - "clock_step": 100, - "skip_resume_reclock": false - }, - { - "clock_min": {"min": 1400, "max": 3500}, - "clock_max": {"min": 500, "max": 3500}, - "clock_step": 100, - "skip_resume_reclock": false - } - ], - "global_governors": false - }, - "gpu": { - "fast_ppt": {"min": 1000000, "max": 30000000}, - "slow_ppt": {"min": 1000000, "max": 29000000}, - "ppt_divisor": 1000000, - "ppt_step": 1, - "clock_min": {"min": 200, "max": 1600}, - "clock_max": {"min": 200, "max": 1600}, + "battery": { + "charge_rate": { + "min": 250, + "max": 2500 + } + }, + "cpus": { + "cpus": [ + { + "clock_min": { + "min": 1400, + "max": 3500 + }, + "clock_max": { + "min": 400, + "max": 3500 + }, "clock_step": 100, "skip_resume_reclock": false - } -} + }, + { + "clock_min": { + "min": 1400, + "max": 3500 + }, + "clock_max": { + "min": 400, + "max": 3500 + }, + "clock_step": 100, + "skip_resume_reclock": false + }, + { + "clock_min": { + "min": 1400, + "max": 3500 + }, + "clock_max": { + "min": 400, + "max": 3500 + }, + "clock_step": 100, + "skip_resume_reclock": false + }, + { + "clock_min": { + "min": 1400, + "max": 3500 + }, + "clock_max": { + "min": 400, + "max": 3500 + }, + "clock_step": 100, + "skip_resume_reclock": false + }, + { + "clock_min": { + "min": 1400, + "max": 3500 + }, + "clock_max": { + "min": 400, + "max": 3500 + }, + "clock_step": 100, + "skip_resume_reclock": false + }, + { + "clock_min": { + "min": 1400, + "max": 3500 + }, + "clock_max": { + "min": 400, + "max": 3500 + }, + "clock_step": 100, + "skip_resume_reclock": false + }, + { + "clock_min": { + "min": 1400, + "max": 3500 + }, + "clock_max": { + "min": 400, + "max": 3500 + }, + "clock_step": 100, + "skip_resume_reclock": false + }, + { + "clock_min": { + "min": 1400, + "max": 3500 + }, + "clock_max": { + "min": 400, + "max": 3500 + }, + "clock_step": 100, + "skip_resume_reclock": false + } + ], + "global_governors": false + }, + "gpu": { + "fast_ppt": { + "min": 1000000, + "max": 30000000 + }, + "slow_ppt": { + "min": 1000000, + "max": 29000000 + }, + "ppt_divisor": 1000000, + "ppt_step": 1, + "clock_min": { + "min": 200, + "max": 1600 + }, + "clock_max": { + "min": 200, + "max": 1600 + }, + "clock_step": 100, + "skip_resume_reclock": false + } +} \ No newline at end of file