julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: BSD-2-Clause |
| 2 | /* |
| 3 | * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | #include <service/test_runner/client/cpp/test_runner_client.h> |
| 7 | #include <app/remote-test-runner/remote_test_runner.h> |
| 8 | #include <protocols/rpc/common/packed-c/encoding.h> |
| 9 | #include <service_locator.h> |
| 10 | #include <rpc_caller.h> |
| 11 | #include <cstdio> |
| 12 | |
| 13 | int main(int argc, char *argv[]) { |
| 14 | (void) argc; |
| 15 | (void) argv; |
| 16 | |
| 17 | int status = -1; |
| 18 | struct service_context *test_runner_service_context = NULL; |
| 19 | |
| 20 | service_locator_init(); |
| 21 | |
| 22 | test_runner_service_context = service_locator_query("sn:trustedfirmware.org:test-runner:0", &status); |
| 23 | |
| 24 | if (test_runner_service_context) { |
| 25 | |
| 26 | struct rpc_caller *caller; |
| 27 | rpc_session_handle rpc_session_handle; |
| 28 | |
| 29 | rpc_session_handle = service_context_open(test_runner_service_context, TS_RPC_ENCODING_PACKED_C, &caller); |
| 30 | |
| 31 | if (rpc_session_handle) { |
| 32 | |
| 33 | test_runner_client test_runner_client(caller); |
| 34 | remote_test_runner commandline_runner(&test_runner_client); |
| 35 | |
| 36 | status = commandline_runner.execute(argc, argv); |
| 37 | |
| 38 | if (status != 0) { |
| 39 | printf("Command failed with test status: %d rpc status: %d\n", status, test_runner_client.err_rpc_status()); |
| 40 | } |
| 41 | |
| 42 | service_context_close(test_runner_service_context, rpc_session_handle); |
| 43 | } |
| 44 | else { |
| 45 | printf("Failed to open rpc session\n"); |
| 46 | } |
| 47 | |
| 48 | service_context_relinquish(test_runner_service_context); |
| 49 | } |
| 50 | else { |
| 51 | printf("Failed to discover test_runner service\n"); |
| 52 | } |
| 53 | |
| 54 | return status; |
| 55 | } |