From f822a250f9b2759207d64cc53b3d80c0c08d2082 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 16 Sep 2026 19:23:35 +0200 Subject: feat: add /proc and /sys parsers with fixture tests Parsers take file contents as a string, not a path, so they test against committed fixtures with no filesystem mocking. hwmon is globbed by its name file rather than a fixed index, carried over from the old config: indices drift across kernel reorders and a stale one silently reads a different chip. Failure returns nil, never 0. A sensor reading 0 C is legitimate, so 0 cannot double as an error value. Co-Authored-By: Claude Opus 5 --- test/fixtures/proc_meminfo | 7 +++++++ test/fixtures/proc_stat | 5 +++++ test/fixtures/temp1_input | 1 + 3 files changed, 13 insertions(+) create mode 100644 test/fixtures/proc_meminfo create mode 100644 test/fixtures/proc_stat create mode 100644 test/fixtures/temp1_input (limited to 'test/fixtures') diff --git a/test/fixtures/proc_meminfo b/test/fixtures/proc_meminfo new file mode 100644 index 0000000..9c279aa --- /dev/null +++ b/test/fixtures/proc_meminfo @@ -0,0 +1,7 @@ +MemTotal: 31943076 kB +MemFree: 4291244 kB +MemAvailable: 25627088 kB +Buffers: 123456 kB +Cached: 6789012 kB +SwapTotal: 8388604 kB +SwapFree: 8388604 kB diff --git a/test/fixtures/proc_stat b/test/fixtures/proc_stat new file mode 100644 index 0000000..2914cca --- /dev/null +++ b/test/fixtures/proc_stat @@ -0,0 +1,5 @@ +cpu 209094 2199 135469 11604898 24408 0 946 0 0 0 +cpu0 5294 11 2928 740049 460 0 592 0 0 0 +cpu1 5210 18 2801 740512 431 0 12 0 0 0 +intr 12345678 +ctxt 987654321 diff --git a/test/fixtures/temp1_input b/test/fixtures/temp1_input new file mode 100644 index 0000000..46fba94 --- /dev/null +++ b/test/fixtures/temp1_input @@ -0,0 +1 @@ +53125 -- cgit v1.2.3