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:
@@ -118,13 +118,13 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- BUILDSWIG=ON
|
- BUILDSWIG=ON
|
||||||
- BUILDSWIGPYTHON=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:
|
python3:
|
||||||
extends: python2
|
extends: python2
|
||||||
environment:
|
environment:
|
||||||
- USEPYTHON3TESTS=ON
|
- 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:
|
java:
|
||||||
extends: base
|
extends: base
|
||||||
@@ -132,7 +132,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- BUILDSWIG=ON
|
- BUILDSWIG=ON
|
||||||
- BUILDSWIGJAVA=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:
|
android:
|
||||||
extends: java
|
extends: java
|
||||||
|
|||||||
@@ -8,39 +8,39 @@ if(NOT GTEST_FOUND)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Unit tests - C common header methods
|
# Unit tests - C common header methods
|
||||||
add_executable(api_common_h_unit api/api_common_h_unit.cxx)
|
add_executable(test_unit_common_h api/api_common_h_unit.cxx)
|
||||||
target_link_libraries(api_common_h_unit GTest::GTest GTest::Main mraa)
|
target_link_libraries(test_unit_common_h GTest::GTest GTest::Main mraa)
|
||||||
target_include_directories(api_common_h_unit
|
target_include_directories(test_unit_common_h
|
||||||
PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/api" "${CMAKE_SOURCE_DIR}/api/mraa")
|
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
|
# Unit tests - C++ common header methods
|
||||||
add_executable(api_common_hpp_unit api/api_common_hpp_unit.cxx)
|
add_executable(test_unit_common_hpp api/api_common_hpp_unit.cxx)
|
||||||
target_link_libraries(api_common_hpp_unit GTest::GTest GTest::Main mraa)
|
target_link_libraries(test_unit_common_hpp GTest::GTest GTest::Main mraa)
|
||||||
target_include_directories(api_common_hpp_unit PRIVATE "${CMAKE_SOURCE_DIR}/api")
|
target_include_directories(test_unit_common_hpp PRIVATE "${CMAKE_SOURCE_DIR}/api")
|
||||||
gtest_add_tests(api_common_hpp_unit "" AUTO)
|
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)
|
# Unit tests - Test platform extenders (as much as possible)
|
||||||
add_executable(platform_extender platform_extender/platform_extender.cxx)
|
add_executable(test_unit_ftdi4222 platform_extender/platform_extender.cxx)
|
||||||
target_link_libraries(platform_extender GTest::GTest GTest::Main mraa-platform-ft4222 dl)
|
target_link_libraries(test_unit_ftdi4222 GTest::GTest GTest::Main mraa-platform-ft4222 dl)
|
||||||
target_include_directories(platform_extender PRIVATE "${PROJECT_SOURCE_DIR}/api"
|
target_include_directories(test_unit_ftdi4222 PRIVATE "${PROJECT_SOURCE_DIR}/api"
|
||||||
"${PROJECT_SOURCE_DIR}/api/mraa"
|
"${PROJECT_SOURCE_DIR}/api/mraa"
|
||||||
"${PROJECT_SOURCE_DIR}/include")
|
"${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 ()
|
endif ()
|
||||||
|
|
||||||
# Unit tests - C initio header methods
|
# Unit tests - test C initio header methods on MOCK platform only
|
||||||
add_executable(mraa_initio_h_unit api/mraa_initio_h_unit.cxx)
|
if (DETECTED_ARCH STREQUAL "MOCK")
|
||||||
target_link_libraries(mraa_initio_h_unit GTest::GTest GTest::Main mraa)
|
add_executable(test_unit_ioinit_h api/mraa_initio_h_unit.cxx)
|
||||||
target_include_directories(mraa_initio_h_unit PRIVATE "${CMAKE_SOURCE_DIR}/api")
|
target_link_libraries(test_unit_ioinit_h GTest::GTest GTest::Main mraa)
|
||||||
gtest_add_tests(mraa_initio_h_unit "" AUTO)
|
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 a target for all unit tests
|
||||||
add_custom_target(tests-unit ALL
|
add_custom_target(test_unit_all ALL DEPENDS ${GTEST_UNIT_TEST_TARGETS})
|
||||||
DEPENDS
|
|
||||||
api_common_h_unit
|
|
||||||
api_common_hpp_unit
|
|
||||||
platform_extender
|
|
||||||
mraa_initio_h_unit
|
|
||||||
COMMENT "mraa unit test collection")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user