Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Imre Kis | 7cbf6a2 | 2021-01-25 18:50:35 +0100 | [diff] [blame] | 2 | # Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. |
Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | cmake_minimum_required(VERSION 3.16) |
| 8 | include(../../deployment.cmake REQUIRED) |
| 9 | |
| 10 | #------------------------------------------------------------------------------- |
| 11 | # The CMakeLists.txt for building the component-test deployment for linux-pc |
| 12 | # |
| 13 | # Used for building and running component level tests in a native PC enviroment. |
| 14 | # Tests can be run by running the built executable called "component-test" |
| 15 | #------------------------------------------------------------------------------- |
| 16 | include(${TS_ROOT}/environments/linux-pc/env.cmake) |
| 17 | project(trusted-services LANGUAGES CXX C) |
Imre Kis | 7cbf6a2 | 2021-01-25 18:50:35 +0100 | [diff] [blame] | 18 | |
| 19 | # Preparing firmware-test-build by including it |
| 20 | include(${TS_ROOT}/external/firmware_test_builder/FirmwareTestBuilder.cmake) |
| 21 | |
| 22 | include(CTest) |
| 23 | include(UnitTest) |
| 24 | |
| 25 | set(COVERAGE FALSE CACHE BOOL "Enable code coverage measurement") |
| 26 | set(UNIT_TEST_PROJECT_PATH ${TS_ROOT} CACHE PATH "Path of the project directory") |
| 27 | set(CMAKE_CXX_STANDARD 11) |
| 28 | |
| 29 | unit_test_init_cpputest() |
| 30 | |
| 31 | if (COVERAGE) |
| 32 | include(Coverage) |
| 33 | |
| 34 | set(COVERAGE_FILE "coverage.info") |
| 35 | set(COMPONENT_TEST_COVERAGE_FILE "component-test-coverage.info" CACHE PATH "Path of coverage info file") |
| 36 | set(COMPONENT_TEST_COVERAGE_REPORT_DIR "${CMAKE_CURRENT_BINARY_DIR}/component-test-coverage-report" CACHE PATH "Directory of coverage report") |
| 37 | |
| 38 | # Collecting coverage |
| 39 | coverage_generate( |
| 40 | NAME "Component test" |
| 41 | SOURCE_DIR ${TS_ROOT} |
| 42 | BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} |
| 43 | OUTPUT_FILE ${COVERAGE_FILE} |
| 44 | ) |
| 45 | |
| 46 | # Filtering project file coverage |
| 47 | coverage_filter( |
| 48 | INPUT_FILE ${COVERAGE_FILE} |
| 49 | OUTPUT_FILE ${COMPONENT_TEST_COVERAGE_FILE} |
| 50 | INCLUDE_DIRECTORY ${UNIT_TEST_PROJECT_PATH}/components |
| 51 | ) |
| 52 | |
| 53 | # Coverage report |
| 54 | coverage_generate_report( |
| 55 | INPUT_FILE ${COMPONENT_TEST_COVERAGE_FILE} |
| 56 | OUTPUT_DIRECTORY ${COMPONENT_TEST_COVERAGE_REPORT_DIR} |
| 57 | ) |
| 58 | endif() |
| 59 | |
| 60 | unit_test_add_suite( |
| 61 | NAME component-test |
| 62 | ) |
| 63 | |
Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 64 | target_include_directories(component-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
| 65 | |
| 66 | #------------------------------------------------------------------------------- |
julhal01 | ffa98d8 | 2021-01-20 13:51:58 +0000 | [diff] [blame] | 67 | # Components that are specific to deployment in the linux-pc environment. |
| 68 | # |
| 69 | #------------------------------------------------------------------------------- |
| 70 | add_components( |
| 71 | TARGET "component-test" |
| 72 | BASE_DIR ${TS_ROOT} |
| 73 | COMPONENTS |
Julian Hall | 9061e6c | 2021-06-29 14:24:20 +0100 | [diff] [blame] | 74 | "components/service/crypto/backend/mbedcrypto/trng_adapter/linux" |
julhal01 | ffa98d8 | 2021-01-20 13:51:58 +0000 | [diff] [blame] | 75 | ) |
| 76 | |
| 77 | #------------------------------------------------------------------------------- |
Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 78 | # Extend with components that are common across all deployments of |
| 79 | # component-test |
| 80 | # |
| 81 | #------------------------------------------------------------------------------- |
| 82 | include(../component-test.cmake REQUIRED) |