Add test_runner service
This is a new service with client and provider that can be
used for running tests in a secure processing environment
and retrieving the results. The test_runner provider allows
for arbitrary test farmework backends. The goal is to
have a cpputest backend. In this commit, a mock backend
is included for testing the service itself. The service
has its own access protocol defined under the protocols
top-level directory.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: If4e965c110763bd805abbdcb87e7e03cd76248b2
diff --git a/deployments/ts-remote-test/arm-linux/.gitignore b/deployments/ts-remote-test/arm-linux/.gitignore
new file mode 100644
index 0000000..378eac2
--- /dev/null
+++ b/deployments/ts-remote-test/arm-linux/.gitignore
@@ -0,0 +1 @@
+build
diff --git a/deployments/ts-remote-test/arm-linux/CMakeLists.txt b/deployments/ts-remote-test/arm-linux/CMakeLists.txt
new file mode 100644
index 0000000..7540178
--- /dev/null
+++ b/deployments/ts-remote-test/arm-linux/CMakeLists.txt
@@ -0,0 +1,31 @@
+#-------------------------------------------------------------------------------
+# 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)
+
+#-------------------------------------------------------------------------------
+# The CMakeLists.txt for building the ts-remote-test deployment for arm-linux
+#
+#-------------------------------------------------------------------------------
+include(${TS_ROOT}/environments/arm-linux/env.cmake)
+project(trusted-services LANGUAGES CXX C)
+add_executable(ts-remote-test)
+target_include_directories(ts-remote-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+
+#-------------------------------------------------------------------------------
+# Extend with components that are common across all deployments of
+# ts-remote-test
+#
+#-------------------------------------------------------------------------------
+include(../ts-remote-test.cmake REQUIRED)
+
+#-------------------------------------------------------------------------------
+# Define library options and dependencies.
+#
+#-------------------------------------------------------------------------------
+env_set_link_options(TGT ts-remote-test)
+target_link_libraries(ts-remote-test PRIVATE stdc++ gcc m)
diff --git a/deployments/ts-remote-test/linux-pc/CMakeLists.txt b/deployments/ts-remote-test/linux-pc/CMakeLists.txt
new file mode 100644
index 0000000..5e5aaa5
--- /dev/null
+++ b/deployments/ts-remote-test/linux-pc/CMakeLists.txt
@@ -0,0 +1,24 @@
+#-------------------------------------------------------------------------------
+# 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)
+
+#-------------------------------------------------------------------------------
+# The CMakeLists.txt for building the ts-remote-test deployment for linux-pc
+#
+#-------------------------------------------------------------------------------
+include(${TS_ROOT}/environments/linux-pc/env.cmake)
+project(trusted-services LANGUAGES CXX C)
+add_executable(ts-remote-test)
+target_include_directories(ts-remote-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+
+#-------------------------------------------------------------------------------
+# Extend with components that are common across all deployments of
+# ts-remote-test
+#
+#-------------------------------------------------------------------------------
+include(../ts-remote-test.cmake REQUIRED)
diff --git a/deployments/ts-remote-test/ts-remote-test.cmake b/deployments/ts-remote-test/ts-remote-test.cmake
new file mode 100644
index 0000000..7e5b286
--- /dev/null
+++ b/deployments/ts-remote-test/ts-remote-test.cmake
@@ -0,0 +1,50 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# The base build file shared between deployments of 'ts-remote-test' for
+# different environments. Acts as a client for tests running in a remote
+# processing environment.
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# Use libts for locating and accessing services. An appropriate version of
+# libts will be imported for the enviroment in which tests are
+# deployed.
+#-------------------------------------------------------------------------------
+include(${TS_ROOT}/deployments/libts/libts-import.cmake)
+target_link_libraries(ts-remote-test PRIVATE libts)
+
+#-------------------------------------------------------------------------------
+# Common main for all deployments
+#
+#-------------------------------------------------------------------------------
+target_sources(ts-remote-test PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}/ts-remote-test.cpp"
+)
+
+#-------------------------------------------------------------------------------
+# Components that are common accross all deployments
+#
+#-------------------------------------------------------------------------------
+add_components(
+ TARGET "ts-remote-test"
+ BASE_DIR ${TS_ROOT}
+ COMPONENTS
+ "components/app/remote-test-runner"
+ "components/common/tlv"
+ "components/service/test_runner/client/cpp"
+)
+
+#-------------------------------------------------------------------------------
+# 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-remote-test RUNTIME DESTINATION bin)
\ No newline at end of file
diff --git a/deployments/ts-remote-test/ts-remote-test.cpp b/deployments/ts-remote-test/ts-remote-test.cpp
new file mode 100644
index 0000000..1c708f6
--- /dev/null
+++ b/deployments/ts-remote-test/ts-remote-test.cpp
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: BSD-2-Clause
+/*
+ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ */
+
+#include <service/test_runner/client/cpp/test_runner_client.h>
+#include <app/remote-test-runner/remote_test_runner.h>
+#include <protocols/rpc/common/packed-c/encoding.h>
+#include <service_locator.h>
+#include <rpc_caller.h>
+#include <cstdio>
+
+int main(int argc, char *argv[]) {
+ (void) argc;
+ (void) argv;
+
+ int status = -1;
+ struct service_context *test_runner_service_context = NULL;
+
+ service_locator_init();
+
+ test_runner_service_context = service_locator_query("sn:trustedfirmware.org:test-runner:0", &status);
+
+ if (test_runner_service_context) {
+
+ struct rpc_caller *caller;
+ rpc_session_handle rpc_session_handle;
+
+ rpc_session_handle = service_context_open(test_runner_service_context, TS_RPC_ENCODING_PACKED_C, &caller);
+
+ if (rpc_session_handle) {
+
+ test_runner_client test_runner_client(caller);
+ remote_test_runner commandline_runner(&test_runner_client);
+
+ status = commandline_runner.execute(argc, argv);
+
+ if (status != 0) {
+ printf("Command failed with test status: %d rpc status: %d\n", status, test_runner_client.err_rpc_status());
+ }
+
+ service_context_close(test_runner_service_context, rpc_session_handle);
+ }
+ else {
+ printf("Failed to open rpc session\n");
+ }
+
+ service_context_relinquish(test_runner_service_context);
+ }
+ else {
+ printf("Failed to discover test_runner service\n");
+ }
+
+ return status;
+}