Skip to content

qdl: split the flashing front-end from the CLI plumbing - #323

Open
igoropaniuk wants to merge 4 commits into
linux-msm:masterfrom
igoropaniuk:refactor/flash-cli
Open

igoropaniuk wants to merge 4 commits into
linux-msm:masterfrom
igoropaniuk:refactor/flash-cli

Conversation

@igoropaniuk

Copy link
Copy Markdown
Contributor

Split the 330-line qdl_flash() into qdl_parse_args(), qdl_build_op_list() and a plain session sequence, then move argument parsing into cli.c, out of main()'s compilation unit. Unit tests cover the read/patch XML loaders
and the new option parser.

No behavior change intended; qdl.c drops from 1109 to 960 lines.

@igoropaniuk
igoropaniuk requested a review from a team as a code owner September 20, 2026 12:28
@igoropaniuk
igoropaniuk force-pushed the refactor/flash-cli branch 2 times, most recently from d119fce to f93f3a4 Compare September 20, 2026 12:34
Comment thread src/meson.build Outdated
Comment thread src/cli.h
patch_load_xml() and read_op_load() turn XML into firehose op lists
and had no direct coverage. Add a cmocka suite (linking util.c for
the real attribute accessors and stubbing the device/ux layers) that
checks a valid entry produces the expected op, that an unrecognized
child tag is skipped, and - locking in the recently fixed error
propagation - that a malformed entry or a missing file makes the
loader return an error instead of reporting success.

Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
qdl_flash() mixed three concerns in 330 lines: option decoding, the
positional-argument walk and the device session. Split them into
qdl_parse_args() (filling struct qdl_opts), qdl_build_op_list() and a
plain session sequence, so each can be reasoned about - and tested -
alone. Options, messages and run order are unchanged; the op-list
builder takes the options mutably because the reset verb overrides
skip-reset.

Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
With qdl_parse_args() self-contained, move it plus print_usage() and
the shared long-option ids into cli.c, out of main()'s compilation
unit, so unit tests can link the option parser directly.

Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
With qdl_parse_args() in cli.c it is now unit testable. Cover the
option-to-struct mapping for valid inputs: the defaults, storage and
backend selection, --dry-run/--create-digests pinning the SIM backend
(and a later --backend being ignored), the skipblock mode, the flag
and value options, and that --help/--version report "done" while
too-few positional arguments report a usage error.

Invalid storage/backend/skipblock values errx() out of the process
and so are
left to the integration tests.

Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants