Skip to content

Add unit tests for CommandManager CLI parser #42

@angeloINTJ

Description

@angeloINTJ

What

Write host-side unit tests for the CLI command parser in CommandManager.

Why

The CLI is accessible via USB Serial (no auth) and Bluetooth (PIN auth). A parser bug on the unauthenticated USB path could brick the device, corrupt config, or leak data. Currently untested.

How

  1. Create test/test_command_parser/test_main.cpp following the pattern of test/test_validators/test_main.cpp
  2. Add a test_filter = test_command_parser line or include in native env
  3. Test at minimum:
    • Valid commands: help, show system, conf user add ..., clear log confirm
    • Invalid commands: empty string, garbage, buffer overflow at CLI_LINE_MAX=256
    • Edge cases: trailing whitespace, extra spaces between args, Unicode bytes
    • Partial commands: conf without subcommand, show without target
    • Auth boundary: commands available before vs after BT PIN auth

Acceptance

  • pio test -e native passes
  • Valid commands parse correctly (exact arg extraction)
  • Invalid commands return unknown/error without crash
  • 256-char boundary is respected
  • Tests are self-contained (no hardware)

References

  • src/CommandManager.h and src/CommandManager.cpp
  • src/SystemDefs_Cli.hCliDemand struct
  • test/test_validators/test_main.cpp — pattern to follow

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomerstestsTesting infrastructure and test coverage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions