Julian Hall | 1911a12 | 2021-12-06 15:20:12 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Balint Dobszay | 047aea8 | 2022-05-16 14:20:53 +0200 | [diff] [blame] | 2 | # Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved. |
Julian Hall | 1911a12 | 2021-12-06 15:20:12 +0000 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
Balint Dobszay | 047aea8 | 2022-05-16 14:20:53 +0200 | [diff] [blame] | 7 | cmake_minimum_required(VERSION 3.18 FATAL_ERROR) |
Julian Hall | 1911a12 | 2021-12-06 15:20:12 +0000 | [diff] [blame] | 8 | include(../../deployment.cmake REQUIRED) |
| 9 | |
| 10 | #------------------------------------------------------------------------------- |
| 11 | # The CMakeLists.txt for building the uefi-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 "uefi-test" |
| 15 | #------------------------------------------------------------------------------- |
| 16 | include(${TS_ROOT}/environments/linux-pc/env.cmake) |
| 17 | project(trusted-services LANGUAGES CXX C) |
| 18 | |
| 19 | # Prevents symbols in the uefi-test executable overriding symbols with |
| 20 | # with same name in libts during dynamic linking performed by the program |
| 21 | # loader. |
| 22 | set(CMAKE_C_VISIBILITY_PRESET hidden) |
| 23 | |
| 24 | # Preparing firmware-test-build by including it |
| 25 | include(${TS_ROOT}/external/firmware_test_builder/FirmwareTestBuilder.cmake) |
| 26 | |
| 27 | include(CTest) |
| 28 | include(UnitTest) |
| 29 | |
| 30 | set(COVERAGE FALSE CACHE BOOL "Enable code coverage measurement") |
| 31 | set(UNIT_TEST_PROJECT_PATH ${TS_ROOT} CACHE PATH "Path of the project directory") |
| 32 | set(CMAKE_CXX_STANDARD 11) |
| 33 | |
| 34 | unit_test_init_cpputest() |
| 35 | |
| 36 | if (COVERAGE) |
| 37 | include(Coverage) |
| 38 | |
| 39 | set(COVERAGE_FILE "coverage.info") |
Imre Kis | 0292222 | 2024-01-29 16:36:51 +0100 | [diff] [blame] | 40 | set(UEFI_TEST_COVERAGE_FILE "uefi-test-coverage.info" CACHE PATH "Path of coverage info file") |
| 41 | set(UEFI_TEST_COVERAGE_REPORT_DIR "${CMAKE_CURRENT_BINARY_DIR}/uefi-test-coverage-report" CACHE PATH "Directory of coverage report") |
Julian Hall | 1911a12 | 2021-12-06 15:20:12 +0000 | [diff] [blame] | 42 | |
| 43 | # Collecting coverage |
| 44 | coverage_generate( |
Imre Kis | 0292222 | 2024-01-29 16:36:51 +0100 | [diff] [blame] | 45 | NAME "uefi-test" |
Julian Hall | 1911a12 | 2021-12-06 15:20:12 +0000 | [diff] [blame] | 46 | SOURCE_DIR ${TS_ROOT} |
| 47 | BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} |
| 48 | OUTPUT_FILE ${COVERAGE_FILE} |
| 49 | ) |
| 50 | |
| 51 | # Filtering project file coverage |
| 52 | coverage_filter( |
| 53 | INPUT_FILE ${COVERAGE_FILE} |
Imre Kis | 0292222 | 2024-01-29 16:36:51 +0100 | [diff] [blame] | 54 | OUTPUT_FILE ${UEFI_TEST_COVERAGE_FILE} |
Julian Hall | 1911a12 | 2021-12-06 15:20:12 +0000 | [diff] [blame] | 55 | INCLUDE_DIRECTORY ${UNIT_TEST_PROJECT_PATH}/components |
| 56 | ) |
| 57 | |
| 58 | # Coverage report |
| 59 | coverage_generate_report( |
Imre Kis | 0292222 | 2024-01-29 16:36:51 +0100 | [diff] [blame] | 60 | INPUT_FILE ${UEFI_TEST_COVERAGE_FILE} |
| 61 | OUTPUT_DIRECTORY ${UEFI_TEST_COVERAGE_REPORT_DIR} |
Julian Hall | 1911a12 | 2021-12-06 15:20:12 +0000 | [diff] [blame] | 62 | ) |
| 63 | endif() |
| 64 | |
| 65 | unit_test_add_suite( |
| 66 | NAME uefi-test |
| 67 | ) |
| 68 | |
| 69 | target_include_directories(uefi-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
| 70 | |
| 71 | #------------------------------------------------------------------------------- |
| 72 | # Extend with components that are common across all deployments of |
| 73 | # uefi-test |
| 74 | # |
| 75 | #------------------------------------------------------------------------------- |
| 76 | include(../uefi-test.cmake REQUIRED) |