gtest: Organized Gtest unit tests

This commit limits which tests run on which ARCH to allow all tests to
pass on CI.

    * Qualify the FTDI tests with (FTDI4222 AND USBPLAT)
    * Qualify the IO init tests with (DETECTED_ARCH == "MOCK")
    * Renamed all unit tests to start with 'test_unit_' to facilitate
      grouping with tab completion (or any other type of sorting)
    * Updated docker targets with new unit test target name

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck
2018-07-20 10:08:18 -07:00
parent ae391fe9fe
commit 4487c98b6f
2 changed files with 29 additions and 29 deletions

View File

@@ -118,13 +118,13 @@ services:
environment:
- BUILDSWIG=ON
- BUILDSWIGPYTHON=ON
command: bash -c "./scripts/run-cmake.sh && cd build && make _python2-mraa tests-unit && ctest --output-on-failure"
command: bash -c "./scripts/run-cmake.sh && cd build && make _python2-mraa test_unit_all && ctest --output-on-failure"
python3:
extends: python2
environment:
- USEPYTHON3TESTS=ON
command: bash -c "./scripts/run-cmake.sh && cd build && make _python3-mraa tests-unit && ctest --output-on-failure"
command: bash -c "./scripts/run-cmake.sh && cd build && make _python3-mraa test_unit_all && ctest --output-on-failure"
java:
extends: base
@@ -132,7 +132,7 @@ services:
environment:
- BUILDSWIG=ON
- BUILDSWIGJAVA=ON
command: bash -c "./scripts/run-cmake.sh && cd build && make mraajava tests-unit && ctest --output-on-failure"
command: bash -c "./scripts/run-cmake.sh && cd build && make mraajava test_unit_all && ctest --output-on-failure"
android:
extends: java

View File

@@ -8,39 +8,39 @@ if(NOT GTEST_FOUND)
endif()
# Unit tests - C common header methods
add_executable(api_common_h_unit api/api_common_h_unit.cxx)
target_link_libraries(api_common_h_unit GTest::GTest GTest::Main mraa)
target_include_directories(api_common_h_unit
add_executable(test_unit_common_h api/api_common_h_unit.cxx)
target_link_libraries(test_unit_common_h GTest::GTest GTest::Main mraa)
target_include_directories(test_unit_common_h
PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/api" "${CMAKE_SOURCE_DIR}/api/mraa")
gtest_add_tests(api_common_h_unit "" AUTO)
gtest_add_tests(test_unit_common_h "" AUTO)
list(APPEND GTEST_UNIT_TEST_TARGETS test_unit_common_h)
# Unit tests - C++ common header methods
add_executable(api_common_hpp_unit api/api_common_hpp_unit.cxx)
target_link_libraries(api_common_hpp_unit GTest::GTest GTest::Main mraa)
target_include_directories(api_common_hpp_unit PRIVATE "${CMAKE_SOURCE_DIR}/api")
gtest_add_tests(api_common_hpp_unit "" AUTO)
add_executable(test_unit_common_hpp api/api_common_hpp_unit.cxx)
target_link_libraries(test_unit_common_hpp GTest::GTest GTest::Main mraa)
target_include_directories(test_unit_common_hpp PRIVATE "${CMAKE_SOURCE_DIR}/api")
gtest_add_tests(test_unit_common_hpp "" AUTO)
list(APPEND GTEST_UNIT_TEST_TARGETS test_unit_common_hpp)
if (FTDI4222)
if (FTDI4222 AND USBPLAT)
# Unit tests - Test platform extenders (as much as possible)
add_executable(platform_extender platform_extender/platform_extender.cxx)
target_link_libraries(platform_extender GTest::GTest GTest::Main mraa-platform-ft4222 dl)
target_include_directories(platform_extender PRIVATE "${PROJECT_SOURCE_DIR}/api"
add_executable(test_unit_ftdi4222 platform_extender/platform_extender.cxx)
target_link_libraries(test_unit_ftdi4222 GTest::GTest GTest::Main mraa-platform-ft4222 dl)
target_include_directories(test_unit_ftdi4222 PRIVATE "${PROJECT_SOURCE_DIR}/api"
"${PROJECT_SOURCE_DIR}/api/mraa"
"${PROJECT_SOURCE_DIR}/include")
gtest_add_tests(platform_extender "" AUTO)
gtest_add_tests(test_unit_ftdi4222 "" AUTO)
list(APPEND GTEST_UNIT_TEST_TARGETS test_unit_ftdi4222)
endif ()
# Unit tests - C initio header methods
add_executable(mraa_initio_h_unit api/mraa_initio_h_unit.cxx)
target_link_libraries(mraa_initio_h_unit GTest::GTest GTest::Main mraa)
target_include_directories(mraa_initio_h_unit PRIVATE "${CMAKE_SOURCE_DIR}/api")
gtest_add_tests(mraa_initio_h_unit "" AUTO)
# Unit tests - test C initio header methods on MOCK platform only
if (DETECTED_ARCH STREQUAL "MOCK")
add_executable(test_unit_ioinit_h api/mraa_initio_h_unit.cxx)
target_link_libraries(test_unit_ioinit_h GTest::GTest GTest::Main mraa)
target_include_directories(test_unit_ioinit_h PRIVATE "${CMAKE_SOURCE_DIR}/api")
gtest_add_tests(test_unit_ioinit_h "" AUTO)
list(APPEND GTEST_UNIT_TEST_TARGETS test_unit_ioinit_h)
endif()
# Add a custom target for unit tests
add_custom_target(tests-unit ALL
DEPENDS
api_common_h_unit
api_common_hpp_unit
platform_extender
mraa_initio_h_unit
COMMENT "mraa unit test collection")
# Add a target for all unit tests
add_custom_target(test_unit_all ALL DEPENDS ${GTEST_UNIT_TEST_TARGETS})