Skip to content
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

Merged
merged 4 commits into from
Dec 9, 2017
Merged

cmake: running unit tests #1802

merged 4 commits into from
Dec 9, 2017

Conversation

furiel
Copy link
Collaborator

@furiel furiel commented Dec 7, 2017

Execute in parallel: make test ARGS=-j4

@kira-syslogng
Copy link
Contributor

Build SUCCESS, the tests were executed on test branch: master and test suite: functions

@kira-syslogng
Copy link
Contributor

Build SUCCESS, the tests were executed on test branch: master and test suite: functions

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)
Copy link
Collaborator

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.


if (${ADD_UNIT_TEST_CRITERION})
target_link_libraries(${ADD_UNIT_TEST_TARGET} criterion)
set_property(TARGET test_filters_statistics PROPERTY POSITION_INDEPENDENT_CODE FALSE)
Copy link
Collaborator

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}.

@@ -10,4 +10,7 @@ add_library(eventlog SHARED
${CMAKE_CURRENT_SOURCE_DIR}/src/evttags.c
)

set(EVENTLOG_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
Copy link
Collaborator

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)
Copy link
Collaborator

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.

Copy link
Collaborator Author

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")
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

add_subdirectory(loggen)

# add_subdirectory(functional)
Copy link
Collaborator

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
Copy link
Collaborator

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 ?

@kira-syslogng
Copy link
Contributor

Build SUCCESS, the tests were executed on test branch: master and test suite: functions

@kira-syslogng
Copy link
Contributor

Build SUCCESS, the tests were executed on test branch: master and test suite: functions

@@ -12,6 +12,8 @@ set(JSON_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/json-parser-grammar.c
)

set(SJON_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

endif()

add_unit_test(LIBTEST TARGET test_json_parser
INCLUDES "${SJON_INCLUDE_DIR}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

endif()

add_unit_test(LIBTEST TARGET test_dot_notation
INCLUDES "${SJON_INCLUDE_DIR}" "${JSONC_INCLUDE_DIR}"
Copy link
Collaborator

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/")
Copy link
Collaborator

@MrAnno MrAnno Dec 8, 2017

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?

Copy link
Collaborator Author

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)
Copy link
Collaborator

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)
Copy link
Collaborator

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?

Copy link
Collaborator Author

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;
Copy link
Collaborator

@MrAnno MrAnno Dec 8, 2017

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.

@kira-syslogng
Copy link
Contributor

Build SUCCESS, the tests were executed on test branch: master and test suite: functions

@Kokan Kokan merged commit 7510588 into syslog-ng:master Dec 9, 2017
@Kokan Kokan removed the needs-review label Dec 9, 2017
@furiel furiel deleted the cmake-ut branch May 8, 2018 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants