Unit tests: Fix One Definition Rule violation caused by overlinking #1997
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #1893
The libdnf5 library unit tests use the private methods of the tested libdnf5 library. The
BaseTestCase
class used as a parent of many test scenarios, not only libdnf5 but also libdnf5-cli and other unit tests, provides theadd_system_pkg
method, which also uses private methods of the libdnf5 library. Because the private methods have hidden symbols, they are not exported by the libdnf5 shared library. To access the symbols of the private methods, unit tests link libdnf5 statically instead of using the libdnf5 shared library. This is fine for unit tests of the libdnf5 library. The problem is with unit tests of other components (e.g. libdnf-cli) that link the shared libdnf5 library. Due to this, in these tests the libdnf5 library was linked statically because of used classBaseTestCase
and at the same time the shared libdnf5 library was linked.The problem was solved by moving the
add_system_pkg
method from theBaseTestCase
class to the newly created inheritedLibdnfPrivateTestCase
class, which is only used in the libdnf5 library unit tests. Thus, only in these tests must libdnf5 be linked statically. The tests of the other components still use theBaseTestClass
class, which now uses only public (API) functions from the libdnf5 library. These tests now only link the shared version of the libdnf5 library.