File: tests.cmake

package info (click to toggle)
iceoryx 2.0.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,296 kB
  • sloc: cpp: 94,119; ansic: 1,443; sh: 1,436; python: 1,377; xml: 100; makefile: 65
file content (83 lines) | stat: -rw-r--r-- 3,121 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright (c) 2020 - 2021 by Apex.AI Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.16)

if (BUILD_TEST)
    find_package(GTest REQUIRED)

    ### create component list
    set(COMPONENTS "hoofs" "posh")

    ### possible place for more extensions
    if (DDS_GATEWAY)
        list(APPEND COMPONENTS "dds_gateway")
    endif()
    if (BINDING_C)
        list(APPEND COMPONENTS "binding_c")
    endif()

    ### create test targets without Timing tests
    foreach(cmp IN ITEMS ${COMPONENTS})
        list(APPEND MODULETEST_CMD COMMAND ./${cmp}/test/${cmp}_moduletests --gtest_filter=-*.TimingTest_* --gtest_output=xml:${CMAKE_BINARY_DIR}/testresults/${cmp}_ModuleTestResults.xml)
    endforeach()

    foreach(cmp IN ITEMS ${COMPONENTS})
        if(NOT (cmp STREQUAL "dds_gateway" OR cmp STREQUAL "binding_c"))
            list(APPEND INTEGRATIONTEST_CMD COMMAND ./${cmp}/test/${cmp}_integrationtests --gtest_filter=-*.TimingTest_* --gtest_output=xml:${CMAKE_BINARY_DIR}/testresults/${cmp}_IntegrationTestResults.xml)
        endif()
    endforeach()
        
    add_custom_target( all_tests
        ${MODULETEST_CMD}
        ${INTEGRATIONTEST_CMD}
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
        VERBATIM
    )

    ### we need to create separate test targets for coverage scan
    add_custom_target( module_tests
        ${MODULETEST_CMD}
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
        VERBATIM
    )

    add_custom_target( integration_tests
        ${INTEGRATIONTEST_CMD}
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    VERBATIM
    )

    ### create test target with Timing tests
    foreach(cmp IN ITEMS ${COMPONENTS})
        list(APPEND TIMING_MODULETEST_CMD COMMAND ./${cmp}/test/${cmp}_moduletests --gtest_filter=*.TimingTest_* --gtest_output=xml:${CMAKE_BINARY_DIR}/testresults/${cmp}_TimingModuleTestResults.xml)
        if(NOT (cmp STREQUAL "dds_gateway" OR cmp STREQUAL "binding_c"))
            list(APPEND TIMING_INTEGRATIONTEST_CMD COMMAND ./${cmp}/test/${cmp}_integrationtests --gtest_filter=*.TimingTest_* --gtest_output=xml:${CMAKE_BINARY_DIR}/testresults/${cmp}_TimingIntegrationTestResults.xml)
        endif()    
    endforeach()

    add_custom_target( timing_module_tests
        ${TIMING_MODULETEST_CMD}
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
        VERBATIM
    )

    add_custom_target( timing_integration_tests
        ${TIMING_INTEGRATIONTEST_CMD}
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
        VERBATIM
    )

endif()