VIEWALYZER · HEADLESS CLI
Documentation
VIEWALYZER · CLI & AUTOMATION

Regression tests in CI

A trace is a measurement, so a build can be gated on it: capture the firmware on a bench runner, compare the recording against a committed baseline, fail the job when the timing, the CPU load or the health counters move. The pieces are query fingerprint, query compare, and exit codes a job runner understands.

Fingerprints

A baseline is the reference you compare against. It can be a fingerprint from one run or an envelope learned from several runs. Both are a single .vafp.json file containing metrics, tolerances and compatibility rules, and both can be loaded by the GUI, CLI or SDK. --runs reads saved recordings; it does not start or schedule captures.

A fingerprint is a small, git-committable .vafp.json distilled from a recording: selected metrics with per-metric tolerances plus capture provenance and compatibility rules. Counts are normalised to per-second rates so runs of different length compare fairly.

$ viewalyzer-cli query fingerprint --recording good.vadb --out app.vafp.json
{"schema_version":3,"recording_id":"328d49aa4eb6","query":"fingerprint","out":"app.vafp.json","runs":1,"sections":["comms","health","summary","tasks","timers","traces"]}

$ viewalyzer-cli query fingerprint --recording good1.vadb --runs good2.vadb,good3.vadb --out app.vafp.json    # learn an envelope from several good runs
FLAG MEANING
--runs a,bExtra recordings merged into the envelope: value = mean, min and max = the observed range
--sections summary,tasks,traces,timers,comms,healthRestrict the sections (default: all)
--tolerance-pct nDefault relative FAIL threshold per metric (25)
--warn-pct nDefault relative WARN threshold (80% of the fail threshold)
--out f.vafp.jsonWrite the fingerprint (pretty JSON, hand-editable)
--require-provenance field,...Require known, equal values for these provenance fields
--ignore-provenance field,...Explicitly permit differences or missing values for these fields

Measurements versus recording settings

These are separate choices. --sections chooses what behavior to judge. --ignore-provenance chooses which recording settings may differ.

  • --sections summary,traces,health excludes per-task metrics. Summary's CPU load and task count are still selected.
  • --ignore-provenance trace_categories permits category settings to differ. It does not exclude task metrics or switch task tracing off on the device.
  • A GUI baseline keeps its selected metrics and provenance rules when used here. Ignoring the Tasks category switch does not undo checked Tasks metrics.
  • Strict integrity checks still apply even when health metrics are excluded or provenance fields are ignored.

Compatibility rules

New fingerprints use file schema_version: 2 (separate from CLI envelope schema 3 and metric_semantics: 2). Each baseline saves a compatibility.fields map containing require or ignore for every field:

FIELD MEANING DEFAULT
osRecorded RTOS namerequire
cpu_hzRecorder timestamp clock in Hzrequire
capture_sourceRecorded source label, such as stlink-rambuf, recorder or pollrequire
trace_categoriesRecorder trace-category maskrequire when available in baseline
build_flagsRecorder build flagsrequire when available in baseline
recorder_versionRecorder version identifierignore

Missing, unknown or mixed required values never count as a match. Ignored values remain visible in the report, including both baseline and current observations. Ignoring all fields is allowed but reported as unchecked: it makes no claim that the configurations match. Rules apply in every comparison of a schema-2 or schema-3 baseline, even without --ci.

The GUI can also set individual category/build-flag rules. Such fingerprints use file schema_version: 3 and an optional compatibility.ignored_bits map, whose keys are trace_categories or build_flags and whose unsigned 32-bit values identify bits excluded from comparison. The field itself must remain require; all other bits, including unknown future bits, must match. To ignore the entire field, use its ignore rule and omit its mask. Masks cannot be stored in schema 2, preventing older readers from silently ignoring these exceptions. Ordinary authoring without per-option rules continues to emit schema 2. Removing the last per-option exception restores schema 2. Switching from Ignore all to individual rules retains exceptions for the named options; unrecognized future bits become required until explicitly ignored.

Both comparators use the same saved rules. Reports retain raw observations and add baseline_display, current_display, ignored_bits, and named bits rows with each option's rule, status and recorded states. An envelope with mixed ignored bits retains all provenance_variants. The required bits must be known and consistent across those observations; requiring a previously mixed option makes the envelope incomparable. None of these rules bypass strict measurement integrity checks.

