aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Hall <julian.hall@arm.com>2020-11-23 18:24:12 +0100
committerGyorgy Szing <Gyorgy.Szing@arm.com>2020-11-27 16:47:04 +0100
commiteff4b28b6ae461defb2d8c0f614965439ed19386 (patch)
tree64cc4f943734c055c1f2261eca1fd4f6c1b6dffe
parent4061ed60d5327d4a2959a28e5bd8c65e19ca6d00 (diff)
downloadtrusted-services-eff4b28b6ae461defb2d8c0f614965439ed19386.tar.gz
Add testing and demo deployments
Change-Id: Ia13b478ac625e974ceacb22c64ec25b078c8e8ba Signed-off-by: Julian Hall <julian.hall@arm.com>
-rw-r--r--deployments/component-test/arm-linux/CMakeLists.txt34
-rw-r--r--deployments/component-test/component-test.cmake82
-rw-r--r--deployments/component-test/linux-pc/CMakeLists.txt26
-rw-r--r--deployments/ts-demo/arm-linux/.gitignore1
-rw-r--r--deployments/ts-demo/arm-linux/CMakeLists.txt33
-rw-r--r--deployments/ts-demo/linux-pc/CMakeLists.txt26
-rw-r--r--deployments/ts-demo/ts-demo.cmake65
-rw-r--r--deployments/ts-demo/ts-demo.cpp52
-rw-r--r--deployments/ts-service-test/arm-linux/CMakeLists.txt33
-rw-r--r--deployments/ts-service-test/linux-pc/CMakeLists.txt27
-rw-r--r--deployments/ts-service-test/ts-service-test.cmake62
-rw-r--r--tools/b-test/test_data.yaml30
12 files changed, 471 insertions, 0 deletions
diff --git a/deployments/component-test/arm-linux/CMakeLists.txt b/deployments/component-test/arm-linux/CMakeLists.txt
new file mode 100644
index 000000000..4b3353c67
--- /dev/null
+++ b/deployments/component-test/arm-linux/CMakeLists.txt
@@ -0,0 +1,34 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.16)
+include(../../deployment.cmake REQUIRED)
+
+#-------------------------------------------------------------------------------
+# The CMakeLists.txt for building the component-test deployment for arm-linux
+#
+# Used for building and running component level tests as a Linux userspace
+# program running on Arm. Tests can be run by running the built executable
+# called "component-test"
+#-------------------------------------------------------------------------------
+include(${TS_ROOT}/environments/arm-linux/env.cmake)
+project(trusted-services LANGUAGES CXX C)
+add_executable(component-test)
+target_include_directories(component-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+
+#-------------------------------------------------------------------------------
+# Extend with components that are common across all deployments of
+# component-test
+#
+#-------------------------------------------------------------------------------
+include(../component-test.cmake REQUIRED)
+
+#-------------------------------------------------------------------------------
+# Define library options and dependencies.
+#
+#-------------------------------------------------------------------------------
+env_set_link_options(TGT component-test)
+target_link_libraries(component-test PRIVATE stdc++ gcc m)
diff --git a/deployments/component-test/component-test.cmake b/deployments/component-test/component-test.cmake
new file mode 100644
index 000000000..1dc0152a3
--- /dev/null
+++ b/deployments/component-test/component-test.cmake
@@ -0,0 +1,82 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# The base build file shared between deployments of 'component-test' for
+# different environments. Used for running standalone component tests
+# contained within a single executable.
+#-------------------------------------------------------------------------------
+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"
+ "components/common/uuid/test"
+ "components/rpc/common/caller"
+ "components/rpc/common/interface"
+ "components/rpc/direct"
+ "components/rpc/dummy"
+ "components/service/common"
+ "components/service/common/serializer/protobuf"
+ "components/service/common/provider"
+ "components/service/common/provider/test"
+ "components/service/locator"
+ "components/service/locator/interface"
+ "components/service/locator/test"
+ "components/service/locator/standalone"
+ "components/service/locator/standalone/services/crypto"
+ "components/service/crypto/client/cpp"
+ "components/service/crypto/client/test"
+ "components/service/crypto/client/test/standalone"
+ "components/service/crypto/provider/mbedcrypto"
+ "components/service/crypto/provider/mbedcrypto/entropy_source/mock"
+ "components/service/crypto/provider/serializer/protobuf"
+ "components/service/crypto/test/unit"
+ "components/service/crypto/test/service"
+ "components/service/secure_storage/client/psa"
+ "components/service/secure_storage/provider/mock_store"
+ "components/service/secure_storage/provider/secure_flash_store"
+ "components/service/secure_storage/provider/secure_flash_store/flash_fs"
+ "components/service/secure_storage/provider/secure_flash_store/flash"
+ "components/service/secure_storage/test"
+ "protocols/rpc/common/protobuf"
+ "protocols/rpc/common/packed-c"
+ "protocols/rpc/common/packed-c/test"
+ "protocols/service/crypto/packed-c"
+ "protocols/service/crypto/protobuf"
+ "protocols/service/secure_storage/packed-c"
+)
+
+#-------------------------------------------------------------------------------
+# Components used from external projects
+#
+#-------------------------------------------------------------------------------
+
+# 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)
+protobuf_generate_all(TGT "component-test" NAMESPACE "protobuf" BASE_DIR "${TS_ROOT}/protocols")
+
+# Mbedcrypto
+include(${TS_ROOT}/external/mbed-crypto/mbedcrypto.cmake)
+target_link_libraries(component-test PRIVATE mbedcrypto)
+
+#-------------------------------------------------------------------------------
+# Define install content.
+#
+#-------------------------------------------------------------------------------
+if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
+endif()
+install(TARGETS component-test DESTINATION bin) \ No newline at end of file
diff --git a/deployments/component-test/linux-pc/CMakeLists.txt b/deployments/component-test/linux-pc/CMakeLists.txt
new file mode 100644
index 000000000..789bddaca
--- /dev/null
+++ b/deployments/component-test/linux-pc/CMakeLists.txt
@@ -0,0 +1,26 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.16)
+include(../../deployment.cmake REQUIRED)
+
+#-------------------------------------------------------------------------------
+# The CMakeLists.txt for building the component-test deployment for linux-pc
+#
+# Used for building and running component level tests in a native PC enviroment.
+# Tests can be run by running the built executable called "component-test"
+#-------------------------------------------------------------------------------
+include(${TS_ROOT}/environments/linux-pc/env.cmake)
+project(trusted-services LANGUAGES CXX C)
+add_executable(component-test)
+target_include_directories(component-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+
+#-------------------------------------------------------------------------------
+# Extend with components that are common across all deployments of
+# component-test
+#
+#-------------------------------------------------------------------------------
+include(../component-test.cmake REQUIRED)
diff --git a/deployments/ts-demo/arm-linux/.gitignore b/deployments/ts-demo/arm-linux/.gitignore
new file mode 100644
index 000000000..378eac25d
--- /dev/null
+++ b/deployments/ts-demo/arm-linux/.gitignore
@@ -0,0 +1 @@
+build
diff --git a/deployments/ts-demo/arm-linux/CMakeLists.txt b/deployments/ts-demo/arm-linux/CMakeLists.txt
new file mode 100644
index 000000000..8b2fcf431
--- /dev/null
+++ b/deployments/ts-demo/arm-linux/CMakeLists.txt
@@ -0,0 +1,33 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.16)
+include(../../deployment.cmake REQUIRED)
+
+#-------------------------------------------------------------------------------
+# The CMakeLists.txt for building the ts-demo deployment for arm-linux
+#
+# Used for building and running service level tests from Linux user-space
+# on an Arm platform with real deployments of trusted services.
+#-------------------------------------------------------------------------------
+include(${TS_ROOT}/environments/arm-linux/env.cmake)
+project(trusted-services LANGUAGES CXX C)
+add_executable(ts-demo)
+target_include_directories(ts-demo PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+
+#-------------------------------------------------------------------------------
+# Extend with components that are common across all deployments of
+# ts-demo
+#
+#-------------------------------------------------------------------------------
+include(../ts-demo.cmake REQUIRED)
+
+#-------------------------------------------------------------------------------
+# Define library options and dependencies.
+#
+#-------------------------------------------------------------------------------
+env_set_link_options(TGT ts-demo)
+target_link_libraries(ts-demo PRIVATE stdc++ gcc m)
diff --git a/deployments/ts-demo/linux-pc/CMakeLists.txt b/deployments/ts-demo/linux-pc/CMakeLists.txt
new file mode 100644
index 000000000..4d49adc29
--- /dev/null
+++ b/deployments/ts-demo/linux-pc/CMakeLists.txt
@@ -0,0 +1,26 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.16)
+include(../../deployment.cmake REQUIRED)
+
+#-------------------------------------------------------------------------------
+# The CMakeLists.txt for building the ts-demo deployment for linux-pc
+#
+# Used for building and running service level tests from Linux user-space
+# on an Arm platform with real deployments of trusted services.
+#-------------------------------------------------------------------------------
+include(${TS_ROOT}/environments/linux-pc/env.cmake)
+project(trusted-services LANGUAGES CXX C)
+add_executable(ts-demo)
+target_include_directories(ts-demo PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+
+#-------------------------------------------------------------------------------
+# Extend with components that are common across all deployments of
+# ts-demo
+#
+#-------------------------------------------------------------------------------
+include(../ts-demo.cmake REQUIRED)
diff --git a/deployments/ts-demo/ts-demo.cmake b/deployments/ts-demo/ts-demo.cmake
new file mode 100644
index 000000000..4c85a4082
--- /dev/null
+++ b/deployments/ts-demo/ts-demo.cmake
@@ -0,0 +1,65 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# The base build file shared between deployments of 'ts-demo' for
+# different environments. Demonstrates use of trusted services by a
+# client application.
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# Use libts for locating and accessing services. An appropriate version of
+# libts will be imported for the enviroment in which service tests are
+# deployed.
+#-------------------------------------------------------------------------------
+include(${TS_ROOT}/deployments/libts/libts-import.cmake)
+target_link_libraries(ts-demo PRIVATE libts)
+
+#-------------------------------------------------------------------------------
+# Common main for all deployments
+#
+#-------------------------------------------------------------------------------
+target_sources(ts-demo PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}/ts-demo.cpp"
+)
+
+#-------------------------------------------------------------------------------
+# Components that are common accross all deployments
+#
+#-------------------------------------------------------------------------------
+add_components(
+ TARGET "ts-demo"
+ BASE_DIR ${TS_ROOT}
+ COMPONENTS
+ "components/app/ts-demo"
+ "components/service/crypto/client/cpp"
+ "components/service/common/serializer/protobuf"
+ "protocols/service/crypto/protobuf"
+)
+
+#-------------------------------------------------------------------------------
+# Components used from external projects
+#
+#-------------------------------------------------------------------------------
+
+# Nanopb
+include(${TS_ROOT}/external/nanopb/nanopb.cmake)
+target_link_libraries(ts-demo PRIVATE nanopb::protobuf-nanopb-static)
+protobuf_generate_all(TGT "ts-demo" NAMESPACE "protobuf" BASE_DIR "${TS_ROOT}/protocols")
+
+# Mbedcrypto
+include(${TS_ROOT}/external/mbed-crypto/mbedcrypto.cmake)
+target_link_libraries(ts-demo PRIVATE mbedcrypto)
+
+#-------------------------------------------------------------------------------
+# Define install content.
+#
+#-------------------------------------------------------------------------------
+if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
+endif()
+install(TARGETS ts-demo RUNTIME DESTINATION bin) \ No newline at end of file
diff --git a/deployments/ts-demo/ts-demo.cpp b/deployments/ts-demo/ts-demo.cpp
new file mode 100644
index 000000000..e055bad1c
--- /dev/null
+++ b/deployments/ts-demo/ts-demo.cpp
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: BSD-2-Clause
+/*
+ * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+ */
+
+#include <service/crypto/client/cpp/crypto_client.h>
+#include <app/ts-demo/ts-demo.h>
+#include <service_locator.h>
+#include <rpc_caller.h>
+
+int main(int argc, char *argv[]) {
+ (void) argc;
+ (void) argv;
+
+ int status = -1;
+ struct service_context *crypto_service_context = NULL;
+
+ service_locator_init();
+
+ crypto_service_context = service_locator_query("sn:trustedfirmware.org:crypto:0", &status);
+
+ if (crypto_service_context) {
+
+ struct rpc_caller *caller;
+ rpc_session_handle rpc_session_handle;
+
+ rpc_session_handle = service_context_open(crypto_service_context, &caller);
+
+ if (rpc_session_handle) {
+
+ crypto_client crypto_client(caller);
+
+ status = run_ts_demo(&crypto_client, true);
+
+ if (status != 0) {
+ printf("run_ts_demo failed\n");
+ }
+
+ service_context_close(crypto_service_context, rpc_session_handle);
+ }
+ else {
+ printf("Failed to open rpc session\n");
+ }
+
+ service_context_relinquish(crypto_service_context);
+ }
+ else {
+ printf("Failed to discover crypto service\n");
+ }
+
+ return status;
+}
diff --git a/deployments/ts-service-test/arm-linux/CMakeLists.txt b/deployments/ts-service-test/arm-linux/CMakeLists.txt
new file mode 100644
index 000000000..4a6d153b1
--- /dev/null
+++ b/deployments/ts-service-test/arm-linux/CMakeLists.txt
@@ -0,0 +1,33 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.16)
+include(../../deployment.cmake REQUIRED)
+
+#-------------------------------------------------------------------------------
+# The CMakeLists.txt for building the ts-service-test deployment for arm-linux
+#
+# Used for building and running service level tests from Linux user-space
+# on an Arm platform with real deployments of trusted services.
+#-------------------------------------------------------------------------------
+include(${TS_ROOT}/environments/arm-linux/env.cmake)
+project(trusted-services LANGUAGES CXX C)
+add_executable(ts-service-test)
+target_include_directories(ts-service-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+
+#-------------------------------------------------------------------------------
+# Extend with components that are common across all deployments of
+# ts-service-test
+#
+#-------------------------------------------------------------------------------
+include(../ts-service-test.cmake REQUIRED)
+
+#-------------------------------------------------------------------------------
+# Define library options and dependencies.
+#
+#-------------------------------------------------------------------------------
+env_set_link_options(TGT ts-service-test)
+target_link_libraries(ts-service-test PRIVATE stdc++ gcc m) \ No newline at end of file
diff --git a/deployments/ts-service-test/linux-pc/CMakeLists.txt b/deployments/ts-service-test/linux-pc/CMakeLists.txt
new file mode 100644
index 000000000..461bc28b0
--- /dev/null
+++ b/deployments/ts-service-test/linux-pc/CMakeLists.txt
@@ -0,0 +1,27 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.16)
+include(../../deployment.cmake REQUIRED)
+
+#-------------------------------------------------------------------------------
+# The CMakeLists.txt for building the ts-service-test deployment for linux-pc
+#
+# Used for building and running service level tests in a native PC enviroment.
+# Tests can be run by running the built executable called "ts-service-test"
+#-------------------------------------------------------------------------------
+include(${TS_ROOT}/environments/linux-pc/env.cmake)
+project(trusted-services LANGUAGES CXX C)
+add_executable(ts-service-test)
+target_include_directories(ts-service-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+
+#-------------------------------------------------------------------------------
+# Extend with components that are common across all deployments of
+# ts-service-test
+#
+#-------------------------------------------------------------------------------
+include(../ts-service-test.cmake REQUIRED)
+
diff --git a/deployments/ts-service-test/ts-service-test.cmake b/deployments/ts-service-test/ts-service-test.cmake
new file mode 100644
index 000000000..1593188a4
--- /dev/null
+++ b/deployments/ts-service-test/ts-service-test.cmake
@@ -0,0 +1,62 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# The base build file shared between deployments of 'ts-service-test' for
+# different environments. Used for running end-to-end service-level tests
+# where test cases excerise trusted service client interfaces.
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# Use libts for locating and accessing services. An appropriate version of
+# libts will be imported for the enviroment in which service tests are
+# deployed.
+#-------------------------------------------------------------------------------
+include(${TS_ROOT}/deployments/libts/libts-import.cmake)
+target_link_libraries(ts-service-test PRIVATE libts)
+
+#-------------------------------------------------------------------------------
+# Components that are common accross all deployments
+#
+#-------------------------------------------------------------------------------
+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"
+ "protocols/service/crypto/protobuf"
+)
+
+#-------------------------------------------------------------------------------
+# Components used from external projects
+#
+#-------------------------------------------------------------------------------
+
+# 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)
+protobuf_generate_all(TGT "ts-service-test" NAMESPACE "protobuf" BASE_DIR "${TS_ROOT}/protocols")
+
+# Mbedcrypto
+include(${TS_ROOT}/external/mbed-crypto/mbedcrypto.cmake)
+target_link_libraries(ts-service-test PRIVATE mbedcrypto)
+
+#-------------------------------------------------------------------------------
+# Define install content.
+#
+#-------------------------------------------------------------------------------
+if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
+endif()
+install(TARGETS ts-service-test RUNTIME DESTINATION bin) \ No newline at end of file
diff --git a/tools/b-test/test_data.yaml b/tools/b-test/test_data.yaml
index 53824ef2b..e1fcf7a7d 100644
--- a/tools/b-test/test_data.yaml
+++ b/tools/b-test/test_data.yaml
@@ -37,3 +37,33 @@ data:
params:
- "-GUnix Makefiles"
- "-DSP_DEV_KIT_DIR=$SP_DEV_KIT_DIR"
+ - name: "component-test-arm-linux"
+ src: "$TS_ROOT/deployments/component-test/arm-linux"
+ os_id : "GNU/Linux"
+ params:
+ - "-GUnix Makefiles"
+ - name: "component-test-pc-linux"
+ os_id : "GNU/Linux"
+ src: "$TS_ROOT/deployments/component-test/linux-pc"
+ params:
+ - "-GUnix Makefiles"
+ - name: "ts-demo-arm-linux"
+ src: "$TS_ROOT/deployments/ts-demo/arm-linux"
+ os_id : "GNU/Linux"
+ params:
+ - "-GUnix Makefiles"
+ - name: "ts-demo-pc-linux"
+ src: "$TS_ROOT/deployments/ts-demo/linux-pc"
+ os_id : "GNU/Linux"
+ params:
+ - "-GUnix Makefiles"
+ - name: "ts-service-test-arm-linux"
+ src: "$TS_ROOT/deployments/ts-service-test/arm-linux"
+ os_id : "GNU/Linux"
+ params:
+ - "-GUnix Makefiles"
+ - name: "ts-service-test-pc-linux"
+ src: "$TS_ROOT/deployments/ts-service-test/linux-pc"
+ os_id : "GNU/Linux"
+ params:
+ - "-GUnix Makefiles"