aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorImre Kis <imre.kis@arm.com>2021-01-25 18:50:35 +0100
committerGy├Ârgy Szing <gyorgy.szing@arm.com>2021-02-23 23:09:36 +0000
commit7cbf6a24b01d8b62f20a499e0ad3e16d024eeabf (patch)
treee6f5001e64ab762e670a840d60a90fc860821e4e
parentd4ed6597787eb55579a91e5af408dc9c476b7df5 (diff)
downloadtrusted-services-7cbf6a24b01d8b62f20a499e0ad3e16d024eeabf.tar.gz
Use firmware-test-builder in existing tests
Use firmware-test-builder for driving component-test and ts-service-test. Change-Id: I5a728395eaa0459188fb92f1355f3d62e86a65ca Signed-off-by: Imre Kis <imre.kis@arm.com>
-rw-r--r--deployments/component-test/arm-linux/CMakeLists.txt9
-rw-r--r--deployments/component-test/component-test.cmake5
-rw-r--r--deployments/component-test/linux-pc/CMakeLists.txt49
-rw-r--r--deployments/ts-service-test/arm-linux/CMakeLists.txt11
-rw-r--r--deployments/ts-service-test/linux-pc/CMakeLists.txt49
-rw-r--r--deployments/ts-service-test/ts-service-test.cmake5
6 files changed, 113 insertions, 15 deletions
diff --git a/deployments/component-test/arm-linux/CMakeLists.txt b/deployments/component-test/arm-linux/CMakeLists.txt
index 4b3353c..d96a793 100644
--- a/deployments/component-test/arm-linux/CMakeLists.txt
+++ b/deployments/component-test/arm-linux/CMakeLists.txt
@@ -19,6 +19,15 @@ project(trusted-services LANGUAGES CXX C)
add_executable(component-test)
target_include_directories(component-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+add_components(
+ TARGET "component-test"
+ BASE_DIR ${TS_ROOT}
+ COMPONENTS "components/app/test-runner"
+)
+
+include(${TS_ROOT}/external/CppUTest/CppUTest.cmake)
+target_link_libraries(component-test PRIVATE CppUTest)
+
#-------------------------------------------------------------------------------
# Extend with components that are common across all deployments of
# component-test
diff --git a/deployments/component-test/component-test.cmake b/deployments/component-test/component-test.cmake
index 831e6ec..3af6d02 100644
--- a/deployments/component-test/component-test.cmake
+++ b/deployments/component-test/component-test.cmake
@@ -14,7 +14,6 @@ add_components(
TARGET "component-test"
BASE_DIR ${TS_ROOT}
COMPONENTS
- "components/app/test-runner"
"components/app/ts-demo"
"components/app/ts-demo/test"
"components/common/uuid"
@@ -59,10 +58,6 @@ add_components(
#
#-------------------------------------------------------------------------------
-# CppUTest
-include(${TS_ROOT}/external/CppUTest/CppUTest.cmake)
-target_link_libraries(component-test PRIVATE CppUTest)
-
# Nanopb
include(${TS_ROOT}/external/nanopb/nanopb.cmake)
target_link_libraries(component-test PRIVATE nanopb::protobuf-nanopb-static)
diff --git a/deployments/component-test/linux-pc/CMakeLists.txt b/deployments/component-test/linux-pc/CMakeLists.txt
index 789bdda..3e56d83 100644
--- a/deployments/component-test/linux-pc/CMakeLists.txt
+++ b/deployments/component-test/linux-pc/CMakeLists.txt
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -15,7 +15,52 @@ include(../../deployment.cmake REQUIRED)
#-------------------------------------------------------------------------------
include(${TS_ROOT}/environments/linux-pc/env.cmake)
project(trusted-services LANGUAGES CXX C)
-add_executable(component-test)
+
+# Preparing firmware-test-build by including it
+include(${TS_ROOT}/external/firmware_test_builder/FirmwareTestBuilder.cmake)
+
+include(CTest)
+include(UnitTest)
+
+set(COVERAGE FALSE CACHE BOOL "Enable code coverage measurement")
+set(UNIT_TEST_PROJECT_PATH ${TS_ROOT} CACHE PATH "Path of the project directory")
+set(CMAKE_CXX_STANDARD 11)
+
+unit_test_init_cpputest()
+
+if (COVERAGE)
+ include(Coverage)
+
+ set(COVERAGE_FILE "coverage.info")
+ set(COMPONENT_TEST_COVERAGE_FILE "component-test-coverage.info" CACHE PATH "Path of coverage info file")
+ set(COMPONENT_TEST_COVERAGE_REPORT_DIR "${CMAKE_CURRENT_BINARY_DIR}/component-test-coverage-report" CACHE PATH "Directory of coverage report")
+
+ # Collecting coverage
+ coverage_generate(
+ NAME "Component test"
+ SOURCE_DIR ${TS_ROOT}
+ BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}
+ OUTPUT_FILE ${COVERAGE_FILE}
+ )
+
+ # Filtering project file coverage
+ coverage_filter(
+ INPUT_FILE ${COVERAGE_FILE}
+ OUTPUT_FILE ${COMPONENT_TEST_COVERAGE_FILE}
+ INCLUDE_DIRECTORY ${UNIT_TEST_PROJECT_PATH}/components
+ )
+
+ # Coverage report
+ coverage_generate_report(
+ INPUT_FILE ${COMPONENT_TEST_COVERAGE_FILE}
+ OUTPUT_DIRECTORY ${COMPONENT_TEST_COVERAGE_REPORT_DIR}
+ )
+endif()
+
+unit_test_add_suite(
+ NAME component-test
+)
+
target_include_directories(component-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
#-------------------------------------------------------------------------------
diff --git a/deployments/ts-service-test/arm-linux/CMakeLists.txt b/deployments/ts-service-test/arm-linux/CMakeLists.txt
index 4a6d153..fd73a45 100644
--- a/deployments/ts-service-test/arm-linux/CMakeLists.txt
+++ b/deployments/ts-service-test/arm-linux/CMakeLists.txt
@@ -18,6 +18,15 @@ project(trusted-services LANGUAGES CXX C)
add_executable(ts-service-test)
target_include_directories(ts-service-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+add_components(
+ TARGET "ts-service-test"
+ BASE_DIR ${TS_ROOT}
+ COMPONENTS "components/app/test-runner"
+ )
+
+include(${TS_ROOT}/external/CppUTest/CppUTest.cmake)
+target_link_libraries(ts-service-test PRIVATE CppUTest)
+
#-------------------------------------------------------------------------------
# Extend with components that are common across all deployments of
# ts-service-test
@@ -30,4 +39,4 @@ include(../ts-service-test.cmake REQUIRED)
#
#-------------------------------------------------------------------------------
env_set_link_options(TGT ts-service-test)
-target_link_libraries(ts-service-test PRIVATE stdc++ gcc m) \ No newline at end of file
+target_link_libraries(ts-service-test PRIVATE stdc++ gcc m)
diff --git a/deployments/ts-service-test/linux-pc/CMakeLists.txt b/deployments/ts-service-test/linux-pc/CMakeLists.txt
index 461bc28..8ccc3b3 100644
--- a/deployments/ts-service-test/linux-pc/CMakeLists.txt
+++ b/deployments/ts-service-test/linux-pc/CMakeLists.txt
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -15,7 +15,52 @@ include(../../deployment.cmake REQUIRED)
#-------------------------------------------------------------------------------
include(${TS_ROOT}/environments/linux-pc/env.cmake)
project(trusted-services LANGUAGES CXX C)
-add_executable(ts-service-test)
+
+# Preparing firmware-test-build by including it
+include(${TS_ROOT}/external/firmware_test_builder/FirmwareTestBuilder.cmake)
+
+include(CTest)
+include(UnitTest)
+
+set(COVERAGE FALSE CACHE BOOL "Enable code coverage measurement")
+set(UNIT_TEST_PROJECT_PATH ${TS_ROOT} CACHE PATH "Path of the project directory")
+set(CMAKE_CXX_STANDARD 11)
+
+unit_test_init_cpputest()
+
+if (COVERAGE)
+ include(Coverage)
+
+ set(COVERAGE_FILE "coverage.info")
+ set(TS_SERVICE_TEST_COVERAGE_FILE "ts-service-test-coverage.info" CACHE PATH "Path of coverage info file")
+ set(TS_SERVICE_TEST_COVERAGE_REPORT_DIR "${CMAKE_CURRENT_BINARY_DIR}/ts-service-coverage-report" CACHE PATH "Directory of coverage report")
+
+ # Collecting coverage
+ coverage_generate(
+ NAME "ts-service test"
+ SOURCE_DIR ${TS_ROOT}
+ BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}
+ OUTPUT_FILE ${COVERAGE_FILE}
+ )
+
+ # Filtering project file coverage
+ coverage_filter(
+ INPUT_FILE ${COVERAGE_FILE}
+ OUTPUT_FILE ${TS_SERVICE_TEST_COVERAGE_FILE}
+ INCLUDE_DIRECTORY ${UNIT_TEST_PROJECT_PATH}/components
+ )
+
+ # Coverage report
+ coverage_generate_report(
+ INPUT_FILE ${TS_SERVICE_TEST_COVERAGE_FILE}
+ OUTPUT_DIRECTORY ${TS_SERVICE_TEST_COVERAGE_REPORT_DIR}
+ )
+endif()
+
+unit_test_add_suite(
+ NAME ts-service-test
+)
+
target_include_directories(ts-service-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
#-------------------------------------------------------------------------------
diff --git a/deployments/ts-service-test/ts-service-test.cmake b/deployments/ts-service-test/ts-service-test.cmake
index 80bf6fd..5630a99 100644
--- a/deployments/ts-service-test/ts-service-test.cmake
+++ b/deployments/ts-service-test/ts-service-test.cmake
@@ -27,7 +27,6 @@ add_components(
TARGET "ts-service-test"
BASE_DIR ${TS_ROOT}
COMPONENTS
- "components/app/test-runner"
"components/service/crypto/test/service"
"components/service/crypto/client/cpp"
"components/service/common/serializer/protobuf"
@@ -39,10 +38,6 @@ add_components(
#
#-------------------------------------------------------------------------------
-# CppUTest
-include(${TS_ROOT}/external/CppUTest/CppUTest.cmake)
-target_link_libraries(ts-service-test PRIVATE CppUTest)
-
# Nanopb
include(${TS_ROOT}/external/nanopb/nanopb.cmake)
target_link_libraries(ts-service-test PRIVATE nanopb::protobuf-nanopb-static)