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 | |
Imre Kis | 9f6f1b4 | 2023-08-02 16:24:10 +0200 | [diff] [blame] | 22 | test_runner_service_context = service_locator_query("sn:trustedfirmware.org:test-runner:0"); |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 23 | |
| 24 | if (test_runner_service_context) { |
| 25 | |
Imre Kis | 9f6f1b4 | 2023-08-02 16:24:10 +0200 | [diff] [blame] | 26 | struct rpc_caller_session *session = NULL; |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 27 | |
Imre Kis | 9f6f1b4 | 2023-08-02 16:24:10 +0200 | [diff] [blame] | 28 | session = service_context_open(test_runner_service_context); |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 29 | |
Imre Kis | 9f6f1b4 | 2023-08-02 16:24:10 +0200 | [diff] [blame] | 30 | if (session) { |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 31 | |
Imre Kis | 9f6f1b4 | 2023-08-02 16:24:10 +0200 | [diff] [blame] | 32 | test_runner_client test_runner_client(session); |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 33 | remote_test_runner commandline_runner(&test_runner_client); |
| 34 | |
| 35 | status = commandline_runner.execute(argc, argv); |
| 36 | |
| 37 | if (status != 0) { |
| 38 | printf("Command failed with test status: %d rpc status: %d\n", status, test_runner_client.err_rpc_status()); |
| 39 | } |
| 40 | |
Imre Kis | 9f6f1b4 | 2023-08-02 16:24:10 +0200 | [diff] [blame] | 41 | service_context_close(test_runner_service_context, session); |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 42 | } |
| 43 | else { |
| 44 | printf("Failed to open rpc session\n"); |
| 45 | } |
| 46 | |
| 47 | service_context_relinquish(test_runner_service_context); |
| 48 | } |
| 49 | else { |
| 50 | printf("Failed to discover test_runner service\n"); |
| 51 | } |
| 52 | |
| 53 | return status; |
| 54 | } |