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:
@@ -49,7 +49,6 @@ set (CMAKE_SWIG_FLAGS "")
|
||||
find_path (SYSTEM_USR_DIR "stdlib.h")
|
||||
include_directories (${SYSTEM_USR_DIR})
|
||||
|
||||
option (GTEST "Build all gtests." OFF)
|
||||
option (BUILDDOC "Build all doc." OFF)
|
||||
option (BUILDSWIG "Build swig 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 (INSTALLGPIOTOOL "Install gpio tool" OFF)
|
||||
option (BUILDARCH "Override architecture to build for - override" OFF)
|
||||
option (TESTS "Override the addition of tests" ON)
|
||||
|
||||
if (NOT BUILDARCH)
|
||||
include (TargetArch)
|
||||
@@ -77,9 +77,19 @@ else ()
|
||||
message(FATAL_ERROR "Only x86 and arm platforms currently supported")
|
||||
endif()
|
||||
|
||||
if (GTEST)
|
||||
enable_testing ()
|
||||
add_subdirectory (tests)
|
||||
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 ()
|
||||
add_subdirectory (tests)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (BUILDDOC)
|
||||
|
||||
@@ -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 (PythonInterp ${PYTHONBUILD_VERSION} REQUIRED)
|
||||
|
||||
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
|
||||
|
||||
|
||||
@@ -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(
|
||||
${GTEST_INCLUDE_DIRS}
|
||||
${PROJECT_SOURCE_DIR}/api
|
||||
${PROJECT_SOURCE_DIR}/include
|
||||
)
|
||||
add_test (NAME py_gpio COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gpio_checks.py)
|
||||
set_tests_properties(py_gpio PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/src/python/")
|
||||
|
||||
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})
|
||||
|
||||
Reference in New Issue
Block a user