Private
Public Access
2
0

tests: add cmake ctest infrastructure so make test can run

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2015-04-07 23:38:48 +01:00
parent 8cc957ac64
commit 4599f3c12a
3 changed files with 20 additions and 23 deletions

View File

@@ -49,7 +49,6 @@ set (CMAKE_SWIG_FLAGS "")
find_path (SYSTEM_USR_DIR "stdlib.h") find_path (SYSTEM_USR_DIR "stdlib.h")
include_directories (${SYSTEM_USR_DIR}) include_directories (${SYSTEM_USR_DIR})
option (GTEST "Build all gtests." OFF)
option (BUILDDOC "Build all doc." OFF) option (BUILDDOC "Build all doc." OFF)
option (BUILDSWIG "Build swig modules." ON) option (BUILDSWIG "Build swig modules." ON)
option (BUILDSWIGPYTHON "Build swig python modules." ON) option (BUILDSWIGPYTHON "Build swig python modules." ON)
@@ -58,6 +57,7 @@ option (IPK "Generate IPK using CPack" OFF)
option (BUILDPYTHON3 "Use python3 for building/installing" OFF) option (BUILDPYTHON3 "Use python3 for building/installing" OFF)
option (INSTALLGPIOTOOL "Install gpio tool" OFF) option (INSTALLGPIOTOOL "Install gpio tool" OFF)
option (BUILDARCH "Override architecture to build for - override" OFF) option (BUILDARCH "Override architecture to build for - override" OFF)
option (TESTS "Override the addition of tests" ON)
if (NOT BUILDARCH) if (NOT BUILDARCH)
include (TargetArch) include (TargetArch)
@@ -77,10 +77,20 @@ else ()
message(FATAL_ERROR "Only x86 and arm platforms currently supported") message(FATAL_ERROR "Only x86 and arm platforms currently supported")
endif() endif()
if (GTEST) if (BUILDSWIGPYTHON)
if (BUILDPYTHON3)
set (PYTHONBUILD_VERSION 3)
else ()
set (PYTHONBUILD_VERSION 2.7)
endif ()
find_package (PythonInterp ${PYTHONBUILD_VERSION} REQUIRED)
if (TESTS)
if (${PYTHONINTERP_FOUND})
enable_testing () enable_testing ()
add_subdirectory (tests) add_subdirectory (tests)
endif () endif ()
endif ()
endif ()
if (BUILDDOC) if (BUILDDOC)
# add a target to generate API documentation with Doxygen # add a target to generate API documentation with Doxygen

View File

@@ -1,11 +1,4 @@
if (BUILDPYTHON3)
set (PYTHONBUILD_VERSION 3)
else ()
set (PYTHONBUILD_VERSION 2.7)
endif ()
find_package (PythonLibs ${PYTHONBUILD_VERSION} REQUIRED) find_package (PythonLibs ${PYTHONBUILD_VERSION} REQUIRED)
find_package (PythonInterp ${PYTHONBUILD_VERSION} REQUIRED)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})

View File

@@ -1,15 +1,9 @@
find_package (GTest REQUIRED) add_test (NAME py_general COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/general_checks.py)
set_tests_properties(py_general PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/src/python/")
set(PROJECT_TEST_NAME "${PROJECT_NAME}_test") add_test (NAME py_platform COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/platform_checks.py)
set_tests_properties(py_platform PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/src/python/")
include_directories( add_test (NAME py_gpio COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gpio_checks.py)
${GTEST_INCLUDE_DIRS} set_tests_properties(py_gpio PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/src/python/")
${PROJECT_SOURCE_DIR}/api
${PROJECT_SOURCE_DIR}/include
)
add_executable(${PROJECT_TEST_NAME} "mraa_test.cxx")
target_link_libraries(${PROJECT_TEST_NAME} ${PROJECT_NAME_STR} ${GTEST_BOTH_LIBRARIES} mraa pthread)
add_test(Basic ${PROJECT_TEST_NAME})