rtla/tests: Add unit tests for actions module
Subsystems (2)
Tomas Glozar
maintainerPATCH 1/1 rtla/tests: Add unit tests for actions module
Add unit tests covering all functions in the actions module, including both valid and invalid inputs and all action types, except for actions_perform(), where only shell and continue actions are tested.
To support testing multiple modules, the unit test build was modified so that it links the entire rtla-in.o file. For this to work, the main() function in rtla.c was declared weak, so that the unit test main is able to override it.
Other included minor changes to unit tests are:
- Make unit test output verbose to show which tests are being run, now that we have more than 3 tests.
- Add unit_tests file to .gitignore.
- Split unit test sources to one file per test suite, and keep only main() function in unit_tests.c.
- Fix Makefile dependencies so that "make unit-tests" will rebuild the binary with the changes in the commit.
Also with the linking the entire rtla-in.o file, it now has rtla's nr_cpus symbol, so the declaration in utils unit tests is made extern.
--- tools/tracing/rtla/.gitignore | 1 + tools/tracing/rtla/src/rtla.c | 3 + tools/tracing/rtla/tests/unit/Build | 3 +- tools/tracing/rtla/tests/unit/Makefile.unit | 6 +- tools/tracing/rtla/tests/unit/actions.c | 380 ++++++++++++++++++++ tools/tracing/rtla/tests/unit/unit_tests.c | 107 +----- tools/tracing/rtla/tests/unit/utils.c | 106 ++++++ 7 files changed, 502 insertions(+), 104 deletions(-) create mode 100644 tools/tracing/rtla/tests/unit/actions.c create mode 100644 tools/tracing/rtla/tests/unit/utils.c
tools/tracing/rtla/.gitignore +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only rtla rtla-static +unit_tests fixdep feature FEATURE-DUMP
tools/tracing/rtla/src/rtla.c +3 -0
@@ -61,6 +61,9 @@ int run_command(int argc, char **argv, int start_position)return 1 ; } +/* Set main as weak to allow overriding it for building unit test binary */ +#pragma weak main +int main (int argc,char *argv[]) {int retval;
tools/tracing/rtla/tests/unit/Build +2 -1
@@ -1,2 +1,3 @@ +unit_tests-y += utils.o +unit_tests-y += actions.o unit_tests-y += unit_tests.o -unit_tests-y +=../../src/utils.o
tools/tracing/rtla/tests/unit/Makefile.unit +3 -3
@@ -3,10 +3,10 @@ UNIT_TESTS := $(OUTPUT)unit_tests UNIT_TESTS_IN := $(UNIT_TESTS)-in.o -$(UNIT_TESTS): $(UNIT_TESTS_IN) - $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $^ -lcheck +$(UNIT_TESTS): $(UNIT_TESTS_IN) $(RTLA_IN) + $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $^ $(EXTLIBS) -lcheck -$(UNIT_TESTS_IN): +$(UNIT_TESTS_IN): fixdep make $(build)=unit_tests unit-tests: FORCE
tools/tracing/rtla/tests/unit/actions.c new file +380 -0
380 lines not on this page · raw message
tools/tracing/rtla/tests/unit/unit_tests.c +7 -100
122 lines not on this page · raw message
tools/tracing/rtla/tests/unit/utils.c new file +106 -0
106 lines not on this page · raw message
Signature · 1 line
2.53.0