Skip to content

Commit

Permalink
enable 'make check' with cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorz committed Dec 20, 2017
1 parent 3396f34 commit 80cd2e2
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Expand Up @@ -30,6 +30,14 @@ SET(host ${CMAKE_SYSTEM})

SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)



# enable "make check"
enable_testing()
set(CMAKE_CTEST_COMMAND ctest -V)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})


# run git-info to collect sourcecode info
file(MAKE_DIRECTORY build)
execute_process(
Expand Down
3 changes: 1 addition & 2 deletions platforms/packaging/bareos.spec
Expand Up @@ -782,8 +782,7 @@ make DESTDIR=%{buildroot}

%check
# run unit tests
# todo with cmake, does not work right now
#%__make CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags} check;
make check;

%install
##if 0#{?suse_version}
Expand Down
2 changes: 2 additions & 0 deletions src/findlib/CMakeLists.txt
Expand Up @@ -31,3 +31,5 @@ INSTALL(TARGETS bareosfind DESTINATION ${libdir})
set_target_properties(bareosfind PROPERTIES VERSION "${VERSION}"
SOVERSION "${SOVERSION}"
)

add_subdirectory(unittests EXCLUDE_FROM_ALL)
40 changes: 40 additions & 0 deletions src/findlib/unittests/CMakeLists.txt
@@ -0,0 +1,40 @@
# BAREOS�� - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2017 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
# License as published by the Free Software Foundation and included
# in the file LICENSE.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.

include_directories(.. ../.. ../../include/)

set (TEST_SRC
drivetype_test.cc
fstype_test.cc
test_findlib.cc
)


add_executable(test_findlib
${TEST_SRC}
)
target_link_libraries(test_findlib
bareos bareosfind
${JANSSON_LIBRARIES}
${CMOCKA_LIBRARIES}
)

add_test(NAME test_findlib
COMMAND test_findlib)
add_dependencies(check test_findlib)
4 changes: 4 additions & 0 deletions src/lib/CMakeLists.txt
Expand Up @@ -78,3 +78,7 @@ set_target_properties(bareos PROPERTIES VERSION "${VERSION}"
)

INSTALL(FILES ${INCLUDE_FILES} DESTINATION ${includedir})



add_subdirectory(unittests EXCLUDE_FROM_ALL)
53 changes: 53 additions & 0 deletions src/lib/unittests/CMakeLists.txt
@@ -0,0 +1,53 @@
# BAREOS�� - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2017 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
# License as published by the Free Software Foundation and included
# in the file LICENSE.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.

include_directories(.. ../.. ../../include/)

set (TEST_SRC
alist_test.cc
base64_test.cc
bsnprintf_test.cc
devlock_test.cc
dlist_test.cc
edit_test.cc
htable_test.cc
#ini_test.cc
junction_test.cc
passphrase_test.cc
rblist_test.cc
rwlock_test.cc
scan_test.cc
sellist_test.cc
test_lib.cc
#tree_test.cc
)


add_executable(test_lib
${TEST_SRC}
)
target_link_libraries(test_lib
bareos
${JANSSON_LIBRARIES}
${CMOCKA_LIBRARIES}
)

add_test(NAME test_lib
COMMAND test_lib)
add_dependencies(check test_lib)

0 comments on commit 80cd2e2

Please sign in to comment.