Move from CUnit to BCUnit

parent 719cde84
......@@ -94,21 +94,21 @@ if(POLARSSL_FOUND)
endif()
if(ENABLE_TESTS_COMPONENT)
find_package(CUnit 3.0 REQUIRED)
find_package(BCUnit 3.0 REQUIRED)
cmake_push_check_state(RESET)
list(APPEND CMAKE_REQUIRED_INCLUDES ${CUNIT_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${CUNIT_LIBRARIES})
check_symbol_exists("CU_get_suite" "CUnit/CUnit.h" HAVE_CU_GET_SUITE)
check_symbol_exists("CU_curses_run_tests" "CUnit/CUnit.h" HAVE_CU_CURSES)
check_symbol_exists("CU_set_trace_handler" "CUnit/Util.h" HAVE_CU_SET_TRACE_HANDLER)
list(APPEND CMAKE_REQUIRED_INCLUDES ${BCUNIT_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${BCUNIT_LIBRARIES})
check_symbol_exists("CU_get_suite" "BCUnit/BCUnit.h" HAVE_CU_GET_SUITE)
check_symbol_exists("CU_curses_run_tests" "BCUnit/BCUnit.h" HAVE_CU_CURSES)
check_symbol_exists("CU_set_trace_handler" "BCUnit/Util.h" HAVE_CU_SET_TRACE_HANDLER)
cmake_pop_check_state()
set(TESTER_REQUIRES_PRIVATE "cunit")
set(TESTER_REQUIRES_PRIVATE "bcunit")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bctoolbox.pc.in ${CMAKE_CURRENT_BINARY_DIR}/bctoolbox.pc)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bctoolbox.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
if(ENABLE_TESTS_COMPONENT AND CUNIT_FOUND)
if(ENABLE_TESTS_COMPONENT AND BCUNIT_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bctoolbox-tester.pc.in ${CMAKE_CURRENT_BINARY_DIR}/bctoolbox-tester.pc)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bctoolbox-tester.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
......@@ -182,7 +182,7 @@ check_library_exists("rt" "clock_gettime" "" HAVE_LIBRT)
add_subdirectory(include)
add_subdirectory(src)
if(ENABLE_TESTS AND ENABLE_TESTS_COMPONENT AND CUNIT_FOUND)
if(ENABLE_TESTS AND ENABLE_TESTS_COMPONENT AND BCUNIT_FOUND)
add_subdirectory(tester)
endif()
......
......@@ -6,11 +6,11 @@ LOCAL_MODULE:= libbctoolbox_tester
LOCAL_SRC_FILES := \
tester/utils.c
LOCAL_CFLAGS += -Wno-maybe-uninitialized -DIN_CUNIT_SOURCES -DHAVE_CU_SET_TRACE_HANDLER=1 -DHAVE_CU_GET_SUITE=1
LOCAL_CFLAGS += -Wno-maybe-uninitialized -DIN_BCUNIT_SOURCES -DHAVE_CU_SET_TRACE_HANDLER=1 -DHAVE_CU_GET_SUITE=1
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/ \
$(LOCAL_PATH)/../include \
$(LOCAL_PATH)/../../externals/cunit/CUnit/Headers
$(LOCAL_PATH)/../../externals/bcunit/BCUnit/Headers
include $(BUILD_STATIC_LIBRARY)
############################################################################
# FindCUnit.txt
# FindBCUnit.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
......@@ -20,49 +20,49 @@
#
############################################################################
#
# - Find the CUnit include file and library
# - Find the BCUnit include file and library
#
# CUNIT_FOUND - system has CUnit
# CUNIT_INCLUDE_DIRS - the CUnit include directory
# CUNIT_LIBRARIES - The libraries needed to use CUnit
# BCUNIT_FOUND - system has BCUnit
# BCUNIT_INCLUDE_DIRS - the BCUnit include directory
# BCUNIT_LIBRARIES - The libraries needed to use BCUnit
include(CheckIncludeFile)
include(CheckLibraryExists)
find_path(CUNIT_INCLUDE_DIRS
NAMES CUnit/CUnit.h
find_path(BCUNIT_INCLUDE_DIRS
NAMES BCUnit/BCUnit.h
PATH_SUFFIXES include
)
if(CUNIT_INCLUDE_DIRS)
set(HAVE_CUNIT_CUNIT_H 1)
if(BCUNIT_INCLUDE_DIRS)
set(HAVE_BCUNIT_BCUNIT_H 1)
endif()
if(HAVE_CUNIT_CUNIT_H)
if(CUnit_FIND_VERSION)
list(APPEND CUNIT_REQUIRED_VARS CUNIT_VERSION)
file(STRINGS "${CUNIT_INCLUDE_DIRS}/CUnit/CUnit.h" CUNIT_VERSION_STR
if(HAVE_BCUNIT_BCUNIT_H)
if(BCUnit_FIND_VERSION)
list(APPEND BCUNIT_REQUIRED_VARS BCUNIT_VERSION)
file(STRINGS "${BCUNIT_INCLUDE_DIRS}/BCUnit/BCUnit.h" BCUNIT_VERSION_STR
REGEX "^#define[\t ]+CU_VERSION[\t ]+\"([0-9.]+).*\"$")
string(REGEX REPLACE "^.*CU_VERSION[\t ]+\"([0-9.]+).*\"$" "\\1" CUNIT_VERSION "${CUNIT_VERSION_STR}")
string(REGEX REPLACE "^.*CU_VERSION[\t ]+\"([0-9.]+).*\"$" "\\1" BCUNIT_VERSION "${BCUNIT_VERSION_STR}")
endif()
endif()
find_library(CUNIT_LIBRARIES
NAMES cunit
find_library(BCUNIT_LIBRARIES
NAMES bcunit
PATH_SUFFIXES bin lib
)
include(FindPackageHandleStandardArgs)
if(CUnit_FIND_VERSION)
set(CHECK_VERSION_ARGS VERSION_VAR CUNIT_VERSION)
if(BCUnit_FIND_VERSION)
set(CHECK_VERSION_ARGS VERSION_VAR BCUNIT_VERSION)
endif()
find_package_handle_standard_args(CUnit
REQUIRED_VARS CUNIT_INCLUDE_DIRS CUNIT_LIBRARIES
find_package_handle_standard_args(BCUnit
REQUIRED_VARS BCUNIT_INCLUDE_DIRS BCUNIT_LIBRARIES
${CHECK_VERSION_ARGS}
)
mark_as_advanced(CUNIT_INCLUDE_DIRS CUNIT_LIBRARIES)
mark_as_advanced(BCUNIT_INCLUDE_DIRS BCUNIT_LIBRARIES)
unset(CHECK_VERSION_ARGS)
......@@ -81,9 +81,9 @@ AC_ARG_WITH( polarssl,
[ --with-polarssl Set prefix where polarssl can be found (ex:/usr or /usr/local)[default=PREFIX] ],
[ polarssl_prefix=${withval}],[ polarssl_prefix=${prefix} ])
AC_ARG_WITH( cunit,
[ --with-cunit Set prefix where cunit can be found (ex:/usr or /usr/local)[default=PREFIX] ],
[ cunit_prefix=${withval}],[ cunit_prefix=${prefix} ])
AC_ARG_WITH( bcunit,
[ --with-bcunit Set prefix where bcunit can be found (ex:/usr or /usr/local)[default=PREFIX] ],
[ bcunit_prefix=${withval}],[ bcunit_prefix=${prefix} ])
if test "$mbedtls_prefix" = "NONE" ; then
......@@ -94,8 +94,8 @@ if test "$polarssl_prefix" = "NONE" ; then
polarssl_prefix=/usr/local
fi
if test "$cunit_prefix" = "NONE" ; then
cunit_prefix=/usr/local
if test "$bcunit_prefix" = "NONE" ; then
bcunit_prefix=/usr/local
fi
......@@ -104,40 +104,40 @@ if test "$mbedtls_prefix" != "/usr" ; then
MBEDTLS_LIBS="-L${mbedtls_prefix}/lib"
fi
if test "$cunit_prefix" != "/usr" ; then
CUNIT_CFLAGS="-I${cunit_prefix}"
CUNIT_LIBS="-L${cunit_prefix}/lib"
if test "$bcunit_prefix" != "/usr" ; then
BCUNIT_CFLAGS="-I${bcunit_prefix}"
BCUNIT_LIBS="-L${bcunit_prefix}/lib"
fi
CPPFLAGS_save=$CPPFLAGS
LIBS_save=$LIBS
CPPFLAGS="$CPPFLAGS $CUNIT_CFLAGS"
LIBS="$LIBS $CUNIT_LIBS"
CPPFLAGS="$CPPFLAGS $BCUNIT_CFLAGS"
LIBS="$LIBS $BCUNIT_LIBS"
AC_CHECK_HEADER(CUnit/CUnit.h, [
AC_CHECK_LIB(cunit, CU_get_error, [CUNIT_LIBS="CUNIT_LIBS -lcunit"; cunit_found=true],
[cunit_found=false]) ],
[cunit_found=false]
AC_CHECK_HEADER(BCUnit/BCUnit.h, [
AC_CHECK_LIB(bcunit, CU_get_error, [BCUNIT_LIBS="BCUNIT_LIBS -lbcunit"; bcunit_found=true],
[bcunit_found=false]) ],
[bcunit_found=false]
)
if test "$cunit_found" != "true" ; then
AC_MSG_ERROR("CUnit not found")
if test "$bcunit_found" != "true" ; then
AC_MSG_ERROR("BCUnit not found")
else
AC_CHECK_LIB(cunit, CU_get_suite,
AC_CHECK_LIB(bcunit, CU_get_suite,
[ AC_DEFINE(HAVE_CU_GET_SUITE, 1, [Defined when CU_get_suite is available])]
)
AC_CHECK_LIB(cunit, CU_set_trace_handler,
AC_CHECK_LIB(bcunit, CU_set_trace_handler,
[ AC_DEFINE(HAVE_CU_SET_TRACE_HANDLER, 1, [Defined when CU_set_trace_handler is available])]
)
AC_CHECK_HEADERS(CUnit/CUCurses.h)
AC_CHECK_HEADERS(BCUnit/CUCurses.h)
fi
CPPFLAGS=$CPPFLAGS_save
LIBS=$LIBS_save
AC_SUBST(CUNIT_CFLAGS)
AC_SUBST(CUNIT_LIBS)
AC_SUBST(BCUNIT_CFLAGS)
AC_SUBST(BCUNIT_LIBS)
CPPFLAGS_save=$CPPFLAGS
LIBS_save=$LIBS
......
......@@ -38,7 +38,7 @@ if(POLARSSL_FOUND)
list(APPEND BCTOOLBOX_C_SOURCE_FILES crypto/polarssl1.2.c)
endif()
endif()
if(CUNIT_FOUND)
if(BCUNIT_FOUND)
set(BCTOOLBOX_C_TESTER_SOURCE_FILES tester.c)
endif()
......@@ -76,7 +76,7 @@ if(ENABLE_STATIC)
if(HAVE_LIBRT)
target_link_libraries(bctoolbox-static rt)
endif()
if(CUNIT_FOUND)
if(BCUNIT_FOUND)
add_library(bctoolbox-tester-static STATIC ${BCTOOLBOX_TESTER_SOURCE_FILES})
set_target_properties(bctoolbox-tester-static PROPERTIES OUTPUT_NAME bctoolbox-tester)
target_link_libraries(bctoolbox-tester-static bctoolbox-static)
......@@ -110,7 +110,7 @@ if(ENABLE_SHARED)
if(HAVE_LIBRT)
target_link_libraries(bctoolbox PRIVATE rt)
endif()
if(CUNIT_FOUND)
if(BCUNIT_FOUND)
add_library(bctoolbox-tester SHARED ${BCTOOLBOX_TESTER_SOURCE_FILES})
set_target_properties(bctoolbox-tester PROPERTIES LINKER_LANGUAGE "CXX")
target_link_libraries(bctoolbox-tester PRIVATE bctoolbox)
......@@ -155,14 +155,14 @@ if(POLARSSL_FOUND)
target_link_libraries(bctoolbox PRIVATE ${POLARSSL_LIBRARIES})
endif()
endif()
if(CUNIT_FOUND)
if(BCUNIT_FOUND)
if(ENABLE_STATIC)
target_include_directories(bctoolbox-tester-static PUBLIC ${CUNIT_INCLUDE_DIRS})
target_link_libraries(bctoolbox-tester-static bctoolbox-static ${CUNIT_LIBRARIES})
target_include_directories(bctoolbox-tester-static PUBLIC ${BCUNIT_INCLUDE_DIRS})
target_link_libraries(bctoolbox-tester-static bctoolbox-static ${BCUNIT_LIBRARIES})
endif()
if(ENABLE_SHARED)
target_include_directories(bctoolbox-tester PUBLIC ${CUNIT_INCLUDE_DIRS})
target_link_libraries(bctoolbox-tester PRIVATE bctoolbox ${CUNIT_LIBRARIES})
target_include_directories(bctoolbox-tester PUBLIC ${BCUNIT_INCLUDE_DIRS})
target_link_libraries(bctoolbox-tester PRIVATE bctoolbox ${BCUNIT_LIBRARIES})
endif()
endif()
......@@ -173,7 +173,7 @@ if(ENABLE_STATIC)
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT core
)
if(CUNIT_FOUND)
if(BCUNIT_FOUND)
install(TARGETS bctoolbox-tester-static EXPORT ${EXPORT_TARGETS_NAME}Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
......@@ -189,7 +189,7 @@ if(ENABLE_SHARED)
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT core
)
if(CUNIT_FOUND)
if(BCUNIT_FOUND)
install(TARGETS bctoolbox-tester EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
......
......@@ -31,6 +31,6 @@ libbctoolbox_la_LDFLAGS = -version-info $(BCTOOLBOX_SO_VERSION) -no-undefined
libbctoolbox_tester_la_SOURCES = tester.c utils.h
libbctoolbox_tester_la_LIBADD = $(CUNIT_LIBS)
libbctoolbox_tester_la_LIBADD = $(BCUNIT_LIBS)
libbctoolbox_tester_la_LDFLAGS= -version-info $(BCTOOLBOX_SO_VERSION) -no-undefined
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src $(CUNIT_CFLAGS)
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src $(BCUNIT_CFLAGS)
......@@ -30,11 +30,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <unistd.h>
#endif
#ifndef IN_CUNIT_SOURCES
#include <CUnit/Basic.h>
#include <CUnit/Automated.h>
#include <CUnit/MyMem.h>
#include <CUnit/Util.h>
#ifndef IN_BCUNIT_SOURCES
#include <BCUnit/Basic.h>
#include <BCUnit/Automated.h>
#include <BCUnit/MyMem.h>
#include <BCUnit/Util.h>
#else
#include "Basic.h"
#include "Automated.h"
......@@ -65,7 +65,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define F_OK 00 /* Visual Studio does not define F_OK */
#endif
#ifdef HAVE_CUNIT_CUCURSES_H
#ifdef HAVE_BCUNIT_CUCURSES_H
#define HAVE_CU_CURSES 1
#endif
......@@ -83,11 +83,11 @@ static test_suite_t **test_suite = NULL;
static int nb_test_suites = 0;
#ifdef HAVE_CU_CURSES
#include "CUnit/CUCurses.h"
#include "BCUnit/CUCurses.h"
static unsigned char curses = 0;
#endif
char* xml_file = "CUnitAutomated-Results.xml";
char* xml_file = "BCUnitAutomated-Results.xml";
int xml_enabled = 0;
char * suite_name = NULL;
char * test_name = NULL;
......@@ -247,7 +247,7 @@ static void test_start_message_handler(const CU_pTest pTest, const CU_pSuite pSu
bc_current_test_name = pTest->pName;
}
/*derivated from cunit*/
/*derivated from bcunit*/
static void test_complete_message_handler(const CU_pTest pTest, const CU_pSuite pSuite,
const CU_pFailureRecord pFailureList) {
int i;
......@@ -310,7 +310,7 @@ static void test_complete_message_handler(const CU_pTest pTest, const CU_pSuite
int bc_tester_run_tests(const char *suite_name, const char *test_name, const char *tag_name) {
int i;
/* initialize the CUnit test registry */
/* initialize the BCUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
......@@ -371,13 +371,13 @@ int bc_tester_run_tests(const char *suite_name, const char *test_name, const cha
{
#ifdef HAVE_CU_CURSES
if (curses) {
/* Run tests using the CUnit curses interface */
/* Run tests using the BCUnit curses interface */
CU_curses_run_tests();
}
else
#endif
{
/* Run all tests using the CUnit Basic interface */
/* Run all tests using the BCUnit Basic interface */
CU_run_all_tests();
}
}
......
......@@ -26,7 +26,7 @@ else()
set(PROJECT_LIBS bctoolbox bctoolbox-tester)
endif()
if(CUNIT_FOUND)
if(BCUNIT_FOUND)
set(TESTER_SOURCES
bctoolbox_tester.c
bctoolbox_tester.h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment