The Kurgan 1.0.0: one process for the LCD, fans, lighting, local LLM servers and the web UI
This commit is contained in:
commit
f631386618
71 files changed
+14616
No files matched your search
@@ -0,0 +1,80 @@
|
||||
import unittest
|
||||
from unittest.mock import Mock
|
||||
|
||||
from kurgan.cooling import control
|
||||
from kurgan.cooling.board_fans import Nct6687
|
||||
from kurgan.cooling.control import CaseFanControl, TopFanCurve
|
||||
from kurgan.cooling.profiles import BALANCED, FULL, PERFORMANCE, PROFILES, QUIET, validate_curve
|
||||
|
||||
|
||||
class ProfileTest(unittest.TestCase):
|
||||
def test_balanced_keeps_the_original_curves(self):
|
||||
self.assertEqual(control.CURVE, ((40, 40), (50, 50), (60, 65), (70, 100)))
|
||||
self.assertEqual(control.CPU_CURVE, ((50, 40), (60, 50), (70, 65), (80, 100)))
|
||||
self.assertEqual((control.TOP_START, control.TOP_STOP), (50, 45))
|
||||
self.assertEqual(list(PROFILES), ["quiet", "balanced", "performance", "full"])
|
||||
|
||||
def test_profiles_are_ordered_quiet_to_full_at_every_temperature(self):
|
||||
for temp in range(0, 111, 5):
|
||||
for side in ("gpu_curve", "cpu_curve", "top_curve"):
|
||||
duties = [control._curve_duty(getattr(p, side), temp) for p in (QUIET, BALANCED, PERFORMANCE, FULL)]
|
||||
with self.subTest(temp=temp, side=side):
|
||||
self.assertEqual(duties, sorted(duties))
|
||||
|
||||
def test_invalid_curves_are_rejected(self):
|
||||
for curve in (((50, 100),), ((50, 40), (50, 100)), ((40, 60), (60, 50), (70, 100)),
|
||||
((40, 40), (60, 90)), ((-5, 40), (60, 100))):
|
||||
with self.subTest(curve=curve), self.assertRaises(ValueError):
|
||||
validate_curve(curve)
|
||||
|
||||
|
||||
class ProfileSwitchTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.commander = Mock()
|
||||
self.commander.set_duty.side_effect = lambda ports, duty: {p: 1200 for p in ports}
|
||||
board = Mock(spec=Nct6687)
|
||||
board.manual_mask.return_value = 0x24
|
||||
self.top = TopFanCurve((2, 5), board_factory=lambda: board)
|
||||
self.fans = CaseFanControl(self.commander, (4, 5, 6), (1, 2, 3), top=self.top, profile=BALANCED)
|
||||
self.now = 0.0
|
||||
|
||||
def run_for(self, seconds, gpu=60.0, cpu=60.0):
|
||||
for _ in range(seconds):
|
||||
self.now += 1
|
||||
self.fans.update(gpu, self.now, cpu)
|
||||
|
||||
def test_rises_apply_at_once_and_falls_ramp_down(self):
|
||||
self.run_for(40)
|
||||
self.assertEqual((self.fans.gpu.duty, self.fans.cpu.duty), (65, 50))
|
||||
self.fans.apply_profile(PERFORMANCE)
|
||||
self.run_for(1)
|
||||
self.assertEqual((self.fans.gpu.duty, self.fans.cpu.duty), (90, 70))
|
||||
self.fans.apply_profile(QUIET)
|
||||
self.run_for(9)
|
||||
self.assertEqual(self.fans.gpu.duty, 90) # held 10 s after the last rise
|
||||
self.run_for(30)
|
||||
self.assertEqual((self.fans.gpu.duty, self.fans.cpu.duty), (55, 40))
|
||||
|
||||
def test_top_fans_take_the_profile_start_temperature(self):
|
||||
self.fans.apply_profile(QUIET)
|
||||
self.run_for(90, gpu=45, cpu=40) # start-up boost, ramp-down, then 30 s below Quiet's 50 C stop
|
||||
self.assertFalse(self.top.running)
|
||||
self.fans.apply_profile(PERFORMANCE) # starts the top fans at 45 C
|
||||
self.run_for(1, gpu=45, cpu=40)
|
||||
self.assertTrue(self.top.running)
|
||||
self.fans.apply_profile(FULL)
|
||||
self.run_for(1, gpu=30, cpu=30)
|
||||
self.assertEqual((self.fans.gpu.duty, self.fans.cpu.duty, self.top.duty), (100, 100, 100))
|
||||
|
||||
def test_snapshot_names_the_profile_and_each_group(self):
|
||||
self.run_for(1)
|
||||
self.fans.apply_profile(PERFORMANCE)
|
||||
snap = self.fans.snapshot()
|
||||
self.assertEqual(snap["profile"], "performance")
|
||||
self.assertEqual([g["name"] for g in snap["groups"]], ["GPU", "CPU"])
|
||||
self.assertEqual(snap["groups"][0]["rpms"], {"4": 1200, "5": 1200, "6": 1200})
|
||||
self.assertEqual(snap["top"]["channels"], [2, 5])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user