Skip to content

Commit 596a9be

Browse files
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>
1 parent 244d0cb commit 596a9be

5 files changed

Lines changed: 710 additions & 1 deletion

File tree

tools/tracing/rtla/src/timerlat.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
2+
#pragma once
3+
24
#include "osnoise.h"
35

46
/*

tools/tracing/rtla/tests/unit/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ unit_tests-y += osnoise_top_cli.o
55
unit_tests-y += osnoise_hist_cli.o
66
unit_tests-y += timerlat_top_cli.o
77
unit_tests-y += timerlat_hist_cli.o
8+
unit_tests-y += cli_opt_callback.o

tools/tracing/rtla/tests/unit/Makefile.unit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ UNIT_TESTS_IN := $(UNIT_TESTS)-in.o
66
$(UNIT_TESTS): $(UNIT_TESTS_IN) $(RTLA_IN) $(LIBSUBCMD) $(LIB_STRING) $(LIB_STR_ERROR_R)
77
$(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $^ $(EXTLIBS) -lcheck
88

9-
$(UNIT_TESTS_IN): fixdep
9+
$(UNIT_TESTS_IN): fixdep $(LIBSUBCMD_INCLUDES)
1010
make $(build)=unit_tests
1111

1212
unit-tests: FORCE

0 commit comments

Comments
 (0)