diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-09 18:59:58 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-09 18:59:58 +0100 |
| commit | 84ac47a8ab196ee20ad778219bfa13df48f87241 (patch) | |
| tree | 313118623d690a33674a93213bc4c62f6a6ad157 /tests/test_stats.py | |
| parent | a9d709f6dd893b6fab6750b67f0c4f367458f40c (diff) | |
| download | deck-it-84ac47a8ab196ee20ad778219bfa13df48f87241.tar.gz deck-it-84ac47a8ab196ee20ad778219bfa13df48f87241.zip | |
feat: Intel xe GPU stats (temp, fan, VRAM)
Diffstat (limited to 'tests/test_stats.py')
| -rw-r--r-- | tests/test_stats.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_stats.py b/tests/test_stats.py index fad6cc2..81acdba 100644 --- a/tests/test_stats.py +++ b/tests/test_stats.py @@ -21,5 +21,28 @@ class Stats(unittest.TestCase): self.assertIn("stats", names) +class Intel(unittest.TestCase): + def test_parse_bytes(self): + self.assertEqual(stats._parse_bytes("12G"), 12 * 1024 ** 3) + self.assertEqual(stats._parse_bytes("512M"), 512 * 1024 ** 2) + self.assertEqual(stats._parse_bytes(2048), 2048) + self.assertIsNone(stats._parse_bytes("nope")) + + def test_vram_scan_counts_each_client_once(self): + import tempfile + root = Path(tempfile.mkdtemp()) + rows = [ + ("100", "3", "drm-driver:\txe\ndrm-client-id:\t7\ndrm-resident-vram0:\t1024 MiB\n"), + ("100", "4", "drm-driver:\txe\ndrm-client-id:\t7\ndrm-resident-vram0:\t1024 MiB\n"), + ("200", "5", "drm-driver:\txe\ndrm-client-id:\t8\ndrm-resident-vram0:\t512 MiB\n"), + ("300", "6", "drm-driver:\ti915\ndrm-client-id:\t9\ndrm-resident-vram0:\t999 MiB\n"), + ] + for pid, fd, body in rows: + d = root / pid / "fdinfo" + d.mkdir(parents=True, exist_ok=True) + (d / fd).write_text(body) + self.assertEqual(stats._intel_vram_used(root), (1024 + 512) * 1024 ** 2) + + if __name__ == "__main__": unittest.main() |
