diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-05 23:34:45 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-05 23:34:45 +0200 |
| commit | b48fb545191be25e9795e79336c45c439466986c (patch) | |
| tree | 95abc9564e44e6763247ebbf8e5b36e6ba0ee896 /internal/ior_mode_test.go | |
| parent | 33dbb917be1e30d3de9640bec18d0c619a1a7f67 (diff) | |
Enable TUI-mode pprof artifacts and trace capture
Diffstat (limited to 'internal/ior_mode_test.go')
| -rw-r--r-- | internal/ior_mode_test.go | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/internal/ior_mode_test.go b/internal/ior_mode_test.go index bbca555..d509cf2 100644 --- a/internal/ior_mode_test.go +++ b/internal/ior_mode_test.go @@ -31,8 +31,8 @@ func TestShouldRunTraceMode(t *testing.T) { withPprof := base withPprof.PprofEnable = true - if !shouldRunTraceMode(withPprof) { - t.Fatalf("expected pprof mode to use trace mode") + if shouldRunTraceMode(withPprof) { + t.Fatalf("expected pprof flag alone to keep TUI mode") } withLive := base @@ -62,8 +62,8 @@ func TestShouldAutoStopByDuration(t *testing.T) { withPprof := base withPprof.PprofEnable = true - if !shouldAutoStopByDuration(withPprof) { - t.Fatalf("expected pprof mode to auto-stop by duration") + if shouldAutoStopByDuration(withPprof) { + t.Fatalf("expected pprof flag alone not to auto-stop by duration") } withLive := base @@ -104,6 +104,37 @@ func TestDispatchRunUsesTraceModeWhenRequested(t *testing.T) { } } +func TestDispatchRunUsesTUIWhenOnlyPprofEnabled(t *testing.T) { + origRunTrace := runTraceFn + origRunTUI := runTUIFn + defer func() { + runTraceFn = origRunTrace + runTUIFn = origRunTUI + }() + + traceCalled := false + tuiCalled := false + runTraceFn = func() error { + traceCalled = true + return nil + } + runTUIFn = func(tui.TraceStarter) error { + tuiCalled = true + return nil + } + + cfg := flags.Flags{PprofEnable: true} + if err := dispatchRun(cfg); err != nil { + t.Fatalf("dispatchRun returned error: %v", err) + } + if traceCalled { + t.Fatalf("did not expect runTraceFn when only -pprof is enabled") + } + if !tuiCalled { + t.Fatalf("expected runTUIFn to be called") + } +} + func TestDispatchRunUsesTUIStarterWhenNotPlain(t *testing.T) { origRunTraceWithContext := runTraceWithContextFn origRunTUI := runTUIFn @@ -220,6 +251,24 @@ func TestTuiTraceStarterFromRunTracePropagatesError(t *testing.T) { } } +func TestProfilingFilesForMode(t *testing.T) { + cpu, mem, execTrace, duration := profilingFilesForMode(false) + if cpu != "ior.cpuprofile" || mem != "ior.memprofile" { + t.Fatalf("unexpected trace-mode profiling file names: cpu=%q mem=%q", cpu, mem) + } + if execTrace != "" || duration != 0 { + t.Fatalf("expected trace-mode execution tracing to be disabled, got trace=%q duration=%s", execTrace, duration) + } + + cpu, mem, execTrace, duration = profilingFilesForMode(true) + if cpu != "ior-tui-cpu.prof" || mem != "ior-tui-mem.prof" || execTrace != "ior-tui-trace.out" { + t.Fatalf("unexpected TUI profiling file names: cpu=%q mem=%q trace=%q", cpu, mem, execTrace) + } + if duration != 10*time.Second { + t.Fatalf("expected 10s TUI execution trace duration, got %s", duration) + } +} + func TestTuiTraceStarterFromRunTraceRespectsCancel(t *testing.T) { starter := tuiTraceStarterFromRunTrace( func(ctx context.Context, _ chan<- struct{}, _ func(*eventLoop)) error { |
