summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-25 22:48:39 -0600
committerSean Kurtz <seankurtz75@gmail.com>2026-11-25 22:48:39 -0600
commit33dbb6057513fc8ba498b7cc05b9e5ccfea5fb58 (patch)
tree5cb3e1283292b1eb65687d19136274dc84c30b80
parent986d03c57f5a55cde1f4e6af0418a5d9e062a689 (diff)
downloadztop-33dbb6057513fc8ba498b7cc05b9e5ccfea5fb58.tar.gz
ztop: PVT has an unallocated pass, so it gets a total and a percent
Only CSA and PVT are asked for unallocated blocks; SQA and LSQA keep the dash, because their totals are not knowable this way.
-rw-r--r--src/ztop.c9
-rw-r--r--tests/__pycache__/screen.cpython-315-pytest-9.1.1.pycbin4249 -> 4406 bytes
-rw-r--r--tests/screen.py14
3 files changed, 18 insertions, 5 deletions
diff --git a/src/ztop.c b/src/ztop.c
index 8b260fc..31039c2 100644
--- a/src/ztop.c
+++ b/src/ztop.c
@@ -163,10 +163,15 @@ static bool collect_area(struct vsm_info *v, int area, bool dump) {
}
/** @brief Fraction of the mapped area in use, or -1 when there is no total. */
+/* Only CSA and PVT get an unallocated pass, so only they have a total. */
+static bool has_total(const struct vsm_info *v) {
+ return (v->area == VSM_CSA || v->area == VSM_PVT) && v->unalloc_valid;
+}
+
static int pct(const struct vsm_info *v) {
uint64_t total;
- if (!v->unalloc_valid || v->area != VSM_CSA)
+ if (!has_total(v))
return -1;
total = v->foot + v->unalloc;
if (total == 0)
@@ -582,7 +587,7 @@ static void draw_storage(struct tui *t, struct app *a) {
human(v->used, used, sizeof used);
human(v->free, freed, sizeof freed);
human(v->foot, mapped, sizeof mapped);
- if (v->area == VSM_CSA && v->unalloc_valid) {
+ if (has_total(v)) {
human(v->foot + v->unalloc, total, sizeof total);
(void)snprintf(pcbuf, sizeof pcbuf, "use %d%%", p);
} else {
diff --git a/tests/__pycache__/screen.cpython-315-pytest-9.1.1.pyc b/tests/__pycache__/screen.cpython-315-pytest-9.1.1.pyc
index d01c573..ff0f12c 100644
--- a/tests/__pycache__/screen.cpython-315-pytest-9.1.1.pyc
+++ b/tests/__pycache__/screen.cpython-315-pytest-9.1.1.pyc
Binary files differ
diff --git a/tests/screen.py b/tests/screen.py
index adc4914..844ec7f 100644
--- a/tests/screen.py
+++ b/tests/screen.py
@@ -7,7 +7,14 @@ The pty is 100x30; every key is followed by a snapshot of the screen as
the escapes would leave it. No termios is touched, so the program sees a
plain pty and uses its own raw mode.
"""
-import fcntl, os, pty, select, struct, termios, time
+import fcntl
+import os
+import pty
+import select
+import struct
+import sys
+import termios
+import time
W, H = 100, 30
grid = [[' '] * W for _ in range(H)]
@@ -51,7 +58,8 @@ def feed(data):
pid, fd = pty.fork()
if pid == 0:
os.environ['TERM'] = 'xterm'
- os.execv('./ztop', ['./ztop', '-d', '60'])
+ prog = sys.argv[1] if len(sys.argv) > 1 else './ztop'
+ os.execv(prog, [prog, '-d', '60']) # noqa: S606 - exec is the point
fcntl.ioctl(fd, termios.TIOCSWINSZ, struct.pack('HHHH', H, W, 0, 0))
@@ -70,7 +78,7 @@ def pump(t):
feed(d)
pump(2.0)
-for k in [b'1', b'2', b'4', b'\t', b'?', b'?', b'q']:
+for k in [b'\t', b'\t', b'\t', b'\t', b'?', b'?', b'q']:
os.write(fd, k)
pump(1.0)
print('=== after', k)