Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7f221be
feat: use gemini to write tests for python modules
justinbarclay Oct 24, 2025
5469d92
chore: add test workflow
justinbarclay Oct 23, 2025
ce5cb0e
chore: update contributing on running tests
justinbarclay Oct 24, 2025
774bd81
test: add test for cli
justinbarclay Oct 24, 2025
44e0c74
test: add comprehensive tests for proc_stats module
justinbarclay Oct 24, 2025
7e12f46
chore: Add debug prints and refine proc stats test
justinbarclay Oct 24, 2025
1a1cfe3
refactor: Extract helper functions from parse_status
justinbarclay Oct 24, 2025
4aa10be
refactor: tests to handle new structure in proc_stats
justinbarclay Oct 24, 2025
20b01fe
chore: update gitignore pyc
justinbarclay Oct 24, 2025
93b6228
fix: Refactor proc_stats module control flow to prevent UnboundLocalE…
justinbarclay Oct 24, 2025
bf1eb78
chore: fix potential divide by zero bug
justinbarclay Oct 24, 2025
4a182d8
tests: enhance and expand the test coverage
justinbarclay Oct 24, 2025
9e8a296
chore: fix bug where a timeout of 1 results in only running once
justinbarclay Oct 24, 2025
502702d
clarify and add tests
justinbarclay Oct 24, 2025
6f69186
fix: bug where module.exit_json doesn't return
justinbarclay Oct 24, 2025
09c1548
fix: assign result after after successful calculation.
justinbarclay Oct 24, 2025
30eea3d
test: Add test_main to verify main function setup with mocks
justinbarclay Oct 24, 2025
e42a9cd
fix: Correctly mock open context manager and assert call in test_main
justinbarclay Oct 24, 2025
077d265
fix: workflow triggers
justinbarclay Oct 24, 2025
6197cf4
chore: fix lints
justinbarclay Oct 24, 2025
fa0fb85
remove: pointless cli tests
justinbarclay Oct 24, 2025
a054956
chore: fix python flake integration
justinbarclay Oct 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions unix/src/machine_stats/modules/cpu_utilization.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def cpu_utilization(timeout):
idle, total = get_perf()
idle_delta, total_delta = idle - last_idle, total - last_total
last_idle, last_total = idle, total
utilisation = 100.0 * (1.0 - idle_delta / total_delta)
if total_delta == 0:
utilisation = 0.0
else:
utilisation = 100.0 * (1.0 - idle_delta / total_delta)
cpu_stats.append(utilisation)
total_runs += 1
sleep(1)
Expand All @@ -99,7 +102,10 @@ def cpu_utilization_value(timeout):
sleep(timeout)
idle, total = get_perf()
idle_delta, total_delta = idle - last_idle, total - last_total
utilization = 100.0 * (1.0 - idle_delta / total_delta)
if total_delta == 0:
utilization = 0.0
else:
utilization = 100.0 * (1.0 - idle_delta / total_delta)

return utilization, rtc_date, rtc_time

Expand Down