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 ts-service-test deployment for linux-pc |
| 12 | # |
| 13 | # Used for building and running service level tests in a native PC enviroment. |
| 14 | # Tests can be run by running the built executable called "ts-service-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 | |
Julian Hall | a7e76c8 | 2021-04-14 11:12:11 +0100 | [diff] [blame] | 19 | # Prevents symbols in the ts-service-test executable overriding symbols with |
| 20 | # with same name in libts during dyanmic linking performed by the program |
| 21 | # loader. This avoid psa crypto api symbols provided by the mbedcrypto |
| 22 | # library from being overridden by the same symbols in the ts-service-test |
| 23 | # executable. |
| 24 | set(CMAKE_C_VISIBILITY_PRESET hidden) |
| 25 | |
Imre Kis | 7cbf6a2 | 2021-01-25 18:50:35 +0100 | [diff] [blame] | 26 | # Preparing firmware-test-build by including it |
| 27 | include(${TS_ROOT}/external/firmware_test_builder/FirmwareTestBuilder.cmake) |
| 28 | |
| 29 | include(CTest) |
| 30 | include(UnitTest) |
| 31 | |
| 32 | set(COVERAGE FALSE CACHE BOOL "Enable code coverage measurement") |
| 33 | set(UNIT_TEST_PROJECT_PATH ${TS_ROOT} CACHE PATH "Path of the project directory") |
| 34 | set(CMAKE_CXX_STANDARD 11) |
| 35 | |
| 36 | unit_test_init_cpputest() |
| 37 | |
| 38 | if (COVERAGE) |
| 39 | include(Coverage) |
| 40 | |
| 41 | set(COVERAGE_FILE "coverage.info") |
| 42 | set(TS_SERVICE_TEST_COVERAGE_FILE "ts-service-test-coverage.info" CACHE PATH "Path of coverage info file") |
| 43 | set(TS_SERVICE_TEST_COVERAGE_REPORT_DIR "${CMAKE_CURRENT_BINARY_DIR}/ts-service-coverage-report" CACHE PATH "Directory of coverage report") |
| 44 | |
| 45 | # Collecting coverage |
| 46 | coverage_generate( |
| 47 | NAME "ts-service test" |
| 48 | SOURCE_DIR ${TS_ROOT} |
| 49 | BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} |
| 50 | OUTPUT_FILE ${COVERAGE_FILE} |
| 51 | ) |
| 52 | |
| 53 | # Filtering project file coverage |
| 54 | coverage_filter( |
| 55 | INPUT_FILE ${COVERAGE_FILE} |
| 56 | OUTPUT_FILE ${TS_SERVICE_TEST_COVERAGE_FILE} |
| 57 | INCLUDE_DIRECTORY ${UNIT_TEST_PROJECT_PATH}/components |
| 58 | ) |
| 59 | |
| 60 | # Coverage report |
| 61 | coverage_generate_report( |
| 62 | INPUT_FILE ${TS_SERVICE_TEST_COVERAGE_FILE} |
| 63 | OUTPUT_DIRECTORY ${TS_SERVICE_TEST_COVERAGE_REPORT_DIR} |
| 64 | ) |
| 65 | endif() |
| 66 | |
| 67 | unit_test_add_suite( |
| 68 | NAME ts-service-test |
| 69 | ) |
| 70 | |
Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 71 | target_include_directories(ts-service-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
| 72 | |
| 73 | #------------------------------------------------------------------------------- |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 74 | # Components that are specific to deployment in the linux-pc environment. |
| 75 | # |
| 76 | #------------------------------------------------------------------------------- |
| 77 | add_components( |
| 78 | TARGET "ts-service-test" |
| 79 | BASE_DIR ${TS_ROOT} |
| 80 | COMPONENTS |
| 81 | "components/service/test_runner/client/cpp" |
| 82 | "components/service/test_runner/test/service" |
Julian Hall | 700aa36 | 2021-05-13 15:30:39 +0100 | [diff] [blame] | 83 | "components/service/attestation/include" |
| 84 | "components/service/attestation/client/psa" |
Julian Hall | 482fd2f | 2021-05-17 16:34:48 +0100 | [diff] [blame] | 85 | "components/service/attestation/client/provision" |
Julian Hall | 700aa36 | 2021-05-13 15:30:39 +0100 | [diff] [blame] | 86 | "components/service/attestation/test/service" |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 87 | ) |
| 88 | |
| 89 | #------------------------------------------------------------------------------- |
Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 90 | # Extend with components that are common across all deployments of |
| 91 | # ts-service-test |
| 92 | # |
| 93 | #------------------------------------------------------------------------------- |
| 94 | include(../ts-service-test.cmake REQUIRED) |