Skip to content

Unit tests for AsyncLogWriter #2497

Description

@ten9876

Follow-up to #2478 (merge commit e8f27c73).

When @jensenpat landed the AsyncLogWriter foundation, he mentioned validating it via a throwaway probe — verifying token redaction, IPv4/serial/MAC redaction, and that clearLog() truncates prior buffered writes while preserving subsequent ones. The probe wasn't committed.

The class is well-suited to unit testing in isolation since the public API is deterministic when called serially:

AsyncLogWriter w;
w.start("/tmp/test.log", false);
w.enqueue(QtDebugMsg, QTime::currentTime(), "test", "hello 192.168.1.123");
w.flush();
QFile f("/tmp/test.log"); f.open(QIODevice::ReadOnly);
QVERIFY(f.readAll().contains("*.*.*. 123"));
w.shutdown();

Suggested test cases

  • Format preservation: produced line matches [HH:mm:ss.zzz] DBG aether.x: msg\n shape exactly
  • PII redaction:
    • IPv4: 192.168.50.121*.*.*. 121
    • IPv4 ver-prefix exemption: software_ver=4.2.18.41174 is NOT redacted
    • IPv4 quoted exemption: "0.9.8" is NOT redacted
    • Serial: 4424-1213-8600-7836****-****-****-7836
    • Token: id_token=ABCDEF12345...long stringid_token= ABCDEF...REDACTED
    • MAC dash: 00-1C-2D-05-37-2A**-**-**-**-**-2A
    • MAC colon: 00:1C:2D:05:37:2A**:**:**:**:**:2A
  • clearLog determinism: enqueue lines → clearLog → enqueue more → file contains only the post-clear lines
  • Drop accounting: enqueue more than kHardMaxQueueEntries warn/crit lines → counters reflect drops, summary line emitted
  • High-priority reserve: enqueue 8192 debug + 1 critical → critical is preserved; counter shows debug drops only
  • Shutdown ordering: enqueue → shutdown → file contains all enqueued lines (no loss on graceful stop)
  • Stderr mirroring: when mirrorToStderr=true, captured stderr matches file content

Test file would live at tests/async_log_writer_test.cpp, registered in CMakeLists.txt as add_executable(async_log_writer_test ...) per the existing test pattern.

Priority

Low. AsyncLogWriter is exercised constantly in production runs so behavioral regressions surface fast. But unit coverage would catch redaction-regex regressions before they ship — those are the most likely target for future tightening.

73, Jeremy KK7GWY & Claude (AI dev partner)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovement to existing featuremaintainer-reviewRequires maintainer review before any action is takenpriority: lowLow priority

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions