blob: be6e98404f59be01849eda60e57127735e1a6745 [file] [log] [blame]
Julian Hall1911a122021-12-06 15:20:12 +00001#-------------------------------------------------------------------------------
2# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7cmake_minimum_required(VERSION 3.16)
8include(../../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#-------------------------------------------------------------------------------
16include(${TS_ROOT}/environments/linux-pc/env.cmake)
17project(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.
22set(CMAKE_C_VISIBILITY_PRESET hidden)
23
24# Preparing firmware-test-build by including it
25include(${TS_ROOT}/external/firmware_test_builder/FirmwareTestBuilder.cmake)
26
27include(CTest)
28include(UnitTest)
29
30set(COVERAGE FALSE CACHE BOOL "Enable code coverage measurement")
31set(UNIT_TEST_PROJECT_PATH ${TS_ROOT} CACHE PATH "Path of the project directory")
32set(CMAKE_CXX_STANDARD 11)
33
34unit_test_init_cpputest()
35
36if (COVERAGE)
37 include(Coverage)
38
39 set(COVERAGE_FILE "coverage.info")
40 set(TS_SERVICE_TEST_COVERAGE_FILE "uefi-test-coverage.info" CACHE PATH "Path of coverage info file")
41 set(TS_SERVICE_TEST_COVERAGE_REPORT_DIR "${CMAKE_CURRENT_BINARY_DIR}/ts-service-coverage-report" CACHE PATH "Directory of coverage report")
42
43 # Collecting coverage
44 coverage_generate(
45 NAME "ts-service test"
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}
54 OUTPUT_FILE ${TS_SERVICE_TEST_COVERAGE_FILE}
55 INCLUDE_DIRECTORY ${UNIT_TEST_PROJECT_PATH}/components
56 )
57
58 # Coverage report
59 coverage_generate_report(
60 INPUT_FILE ${TS_SERVICE_TEST_COVERAGE_FILE}
61 OUTPUT_DIRECTORY ${TS_SERVICE_TEST_COVERAGE_REPORT_DIR}
62 )
63endif()
64
65unit_test_add_suite(
66 NAME uefi-test
67)
68
69target_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#-------------------------------------------------------------------------------
76include(../uefi-test.cmake REQUIRED)