]> git.ipfire.org Git - thirdparty/linux.git/commit
rtla/tests: Add unit tests for CLI option callbacks
authorTomas Glozar <tglozar@redhat.com>
Thu, 28 May 2026 10:32:54 +0000 (12:32 +0200)
committerTomas Glozar <tglozar@redhat.com>
Thu, 28 May 2026 11:02:48 +0000 (13:02 +0200)
commit596a9bed0aec60490dffd85bd1865430ce298eba
tree221d3ba02d3776f395c3979c29428044b26df3a9
parent244d0cbff2efa13931115784e5dc4d1270a04ec7
rtla/tests: Add unit tests for CLI option callbacks

In addition to testing all tool_parse_args() functions, test also all
callbacks used for parsing custom option formats.

The callbacks represent a middle layer between the parsing functions
and utility functions dedicated to checking specific argument formats,
for example, scheduling class and duration. Callback tests are run
before parsing functions to make sure any issue in the former is
reported before it is encountered through the latter.

Tests verify both successful parsing and proper rejection of invalid
inputs (via exit tests). To enable testing static callbacks, a pragma
once guard is added to timerlat.h for safe inclusion by cli_p.h.

Add dependency of UNIT_TESTS_IN on LIBSUBCMD_INCLUDES, as the new test
file tests/unit/cli_opt_callback.c includes cli_p.h which includes
subcmd/parse-options.h.

Link: https://lore.kernel.org/r/20260528103254.2990068-7-tglozar@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
tools/tracing/rtla/src/timerlat.h
tools/tracing/rtla/tests/unit/Build
tools/tracing/rtla/tests/unit/Makefile.unit
tools/tracing/rtla/tests/unit/cli_opt_callback.c [new file with mode: 0644]
tools/tracing/rtla/tests/unit/unit_tests.c