For example, to allow an intentional timestamp-clock change:

viewalyzer-cli query fingerprint --recording good.vadb --ignore-provenance cpu_hz --out app.vafp.json
viewalyzer-cli query compare --recording candidate.vadb --baseline app.vafp.json --ci

Choose exceptions when authoring or reviewing the baseline. Comparison does not accept overrides that bypass its saved rules. The GUI's Provenance rules controls write the same policy; Save baseline copy... preserves the loaded baseline's observations and metrics while saving your edits. Merged runs must have the same policy and equal required provenance. Different ignored values are retained in provenance_variants, with the corresponding value marked unknown so it cannot later be mistaken for a single matching value.

This validates recorded metadata, not independent hardware identity or the entire firmware configuration. cpu_hz is the trace timebase, which may differ from the core clock. capture_source may name the transport, but generic recorder labels do not; it does not identify a probe or board. Recorder build flags do not encode every RTOS setting. Board, workload, full RTOS configuration and build identity checks remain the harness's responsibility when they are not represented in the recording.

Sections: summary (cpu_load_percent, events_per_second, context_switches_hz, preemptions_hz, exact total_tasks and trace_channels, heap scalars), tasks (per lane: cpu_percent, run_hz, avg_run_us, mean_switch_in_interval_us, max_switch_in_interval_deviation_us, preemption_hz, exact base_priority, stack, sync-op and failed_ops_hz), traces (per channel: rate_hz, mean_value, rms, std_dev, advisory min and max), timers (measured fires_hz or advisory predicted_fires_hz; advisory nominal schedule offsets when observable), comms (per path: rate_hz, median_us, p99_us, blocked_hz; per resource: peak_pending, still_pending, empty_receives_hz), health (corrupt_bytes, corrupt_runs, lost_events, seq_gaps: baselines are normally 0, so any loss fails).

The file is meant to be edited: change a metric's tol_pct or warn_pct, set abs_tol or abs_warn directly, delete items you do not want pinned.

Fingerprints carry metric_semantics: 2. Rebuild older baselines from new recordings so they use the same CPU, stack, timer and percentile definitions. Missing values are never replaced with zero. Unknown base priority remains an explicit metric with value, min, max set to null, runs: 0 and an unmeasured reason. When some mutex waits cannot be classified, inversions_hz retains the confirmed rate with a lower_bound reason. A lower bound can fail an upper limit that it already exceeds; otherwise it warns because the complete rate is unknown. Unmeasured values and lower bounds do not contribute to learned numeric envelopes. priority_comparisons_undetermined_hz measures coverage and is advisory. Allocation failures use heap_failed_allocs_hz even when heap usage is unavailable. Merging envelopes weights each metric by its own observed run count. Different units, exact values, tolerance definitions or required capture provenance cannot be merged. Duplicate object names are retained with identity suffixes. Selected ambiguous objects fail comparison because their identities cannot be matched reliably across runs; unrelated objects and sections remain comparable. GUI exclusions are saved in excluded_metrics as [section, item, metric] entries, excluded_items as [section, item], and excluded_sections as section names. Group exclusions apply to metrics added in later runs too. Merge requires matching selections. Excluded metrics and unselected sections do not produce new-metric warnings. A metric absent from some baseline runs warns when absent again. Zero-duration runs omit rates; user-function lanes omit CPU share. Base priority excludes temporary priority-inheritance boosts and becomes unknown after lost events.

Compare

$ viewalyzer-cli query compare --recording candidate.vadb --baseline app.vafp.json --ci
{"schema_version":3,"recording_id":"bf37d1669b82","query":"compare","baseline":"app.vafp.json","verdict":"pass",
 "counts":{"pass":47,"warn":0,"fail":0,"missing":0,"new":0},"provenance_warnings":[],"baseline_runs":1,
 "results":[{"section":"summary","item":"_","metric":"context_switches_hz","status":"pass","current":2871.79,"baseline":2871.74,"min":2871.74,"max":2871.74,"delta_outside":0.04,"abs_warn":574.35,"abs_tol":717.94,"unit":"hz"},
            {"section":"health","item":"_","metric":"lost_events","status":"pass","current":0.0,"baseline":0.0,"min":0.0,"max":0.0,"unit":"count"}, ...]}

A metric passes inside the baseline's [min, max] envelope or within its warn band, warns up to the fail band, fails beyond; exact metrics must match. A baseline item or metric missing from the run is missing (fail); an item or metric the baseline never saw is new (warn). metric_verdict and counts describe metric results independently of compatibility. compatibility explains each provenance rule; required mismatches or missing values make the overall verdict incomparable. Results are sorted fail, missing, warn, new, pass.

--ci additionally rejects legacy baselines without an explicit policy and invalid measurement evidence: empty captures/windows, recorder timebase or recorder errors, unknown integrity counters, loss/corruption, reported transport drops, an empty metric selection, or selected metrics marked unmeasured/lower-bound. Excluding health metrics cannot bypass these checks. Ordinary metric tolerance warnings still succeed.

Schema-1 baselines with current metric semantics remain readable in normal mode, where provenance differences warn. For CI, rebuild from a usable recording and review the rules. GUI policy edits can upgrade an old baseline, but do not manufacture missing provenance or measurement evidence; an old baseline without that evidence still needs rebuilding. Older ViewAlyzer versions reject schema-2 files rather than silently ignoring their rules.

In each metric row, current is the candidate passed through --recording and baseline is the fingerprint/envelope value. Startup residue before the first sync marker is reported separately as pre_sync and does not fail the synced recording's zero-loss health baseline.

**Do not gate on verdict != "fail".** Accept only pass/warn, use the CLI exit status, or use Python Recording.assert_matches() to raise on rejected runs.

Exit codes: 0 pass or warn, 1 command/input error, 2 metric regression, 3 incomparable provenance, 4 invalid measurement. Compatibility takes precedence over measurement validity, then metric regression; all findings remain in the JSON report. --baseline also accepts a recording, fingerprinted on the fly with default rules.

A bench job

Capture on a self-hosted runner with the board attached, compare against the committed fingerprint, keep the recording as an artifact:

# .github/workflows/trace.yml
jobs:
  trace:
    runs-on: [self-hosted, bench-g474]
    steps:
      - uses: actions/checkout@v4
      - name: Flash
        run: python build.py --flash --serial ${{ vars.PROBE_SERIAL }}
      - name: Capture 30 s
        run: |
          viewalyzer-cli capture --config nucleo_g474_rambuf.vacf --stlink-serial ${{ vars.PROBE_SERIAL }} \
            --elf build/rambuf/firmware.elf --output run.vadb --duration 30 --no-register \
            | tee capture.log
          test "$(jq -r '.summary.lost_events' <<< "$(tail -1 capture.log)")" = "0"
      - name: Compare
        shell: bash
        run: |
          set -o pipefail
          viewalyzer-cli query compare --recording run.vadb --baseline ci/app.vafp.json --ci | tee compare.json
      - uses: actions/upload-artifact@v4
        if: always()
        with: { name: trace, path: "run.vadb\ncompare.json\ncapture.log" }

Pin the probe serial (--stlink-serial) on any machine that can have two probes, pass --no-register so the runner's index does not fill up, and read lost_events from the envelope: a capture that lost events is not a measurement of the firmware.

Assertions in Python

The Python SDK turns the same pieces into fixtures and asserts (Tests and CI):

from viewalyzer_sdk import ViewAlyzer

def test_isr_budget(tmp_path):
    va = ViewAlyzer()
    rec = va.record("nucleo_g474_rambuf.vacf", output=tmp_path / "run.vadb", duration_s=10, elf="firmware.elf")
    assert rec.is_clean                                   # no lost events, no corrupt bytes
    lanes = {t["name"]: t for t in rec.timeline()["tasks"]}
    assert lanes["ISR:SysTick"]["p99_slice_us"] < 5.0
    rec.assert_matches("ci/app.vafp.json")  # strict gate; raises with the full report on failure

Metrics for dashboards

replay run.vadb prints one [metric] category,name,value,unit line per metric (recording info, event counts, per-lane slices and CPU, per-channel statistics, flow summaries, result,status), which a bench harness can scrape into a time series without parsing JSON; --perf adds the engine's stage timings.