aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorImre Kis <imre.kis@arm.com>2021-01-14 21:10:51 +0100
committerGy├Ârgy Szing <gyorgy.szing@arm.com>2021-02-23 23:09:36 +0000
commitd4ed6597787eb55579a91e5af408dc9c476b7df5 (patch)
treeedeec9a966eed72bc8214721b68e0ede4b136249
parent36ef73a2fee59ca36332867f35faa04963912fc2 (diff)
downloadtrusted-services-d4ed6597787eb55579a91e5af408dc9c476b7df5.tar.gz
libsp: Integrate firmware-test-builder
Use firmware-test-builder for unit testing libsp on the host machine. Change-Id: I32139e6ce476358e3265fe03f33eb20ebac00db4 Signed-off-by: Imre Kis <imre.kis@arm.com>
-rw-r--r--components/messaging/ffa/libsp/tests.cmake18
-rw-r--r--deployments/libsp/linux-pc/CMakeLists.txt54
-rw-r--r--external/firmware_test_builder/FirmwareTestBuilder.cmake34
-rw-r--r--requirements.txt5
-rw-r--r--tools/b-test/test_data.yaml5
5 files changed, 106 insertions, 10 deletions
diff --git a/components/messaging/ffa/libsp/tests.cmake b/components/messaging/ffa/libsp/tests.cmake
index 7096916..1658033 100644
--- a/components/messaging/ffa/libsp/tests.cmake
+++ b/components/messaging/ffa/libsp/tests.cmake
@@ -13,7 +13,7 @@ unit_test_add_suite(
${CMAKE_CURRENT_LIST_DIR}/test/test_mock_assert.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
- ${PROJECT_PATH}/components/common/utils/include
+ ${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
)
@@ -25,7 +25,7 @@ unit_test_add_suite(
${CMAKE_CURRENT_LIST_DIR}/test/test_mock_ffa_internal_api.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
- ${PROJECT_PATH}/components/common/utils/include
+ ${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
)
@@ -41,7 +41,7 @@ unit_test_add_suite(
${CMAKE_CURRENT_LIST_DIR}/test/mock_assert.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
- ${PROJECT_PATH}/components/common/utils/include
+ ${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
)
@@ -53,7 +53,7 @@ unit_test_add_suite(
${CMAKE_CURRENT_LIST_DIR}/test/mock_ffa_api.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
- ${PROJECT_PATH}/components/common/utils/include
+ ${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
)
@@ -66,7 +66,7 @@ unit_test_add_suite(
${CMAKE_CURRENT_LIST_DIR}/sp_rxtx.c
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
- ${PROJECT_PATH}/components/common/utils/include
+ ${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
)
@@ -78,7 +78,7 @@ unit_test_add_suite(
${CMAKE_CURRENT_LIST_DIR}/test/mock_sp_rxtx.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
- ${PROJECT_PATH}/components/common/utils/include
+ ${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
)
@@ -92,7 +92,7 @@ unit_test_add_suite(
${CMAKE_CURRENT_LIST_DIR}/test/mock_sp_rxtx.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
- ${PROJECT_PATH}/components/common/utils/include
+ ${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
)
@@ -108,7 +108,7 @@ unit_test_add_suite(
${CMAKE_CURRENT_LIST_DIR}/test/mock_sp_rxtx.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
- ${PROJECT_PATH}/components/common/utils/include
+ ${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
)
@@ -122,7 +122,7 @@ unit_test_add_suite(
${CMAKE_CURRENT_LIST_DIR}/test/mock_assert.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
- ${PROJECT_PATH}/components/common/utils/include
+ ${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
)
diff --git a/deployments/libsp/linux-pc/CMakeLists.txt b/deployments/libsp/linux-pc/CMakeLists.txt
new file mode 100644
index 0000000..2b50c97
--- /dev/null
+++ b/deployments/libsp/linux-pc/CMakeLists.txt
@@ -0,0 +1,54 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.16)
+include(../../deployment.cmake REQUIRED)
+
+project(libsp-unit-tests LANGUAGES CXX C)
+
+# 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(LIBSP_COVERAGE_FILE "libsp-coverage.info" CACHE PATH "Path of coverage info file")
+ set(LIBSP_COVERAGE_REPORT_DIR "${CMAKE_CURRENT_BINARY_DIR}/libsp-coverage-report" CACHE PATH "Directory of coverage report")
+
+ # Collecting coverage
+ coverage_generate(
+ NAME "libsp unit 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 ${LIBSP_COVERAGE_FILE}
+ INCLUDE_DIRECTORY ${UNIT_TEST_PROJECT_PATH}/components/messaging/ffa/libsp
+ )
+
+ # Coverage report
+ coverage_generate_report(
+ INPUT_FILE ${LIBSP_COVERAGE_FILE}
+ OUTPUT_DIRECTORY ${LIBSP_COVERAGE_REPORT_DIR}
+ )
+endif()
+
+# Including test suite descriptions
+include(${TS_ROOT}/components/messaging/ffa/libsp/tests.cmake)
diff --git a/external/firmware_test_builder/FirmwareTestBuilder.cmake b/external/firmware_test_builder/FirmwareTestBuilder.cmake
new file mode 100644
index 0000000..4a4cf08
--- /dev/null
+++ b/external/firmware_test_builder/FirmwareTestBuilder.cmake
@@ -0,0 +1,34 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+include(FetchContent)
+
+set(FIRMWARE_TEST_BUILDER_URL "https://git.trustedfirmware.org/TS/trusted-services.git" CACHE STRING "firmware-test-builder repository URL")
+set(FIRMWARE_TEST_BUILDER_REFSPEC "topics/fwtb" CACHE STRING "firmware-test-builder git refspec")
+
+# Checking git
+find_program(GIT_COMMAND "git")
+if (NOT GIT_COMMAND)
+ message(FATAL_ERROR "Please install git")
+endif()
+
+# Fetching firmware-test-builder
+FetchContent_Declare(
+ firmware_test_builder
+ GIT_REPOSITORY ${FIRMWARE_TEST_BUILDER_URL}
+ GIT_TAG ${FIRMWARE_TEST_BUILDER_REFSPEC}
+ GIT_SHALLOW TRUE
+)
+
+FetchContent_GetProperties(firmware_test_builder)
+if(NOT firmware_test_builder_POPULATED)
+ message(STATUS "Fetching Firmware Test Builder")
+ FetchContent_Populate(firmware_test_builder)
+endif()
+
+# Appending firmware-test-builder's CMake directory to CMake module path
+list(APPEND CMAKE_MODULE_PATH ${firmware_test_builder_SOURCE_DIR}/cmake) \ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index 78caa84..7017f69 100644
--- a/requirements.txt
+++ b/requirements.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
#
@@ -12,3 +12,6 @@
# Include packages needed for build test tool
-r tools/b-test/requirements.txt
+
+# Include c-picker needed for firmware-test-builder
+git+https://git.trustedfirmware.org/TS/trusted-services.git@topics/c-picker
diff --git a/tools/b-test/test_data.yaml b/tools/b-test/test_data.yaml
index e1fcf7a..74cf29e 100644
--- a/tools/b-test/test_data.yaml
+++ b/tools/b-test/test_data.yaml
@@ -11,6 +11,11 @@ data:
params:
- "-GUnix Makefiles"
- "-DSP_DEV_KIT_DIR=$SP_DEV_KIT_DIR"
+ - name: "libsp-linux-pc"
+ src: "$TS_ROOT/deployments/libsp/linux-pc"
+ os_id : "GNU/Linux"
+ params:
+ - "-GUnix Makefiles"
- name: "libts-arm-linux"
src: "$TS_ROOT/deployments/libts/arm-linux"
os_id : "GNU/Linux"