summaryrefslogtreecommitdiff
path: root/internal/tui/eventstream/render_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-26 10:37:40 +0200
committerPaul Buetow <paul@buetow.org>2026-02-26 10:37:40 +0200
commit4302cbf28a9d9efd2416ab6ea95168f9e39c29ec (patch)
tree90e4dfb2f9cc71e483396c3465859d1282282348 /internal/tui/eventstream/render_test.go
parentc661b23f2940e07a1e1cbe16334598d999096f27 (diff)
tui: add fd trace drilldown and fd column in stream
Diffstat (limited to 'internal/tui/eventstream/render_test.go')
-rw-r--r--internal/tui/eventstream/render_test.go24
1 files changed, 22 insertions, 2 deletions
diff --git a/internal/tui/eventstream/render_test.go b/internal/tui/eventstream/render_test.go
index 8c2d39a..33e5b38 100644
--- a/internal/tui/eventstream/render_test.go
+++ b/internal/tui/eventstream/render_test.go
@@ -34,6 +34,14 @@ func TestRenderPausedAndErrorRow(t *testing.T) {
}
}
+func TestRenderShowsFDWhenPresent(t *testing.T) {
+ events := []StreamEvent{{Syscall: "read", Comm: "worker", PID: 1, TID: 2, FD: 9, DurationNs: 10, GapNs: 1, Bytes: 8, FileName: "/tmp/b", RetVal: 8}}
+ out := RenderStreamTable(120, false, 1, 1, 1, 10000, Filter{}, events, -1)
+ if !strings.Contains(out, "FD") || !strings.Contains(out, " 9 ") {
+ t.Fatalf("expected FD column/value in output\n%s", out)
+ }
+}
+
func TestRenderHeaderAndTruncate(t *testing.T) {
events := []StreamEvent{{
Syscall: "very_long_syscall_name",
@@ -48,7 +56,7 @@ func TestRenderHeaderAndTruncate(t *testing.T) {
}}
out := RenderStreamTable(80, false, 1, 1, 1, 10000, Filter{}, events, -1)
- for _, col := range []string{"Gap", "Latency", "Comm", "PID.TID", "Syscall", "Ret", "Bytes", "File"} {
+ for _, col := range []string{"Gap", "Latency", "Comm", "PID.TID", "Syscall", "FD", "Ret", "Bytes", "File"} {
if !strings.Contains(out, col) {
t.Fatalf("missing column %q\n%s", col, out)
}
@@ -98,7 +106,7 @@ func TestRenderEventRowIsSingleLineWithControlCharsAndLongValues(t *testing.T) {
func TestComputeColumnLayoutGivesFileMoreSpace(t *testing.T) {
cols := computeColumnLayout(120)
- if cols.file < 55 {
+ if cols.file < 50 {
t.Fatalf("expected file column to get most width, got %d", cols.file)
}
}
@@ -124,3 +132,15 @@ func TestRenderStreamTableFitsRequestedWidth(t *testing.T) {
}
}
}
+
+func TestRenderFDTraceTableShowsHeaderAndScope(t *testing.T) {
+ out := RenderFDTraceTable(100, 123, 7, 2, []StreamEvent{
+ {Syscall: "read", PID: 123, TID: 1, FD: 7, FileName: "/tmp/a"},
+ {Syscall: "write", PID: 123, TID: 2, FD: 7, FileName: "/tmp/a"},
+ })
+ for _, want := range []string{"FD Trace (ring snapshot)", "PID:123 FD:7 matched:2", "read", "write"} {
+ if !strings.Contains(out, want) {
+ t.Fatalf("output missing %q\n%s", want, out)
+ }
+ }
+}