1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-07-29 13:01:13 +03:00

tests: Start to migrate tests to cmockery.

https://code.google.com/p/cmockery/wiki/Cmockery_Unit_Testing_Framework
This commit is contained in:
Andreas Schneider
2010-12-28 13:41:33 +01:00
parent 7dc183126a
commit 17f592d4dd
7 changed files with 82 additions and 101 deletions

View File

@ -1,7 +1,7 @@
# - ADD_CHECK_TEST(test_name test_source linklib1 ... linklibN)
# Copyright (c) 2007, Daniel Gollub, <dgollub@suse.de>
# Copyright (c) 2007, Andreas Schneider, <mail@cynapses.org>
# Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
# Copyright (c) 2007-2010 Andreas Schneider <asn@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
@ -14,9 +14,8 @@ set(CMAKE_SHARED_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE
set(CMAKE_MODULE_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
set(CMAKE_EXEC_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
function (ADD_CHECK_TEST _testName _testSource)
add_executable(${_testName} ${_testSource})
target_link_libraries(${_testName} ${ARGN})
add_test(${_testName} ${CMAKE_CURRENT_BINARY_DIR}/${_testName})
endfunction (ADD_CHECK_TEST)
function (ADD_CMOCKERY_TEST _testName _testSource)
add_executable(${_testName} ${_testSource})
target_link_libraries(${_testName} ${ARGN})
add_test(${_testName} ${CMAKE_CURRENT_BINARY_DIR}/${_testName})
endfunction (ADD_CMOCKERY_TEST)

View File

@ -0,0 +1,59 @@
# - Try to find CMockery
# Once done this will define
#
# CMOCKERY_FOUND - system has CMockery
# CMOCKERY_INCLUDE_DIRS - the CMockery include directory
# CMOCKERY_LIBRARIES - Link these to use CMockery
# CMOCKERY_DEFINITIONS - Compiler switches required for using CMockery
#
# Copyright (c) 2010 Andreas Schneider <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (CMOCKERY_LIBRARIES AND CMOCKERY_INCLUDE_DIRS)
# in cache already
set(CMOCKERY_FOUND TRUE)
else (CMOCKERY_LIBRARIES AND CMOCKERY_INCLUDE_DIRS)
find_path(CMOCKERY_INCLUDE_DIR
NAMES
google/cmockery.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
)
find_library(CMOCKERY_LIBRARY
NAMES
cmockery
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
set(CMOCKERY_INCLUDE_DIRS
${CMOCKERY_INCLUDE_DIR}
)
if (CMOCKERY_LIBRARY)
set(CMOCKERY_LIBRARIES
${CMOCKERY_LIBRARIES}
${CMOCKERY_LIBRARY}
)
endif (CMOCKERY_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CMockery DEFAULT_MSG CMOCKERY_LIBRARIES CMOCKERY_INCLUDE_DIRS)
# show the CMOCKERY_INCLUDE_DIRS and CMOCKERY_LIBRARIES variables only in the advanced view
mark_as_advanced(CMOCKERY_INCLUDE_DIRS CMOCKERY_LIBRARIES)
endif (CMOCKERY_LIBRARIES AND CMOCKERY_INCLUDE_DIRS)

View File

@ -1,72 +0,0 @@
# - Try to find Check
# Once done this will define
#
# CHECK_FOUND - system has Check
# CHECK_INCLUDE_DIRS - the Check include directory
# CHECK_LIBRARIES - Link these to use Check
# CHECK_DEFINITIONS - Compiler switches required for using Check
#
# Copyright (c) 2010 Andreas Schneider <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (CHECK_LIBRARIES AND CHECK_INCLUDE_DIRS)
# in cache already
set(CHECK_FOUND TRUE)
else (CHECK_LIBRARIES AND CHECK_INCLUDE_DIRS)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_CHECK check)
endif (PKG_CONFIG_FOUND)
find_path(CHECK_INCLUDE_DIR
NAMES
check.h
PATHS
${_CHECK_INCLUDEDIR}
/usr/include
/usr/local/include
/opt/local/include
/sw/include
/usr/lib/sfw/include
)
# check_pic is a workaround for ubuntu's check bug which does not compile
# check as a shared library with -fPIC.
# see https://bugs.launchpad.net/ubuntu/+source/check/+bug/125781
find_library(CHECK_LIBRARY
NAMES
check_pic check
PATHS
${_CHECK_LIBDIR}
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
/usr/sfw/lib/64
/usr/sfw/lib
)
set(CHECK_INCLUDE_DIRS
${CHECK_INCLUDE_DIR}
)
if (CHECK_LIBRARY)
set(CHECK_LIBRARIES
${CHECK_LIBRARIES}
${CHECK_LIBRARY}
)
endif (CHECK_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Check DEFAULT_MSG CHECK_LIBRARIES CHECK_INCLUDE_DIRS)
# show the CHECK_INCLUDE_DIRS and CHECK_LIBRARIES variables only in the advanced view
mark_as_advanced(CHECK_INCLUDE_DIRS CHECK_LIBRARIES)
endif (CHECK_LIBRARIES AND CHECK_INCLUDE_DIRS)