]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rtla/tests: Add unit tests for _parse_args() functions
authorTomas Glozar <tglozar@redhat.com>
Thu, 28 May 2026 10:32:53 +0000 (12:32 +0200)
committerTomas Glozar <tglozar@redhat.com>
Thu, 28 May 2026 11:02:48 +0000 (13:02 +0200)
commit244d0cbff2efa13931115784e5dc4d1270a04ec7
tree3a679f17c3adab9ea147eda742c520323716a355
parent5d9af63e80b5a202e69ce5bcf54af320e46f397a
rtla/tests: Add unit tests for _parse_args() functions

Add a test suite for the _parse_args() function of each tool that checks
the params structures (struct common_params, struct osnoise_params,
struct timerlat_params) returned by them for correctness.

One test case is added per option, as well as a few special cases for
tricky combinations of options. Test cases are ordered the same as the
option arrays and help message to allow easy checking of whether all
options are covered.

This should help clarify what the proper command line behavior of RTLA
is in case there are holes in the documentation and verify that the
intended behavior is implemented correctly.

A few necessary changes to the unit tests were done as part of this
commit:

- Unit tests now also link to libsubcmd and its dependencies.
- A new global variable in_unit_test is added to RTLA's CLI interface,
  causing it to skip check for root if running in unit tests. This
  allows the CLI unit tests to run as non-root, like existing unit
  tests.

There is quite a lot of duplication, some of it is mitigated with macros,
but partially it is intentional so that future changes in behavior are
tracked across tools.

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