-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake: running unit tests #1802
Conversation
Build SUCCESS, the tests were executed on test branch: master and test suite: functions |
Build SUCCESS, the tests were executed on test branch: master and test suite: functions |
cmake/add_tests.cmake
Outdated
cmake_parse_arguments(ADD_UNIT_TEST "CRITERION;LIBTEST" "TARGET" "SOURCES;DEPENDS;INCLUDES" ${ARGN}) | ||
|
||
if (${ADD_UNIT_TEST_CRITERION} AND NOT ${CRITERION_FOUND}) | ||
MESSAGE(WARNING "Criterion not found, ${ADD_UNIT_TEST_TARGET}" will not be compiled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to create a lot of warning message, if there is no Criterion.
You could write a warning next to the find_package(Criterion)
instead.
cmake/add_tests.cmake
Outdated
|
||
if (${ADD_UNIT_TEST_CRITERION}) | ||
target_link_libraries(${ADD_UNIT_TEST_TARGET} criterion) | ||
set_property(TARGET test_filters_statistics PROPERTY POSITION_INDEPENDENT_CODE FALSE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The target should be ${ADD_UNIT_TEST_TARGET}
.
lib/eventlog/CMakeLists.txt
Outdated
@@ -10,4 +10,7 @@ add_library(eventlog SHARED | |||
${CMAKE_CURRENT_SOURCE_DIR}/src/evttags.c | |||
) | |||
|
|||
set(EVENTLOG_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already an ${Eventlog_INCLUDE_DIR}
variable for that. (You could convert it into uppercase if you want.)
Maybe that is not in the best place.
test-dgram-server.c | ||
test-framed-server.c | ||
test-indented-multiline-server.c | ||
test-regexp-multiline-server.c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New line here would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
add_unit_test(LIBTEST TARGET test_patterndb INCLUDES ${PATTERNDB_INCLUDE_DIR} | ||
DEPENDS patterndb basicfuncs syslogformat) | ||
add_unit_test(TARGET test_radix INCLUDES ${PATTERNDB_INCLUDE_DIR} DEPENDS patterndb) | ||
target_compile_options(test_radix PRIVATE "-Wno-pointer-sign") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be a nicer way to not hide this error, just change it back to warning with: -Wno-error=no-pointer-sign
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
tests/CMakeLists.txt
Outdated
add_subdirectory(loggen) | ||
|
||
# add_subdirectory(functional) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be removed.
@@ -157,7 +157,11 @@ run_testcases(const char *top_srcdir) | |||
int | |||
main(int argc G_GNUC_UNUSED, char *argv[] G_GNUC_UNUSED) | |||
{ | |||
#ifdef TOP_SRCDIR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like your approach, but I think it would be better, if the autotools
based build would use the same approach.
Could you please update the autotools
compile also ?
Build SUCCESS, the tests were executed on test branch: master and test suite: functions |
Build SUCCESS, the tests were executed on test branch: master and test suite: functions |
modules/json/CMakeLists.txt
Outdated
@@ -12,6 +12,8 @@ set(JSON_SOURCES | |||
${CMAKE_CURRENT_BINARY_DIR}/json-parser-grammar.c | |||
) | |||
|
|||
set(SJON_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
modules/json/tests/CMakeLists.txt
Outdated
endif() | ||
|
||
add_unit_test(LIBTEST TARGET test_json_parser | ||
INCLUDES "${SJON_INCLUDE_DIR}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
modules/json/tests/CMakeLists.txt
Outdated
endif() | ||
|
||
add_unit_test(LIBTEST TARGET test_dot_notation | ||
INCLUDES "${SJON_INCLUDE_DIR}" "${JSONC_INCLUDE_DIR}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
@@ -48,13 +48,10 @@ if (EXISTS ${PROJECT_SOURCE_DIR}/lib/jsonc/json.h) | |||
) | |||
|
|||
set(${LIB_NAME}_INTERNAL TRUE) | |||
set(${LIB_NAME}_INTERNAL_INCLUDE_DIR "${PROJECT_BINARY_DIR}/include/json-c/" INTERNAL) | |||
set(${LIB_NAME}_INTERNAL_LIBRARY "${PROJECT_BINARY_DIR}/lib/libjson-c.so" INTERNAL) | |||
set(${LIB_NAME}_INTERNAL_INCLUDE_DIR "${PROJECT_BINARY_DIR}/include/json-c/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this related to unit tests?
If not, can you extract the changes of this file to a separate commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
include(CMakeParseArguments) | ||
|
||
function (add_unit_test) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
@@ -30,5 +30,4 @@ set(Libsystemd_PROCESS_INCLUDES Libsystemd_INCLUDE_DIR) | |||
set(Libsystemd_PROCESS_LIBS Libsystemd_LIBRARY) | |||
|
|||
# silence warnings | |||
set(Libsystemd_FIND_QUIETLY 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you extract this change to a separate commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -157,7 +157,8 @@ run_testcases(const char *top_srcdir) | |||
int | |||
main(int argc G_GNUC_UNUSED, char *argv[] G_GNUC_UNUSED) | |||
{ | |||
char *top_srcdir = getenv("top_srcdir"); | |||
|
|||
char *top_srcdir = TOP_SRCDIR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would split this commit (along with the Makefile and configure changes).
In my opinion, this is a bugfix-like patch and has nothing to do with CMake.
<package>_FIND_QUIETLY is a read_only variable, it should not be set.
Signed-off-by: Antal Nemes <antal.nemes@balabit.com>
Build SUCCESS, the tests were executed on test branch: master and test suite: functions |
Execute in parallel: make test ARGS=-j4